arg = args() → args = arg()

This commit is contained in:
Juhani Krekelä 2019-05-12 14:32:52 +03:00
parent c688acf55e
commit 7365619fcb
1 changed files with 45 additions and 45 deletions

View File

@ -179,7 +179,7 @@ def parse_command(message, nick, irc):
global irc_chan
irc.bot_response(irc_chan, m)
def args(num, index = 1):
def arg(num, index = 1):
nonlocal message
if type(num) == int:
num = [num]
@ -197,27 +197,27 @@ def parse_command(message, nick, irc):
c = message[0]
if c == '!status':
if args(0) is not None:
if arg(0) is not None:
send_event((events.status,))
elif c == '!start':
arg = args([0, 1])
if arg is not None:
if len(arg) == 0:
args = arg([0, 1])
if args is not None:
if len(args) == 0:
send_event((events.start, nick))
else:
send_event((events.start, nick, arg[0]))
send_event((events.start, nick, args[0]))
elif c == '!ready':
if args(0) is not None:
if arg(0) is not None:
send_event((events.ready, nick))
elif c == '!unready':
if args(0) is not None:
if arg(0) is not None:
send_event((events.unready, nick))
elif c == '!kill':
if args(0) is not None:
if arg(0) is not None:
send_event((events.kill,))
elif c == '!join':
@ -227,17 +227,17 @@ def parse_command(message, nick, irc):
send_event((events.join, nick))
elif c == '!leave':
if args(0) is not None:
if arg(0) is not None:
send_event((events.leave, nick))
elif c == '!players':
if args(0) is not None:
if arg(0) is not None:
send_event((events.players,))
elif c == '!kick':
arg = args(1)
if arg is not None:
kickee, = arg
args = arg(1)
if args is not None:
kickee, = args
send_event((events.kick, nick, kickee))
elif c == '!deck':
@ -247,22 +247,22 @@ def parse_command(message, nick, irc):
subc = message[1]
if subc == 'add':
arg = args(1, 2)
if arg is not None:
code, = arg
args = arg(1, 2)
if args is not None:
code, = args
if code == 'random':
send_event((events.deck_add_random,))
else:
send_event((events.deck_add, code))
elif subc == 'remove':
arg = args(1, 2)
if arg is not None:
code, = arg
args = arg(1, 2)
if args is not None:
code, = args
send_event((events.deck_remove, code))
elif subc == 'list':
if args(0, 2) is not None:
if arg(0, 2) is not None:
send_event((events.deck_list,))
else:
@ -275,12 +275,12 @@ def parse_command(message, nick, irc):
subc = message[1]
if subc == 'add':
arg = args([1, 2], 2)
if arg is not None:
if len(arg) == 2:
bot_type, name = arg
args = arg([1, 2], 2)
if args is not None:
if len(args) == 2:
bot_type, name = args
else:
bot_type, = arg
bot_type, = args
name = bot_type
if bot_type == 'rando':
send_event((events.bot_add_rando, name))
@ -288,30 +288,30 @@ def parse_command(message, nick, irc):
send('Allowed bot types: rando')
elif subc == 'remove':
arg = args(1, 2)
if arg is not None:
name, = arg
args = arg(1, 2)
if args is not None:
name, = args
send_event((events.bot_remove, name))
else:
send(usage('!bot'))
elif c == '!limit':
arg = args([0, 1, 2])
if arg is None: return
args = arg([0, 1, 2])
if args is None: return
if len(arg) == 0:
if len(args) == 0:
send_event((events.limit,))
else:
num = arg[0]
num = args[0]
if not num.isdecimal():
send(usage('!limit'))
return
num = int(num)
if len(arg) == 2:
limit_type = arg[1]
if len(args) == 2:
limit_type = args[1]
if limit_type == 'p' or limit_type == 'points':
send_event((events.limit, gameloop.limit_types.points, num))
@ -325,33 +325,33 @@ def parse_command(message, nick, irc):
elif c == '!card' or all(i.isdecimal() for i in message):
if c == '!card':
arg = message[1:]
args = message[1:]
else:
arg = message
args = message
if not all(i.isdecimal() for i in arg):
if not all(i.isdecimal() for i in args):
send(usage('!card'))
return
choices = [int(i) for i in arg]
choices = [int(i) for i in args]
send_event((events.card, nick, choices))
elif c == '!cards':
if args(0) is not None:
if arg(0) is not None:
send_event((events.cards, nick))
elif c == '!origins':
if args(0) is not None:
if arg(0) is not None:
send_event((events.origins, nick))
elif c == '!redeal':
if args(0) is not None:
if arg(0) is not None:
send_event((events.redeal, nick))
elif c == '!help':
arg = args([0, 1, 2])
if arg is not None:
send(usage(arg))
args = arg([0, 1, 2])
if args is not None:
send(usage(args))
# initialize(*, config)
# Called to initialize the IRC bot