Cosmetics and added own docopt so we have propert DocOptDict.get

This commit is contained in:
mrhanky 2017-08-21 16:59:27 +02:00
parent 18695cf011
commit b9ed0a9b3b
No known key found for this signature in database
GPG Key ID: 67D772C481CB41B8
7 changed files with 20 additions and 20 deletions

View File

@ -26,7 +26,7 @@ class Coins(Plugin):
%%btc [<currency>]
"""
return self.cryptowat_summary('btc', args.get('<currency>') or 'usd')
return self.cryptowat_summary('btc', args.get('<currency>', 'usd'))
@command
def eth(self, mask: IrcString, target: IrcString, args: DocOptDict):
@ -34,7 +34,7 @@ class Coins(Plugin):
%%eth [<currency>]
"""
return self.cryptowat_summary('eth', args.get('<currency>') or 'usd')
return self.cryptowat_summary('eth', args.get('<currency>', 'usd'))
def cryptowat_summary(self, crypto: str, currency: str = 'usd'):
# Check if valid currency + crypto2currency

View File

@ -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('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
name = name.upper()
data = await self.bot.ctcp_async(nick, name)
@ -38,7 +38,7 @@ class CTCP(Plugin):
%%ping [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
data = await self.bot.ctcp_async(nick, 'PING {}'.format(time.time()))
if not data or data['timeout']:

View File

@ -21,7 +21,7 @@ class Rape(DatabasePlugin):
%%owe [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
# Fetch result from database
self.cur.execute('''
@ -49,7 +49,7 @@ class Rape(DatabasePlugin):
%%rape <nick>
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
rand = random.randint(0, 3)
if rand not in (0, 1):

View File

@ -22,7 +22,7 @@ class Seen(DatabasePlugin):
%%seen [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
# Don't be stupid
if nick == mask.nick:

View File

@ -100,7 +100,7 @@ class Useless(DatabasePlugin):
1
''')
self.bot.action(target, self.cur.fetchone()['item'].format(
nick=args.get('<nick>') or mask.nick,
nick=args.get('<nick>', mask.nick),
))
@command
@ -120,7 +120,7 @@ class Useless(DatabasePlugin):
1
''')
self.bot.action(target, self.cur.fetchone()['item'].format(
nick=args.get('<nick>') or mask.nick,
nick=args.get('<nick>', mask.nick),
yiffer=mask.nick,
))
@ -240,7 +240,7 @@ class Useless(DatabasePlugin):
%%kiss [<nick>]
"""
return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x0F {} \x0304❤'.format(args.get('<nick>') or mask.nick)
return '(づ。◕‿‿◕。)\x0304。。・゜゜・。。・゜❤\x0F {} \x0304❤'.format(args.get('<nick>', mask.nick))
@command
def hug(self, mask: IrcString, target: IrcString, args: DocOptDict):
@ -248,7 +248,7 @@ class Useless(DatabasePlugin):
%%hug [<nick>]
"""
return '\x0304♥♡❤♡♥\x0F {} \x0304♥♡❤♡♥'.format(args.get('<nick>') or mask.nick)
return '\x0304♥♡❤♡♥\x0F {} \x0304♥♡❤♡♥'.format(args.get('<nick>', mask.nick))
@command
def bier(self, mask: IrcString, target: IrcString, args: DocOptDict):
@ -256,7 +256,7 @@ class Useless(DatabasePlugin):
%%bier [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', 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>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', 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>]
"""
nick = args.get('<nick>') or ''
nick = args.get('<nick>')
return 'hacking{}...'.format(' %s' % nick if nick else '')
@command
@ -330,7 +330,7 @@ class Useless(DatabasePlugin):
%%asshole [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
asshole_perc = random.randint(0, 100)
if nick == 'mrhanky':
@ -344,8 +344,7 @@ class Useless(DatabasePlugin):
%%assume [<nick>]
"""
nick = args.get('<nick>') or mask.nick
nick = args.get('<nick>', mask.nick)
gender = random.choice(GENDERS)
return 'Assuming {}''s gender... they''re a {}.'.format(nick, gender)

View File

@ -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()

View File

@ -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