From b9ed0a9b3b573051831d2dec8ee0a313c53982a5 Mon Sep 17 00:00:00 2001 From: mrhanky Date: Mon, 21 Aug 2017 16:59:27 +0200 Subject: [PATCH] Cosmetics and added own docopt so we have propert DocOptDict.get --- bot/plugins/coins.py | 4 ++-- bot/plugins/ctcp.py | 4 ++-- bot/plugins/rape.py | 4 ++-- bot/plugins/seen.py | 2 +- bot/plugins/useless.py | 21 ++++++++++----------- bot/plugins/youtube.py | 4 ++-- requirements.txt | 1 + 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bot/plugins/coins.py b/bot/plugins/coins.py index 2ebf485..d3cb926 100644 --- a/bot/plugins/coins.py +++ b/bot/plugins/coins.py @@ -26,7 +26,7 @@ class Coins(Plugin): %%btc [] """ - return self.cryptowat_summary('btc', args.get('') or 'usd') + return self.cryptowat_summary('btc', args.get('', 'usd')) @command def eth(self, mask: IrcString, target: IrcString, args: DocOptDict): @@ -34,7 +34,7 @@ class Coins(Plugin): %%eth [] """ - return self.cryptowat_summary('eth', args.get('') or 'usd') + return self.cryptowat_summary('eth', args.get('', 'usd')) def cryptowat_summary(self, crypto: str, currency: str = 'usd'): # Check if valid currency + crypto2currency diff --git a/bot/plugins/ctcp.py b/bot/plugins/ctcp.py index 1748004..d877d12 100644 --- a/bot/plugins/ctcp.py +++ b/bot/plugins/ctcp.py @@ -19,7 +19,7 @@ class CTCP(Plugin): return '\x02[{}]\x02 {}: {}'.format(name.upper(), nick, reply) async def ctcp(self, name: str, mask: IrcString, args: DocOptDict): - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) name = name.upper() data = await self.bot.ctcp_async(nick, name) @@ -38,7 +38,7 @@ class CTCP(Plugin): %%ping [] """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) data = await self.bot.ctcp_async(nick, 'PING {}'.format(time.time())) if not data or data['timeout']: diff --git a/bot/plugins/rape.py b/bot/plugins/rape.py index 3e33dfd..8a677eb 100644 --- a/bot/plugins/rape.py +++ b/bot/plugins/rape.py @@ -21,7 +21,7 @@ class Rape(DatabasePlugin): %%owe [] """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) # Fetch result from database self.cur.execute(''' @@ -49,7 +49,7 @@ class Rape(DatabasePlugin): %%rape """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) rand = random.randint(0, 3) if rand not in (0, 1): diff --git a/bot/plugins/seen.py b/bot/plugins/seen.py index 42a2130..279e6dd 100644 --- a/bot/plugins/seen.py +++ b/bot/plugins/seen.py @@ -22,7 +22,7 @@ class Seen(DatabasePlugin): %%seen [] """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) # Don't be stupid if nick == mask.nick: diff --git a/bot/plugins/useless.py b/bot/plugins/useless.py index 00391b3..51d2284 100644 --- a/bot/plugins/useless.py +++ b/bot/plugins/useless.py @@ -100,7 +100,7 @@ class Useless(DatabasePlugin): 1 ''') self.bot.action(target, self.cur.fetchone()['item'].format( - nick=args.get('') or mask.nick, + nick=args.get('', mask.nick), )) @command @@ -120,7 +120,7 @@ class Useless(DatabasePlugin): 1 ''') self.bot.action(target, self.cur.fetchone()['item'].format( - nick=args.get('') or mask.nick, + nick=args.get('', mask.nick), yiffer=mask.nick, )) @@ -240,7 +240,7 @@ class Useless(DatabasePlugin): %%kiss [] """ - return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x0F {} \x0304❤'.format(args.get('') or mask.nick) + return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x0F {} \x0304❤'.format(args.get('', mask.nick)) @command def hug(self, mask: IrcString, target: IrcString, args: DocOptDict): @@ -248,7 +248,7 @@ class Useless(DatabasePlugin): %%hug [] """ - return '\x0304♥♡❤♡♥\x0F {} \x0304♥♡❤♡♥'.format(args.get('') or mask.nick) + return '\x0304♥♡❤♡♥\x0F {} \x0304♥♡❤♡♥'.format(args.get('', mask.nick)) @command def bier(self, mask: IrcString, target: IrcString, args: DocOptDict): @@ -256,7 +256,7 @@ class Useless(DatabasePlugin): %%bier [] """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) self.bot.action(target, 'schenkt ein kühles Blondes an {} aus.'.format(nick)) @command @@ -265,7 +265,7 @@ class Useless(DatabasePlugin): %%fucken [] """ - nick = args.get('') or mask.nick + nick = args.get('', mask.nick) self.bot.action(target, 'fuckt {0} und tötet {0} anschließend.'.format(nick, nick)) @command @@ -290,7 +290,7 @@ class Useless(DatabasePlugin): %%hack [] """ - nick = args.get('') or '' + nick = args.get('') return 'hacking{}...'.format(' %s' % nick if nick else '') @command @@ -330,8 +330,8 @@ class Useless(DatabasePlugin): %%asshole [] """ - nick = args.get('') or mask.nick - asshole_perc = random.randint(0,100) + nick = args.get('', mask.nick) + asshole_perc = random.randint(0, 100) if nick == 'mrhanky': asshole_perc = 100 @@ -344,8 +344,7 @@ class Useless(DatabasePlugin): %%assume [] """ - nick = args.get('') or mask.nick - + nick = args.get('', mask.nick) gender = random.choice(GENDERS) return 'Assuming {}''s gender... they''re a {}.'.format(nick, gender) diff --git a/bot/plugins/youtube.py b/bot/plugins/youtube.py index 50234d8..4a57ea1 100644 --- a/bot/plugins/youtube.py +++ b/bot/plugins/youtube.py @@ -77,8 +77,8 @@ class YouTube(Plugin): data = self.get_video_data(video_id) return '{} - https://youtu.be/{}'.format(data, video_id) - @staticmethod - def _api(url: str, **kwargs): + # noinspection PyMethodMayBeStatic + def _api(self, url: str, **kwargs): """Wrapper around requests.get which adds the Google API key.""" kwargs['key'] = os.environ['GOOGLE_API_KEY'] return requests.get(url, params=kwargs).json() diff --git a/requirements.txt b/requirements.txt index a1d2037..cdd86d6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ #git+https://github.com/gawel/irc3.git#egg=irc3 git+https://github.com/mrhanky17/irc3.git#egg=irc3 +git+https://github.com/mrhanky17/docopt.git#egg=docopt psycopg2==2.7.1 requests==2.14.2 feedparser==5.2.1