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