Compare commits
No commits in common. "d8caed033ee5e34e6ef4bb2aaf42ba88e342cba6" and "2397ded4b581d79da7fa724105365d7367f8772d" have entirely different histories.
d8caed033e
...
2397ded4b5
2
bot.py
2
bot.py
|
@ -173,7 +173,7 @@ class Fulvia(irc.IRCClient):
|
|||
self._hooks.remove(func)
|
||||
|
||||
if func.rate or func.channel_rate or func.global_rate:
|
||||
self._times.pop(func.__name__)
|
||||
self._times.pop(func)
|
||||
|
||||
if hasattr(func, 'url_callback'):
|
||||
for url in func.url_callback:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
ASCII
|
||||
"""
|
||||
from io import BytesIO
|
||||
import argparse
|
||||
|
||||
import requests
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
|
@ -10,7 +11,6 @@ from PIL import Image, ImageFont, ImageDraw
|
|||
import numpy as np
|
||||
import numpngw
|
||||
|
||||
import tools
|
||||
import module
|
||||
|
||||
ASCII_CHARS = "$@%#*+=-:. "
|
||||
|
@ -235,7 +235,7 @@ def ascii(bot, trigger):
|
|||
"""
|
||||
if len(trigger.args) < 2:
|
||||
return bot.msg()
|
||||
parser = tools.FulviaArgparse()
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser.add_argument("imagePath")
|
||||
parser.add_argument("-r", "--reverse", action="store_true", help="Reverse.")
|
||||
parser.add_argument("-c", "--color", action="store_true")
|
||||
|
@ -243,10 +243,10 @@ def ascii(bot, trigger):
|
|||
parser.add_argument("-B", "--brail2", action="store_true")
|
||||
parser.add_argument("-a", "--animated", action="store_true")
|
||||
parser.add_argument("-h", "--help", action="store_true")
|
||||
try:
|
||||
args = parser.parse_args(trigger.args[1:])
|
||||
except Exception as e:
|
||||
return bot.reply(type(e).__name__ + ": " + str(e))
|
||||
|
||||
if args.help:
|
||||
return bot.msg(parser.print_help())
|
||||
|
||||
if args.color:
|
||||
args.color = "irc"
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
Resistor color band codes.
|
||||
"""
|
||||
import re
|
||||
import argparse
|
||||
|
||||
import tools
|
||||
from module import commands, example
|
||||
|
||||
suffix = {"k": 1000, "m": 10000000}
|
||||
|
@ -62,14 +62,11 @@ def resist(bot, trigger):
|
|||
"""
|
||||
if len(trigger.args) < 2:
|
||||
return bot.msg("Please specify a value")
|
||||
parser = tools.FulviaArgparse()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("value", nargs="+")
|
||||
parser.add_argument("-r", "--reverse", action="store_true")
|
||||
parser.add_argument("-n", "--num_bands", type=int, choices=[3,4,5,6], default=4)
|
||||
try:
|
||||
args = parser.parse_args(trigger.args[1:])
|
||||
except Exception as e:
|
||||
return bot.reply(type(e).__name__ + ": " + str(e))
|
||||
|
||||
if args.reverse: # bands-to-value
|
||||
bot.msg(bands_to_value(" ".join(args.value)))
|
||||
|
|
|
@ -4,13 +4,13 @@ When was this user last seen.
|
|||
"""
|
||||
import os
|
||||
import time
|
||||
import argparse
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from sqlite3 import OperationalError
|
||||
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
import tools
|
||||
import config
|
||||
from tools.time import relativeTime
|
||||
from module import commands, example, hook, require_chanmsg, rate
|
||||
|
@ -68,16 +68,13 @@ def seen(bot, trigger):
|
|||
if len(trigger.args) < 2:
|
||||
return bot.reply("Seen who?")
|
||||
|
||||
parser = tools.FulviaArgparse()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("nick")
|
||||
parser.add_argument("-l", "--last", action="store_true", default=True)
|
||||
parser.add_argument("-f", "--first", action="store_true")
|
||||
parser.add_argument("-m", "--message", action="store_true")
|
||||
parser.add_argument("-c", "--context", action="store_true")
|
||||
try:
|
||||
args = parser.parse_args(trigger.args[1:])
|
||||
except Exception as e:
|
||||
return bot.reply(type(e).__name__ + ": " + str(e))
|
||||
|
||||
if args.nick == bot.nick:
|
||||
return bot.reply("I'm right here!")
|
||||
|
|
|
@ -5,8 +5,8 @@ All data comes from http://www.rsdb.org/.
|
|||
"""
|
||||
import random
|
||||
import sqlite3
|
||||
import argparse
|
||||
|
||||
import tools
|
||||
from module import commands
|
||||
|
||||
|
||||
|
@ -33,14 +33,11 @@ def slur(bot, trigger):
|
|||
-s, --slur - specifies a particular slur to pick.
|
||||
-l, --list - prints a list of available races.
|
||||
"""
|
||||
parser = tools.FulviaArgparse()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-r", "--race", type=str, nargs='+')
|
||||
parser.add_argument("-s", "--slur", type=str)
|
||||
parser.add_argument("-l", "--list", action="store_true")
|
||||
try:
|
||||
args = parser.parse_args(trigger.args[1:])
|
||||
except Exception as e:
|
||||
return bot.reply(type(e).__name__ + ": " + str(e))
|
||||
|
||||
if args.list:
|
||||
races = bot.db.execute("SELECT DISTINCT race FROM slur").fetchall()
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
Google translate that shit.
|
||||
"""
|
||||
import random
|
||||
import argparse
|
||||
|
||||
import requests
|
||||
|
||||
import tools
|
||||
from module import commands, example
|
||||
|
||||
|
||||
|
@ -45,14 +45,11 @@ def tr2(bot, trigger):
|
|||
if len(trigger.args) < 2:
|
||||
return bot.reply("Translate what?")
|
||||
|
||||
parser = tools.FulviaArgparse()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("text", nargs=argparse.REMAINDER)
|
||||
parser.add_argument("-i", "--inlang", default="auto")
|
||||
parser.add_argument("-o", "--outlang", default="en")
|
||||
try:
|
||||
args = parser.parse_args(trigger.args[1:])
|
||||
except Exception as e:
|
||||
return bot.reply(type(e).__name__ + ": " + str(e))
|
||||
args.text = " ".join(args.text)
|
||||
|
||||
tr_text, in_lang = translate(args.text, in_lang=args.inlang,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
Some helper functions and other tools.
|
||||
"""
|
||||
import re
|
||||
import argparse
|
||||
import threading
|
||||
from collections import defaultdict
|
||||
|
||||
|
@ -200,16 +199,3 @@ def getOpSym(level):
|
|||
return "+"
|
||||
else:
|
||||
return " "
|
||||
|
||||
|
||||
class FulviaArgparse(argparse.ArgumentParser):
|
||||
"""
|
||||
A custom ArgParser class that raises errors as exceptions rather than
|
||||
printing them to stderr.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['add_help'] = False
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def error(self, message):
|
||||
raise argparse.ArgumentError(None, message)
|
||||
|
|
Loading…
Reference in New Issue
Block a user