mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
test --digit
This commit is contained in:
parent
1d34537e9e
commit
d3e694fae0
@ -100,12 +100,10 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
|||||||
botcom.dict["runcount"] = runcount
|
botcom.dict["runcount"] = runcount
|
||||||
|
|
||||||
botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"])
|
botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"])
|
||||||
if not botcom.dict["hyphen_arg"]:
|
args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom)
|
||||||
# check if anything prohibits the nick from running the command
|
if args_pass:
|
||||||
if trigger_runstatus(bot, trigger, botcom):
|
if trigger_runstatus(bot, trigger, botcom):
|
||||||
function(bot, trigger, botcom, *args, **kwargs)
|
function(bot, trigger, botcom, *args, **kwargs)
|
||||||
else:
|
|
||||||
trigger_hyphen_arg_handler(bot, trigger, botcom)
|
|
||||||
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
|
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
|
||||||
|
|
||||||
return internal_prerun
|
return internal_prerun
|
||||||
@ -408,8 +406,14 @@ def trigger_hyphen_args(trigger_args_part):
|
|||||||
hyphen_args = []
|
hyphen_args = []
|
||||||
trigger_args_unhyphend = []
|
trigger_args_unhyphend = []
|
||||||
for worditem in trigger_args_part:
|
for worditem in trigger_args_part:
|
||||||
if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args:
|
if str(worditem).startswith("--"):
|
||||||
hyphen_args.append(worditem[2:])
|
clipped_word = worditem[2:]
|
||||||
|
if clipped_word in valid_hyphen_args:
|
||||||
|
hyphen_args.append(clipped_word)
|
||||||
|
elif str(clipped_word).isdigit():
|
||||||
|
hyphen_args.append(int(clipped_word))
|
||||||
|
else:
|
||||||
|
trigger_args_unhyphend.append(worditem)
|
||||||
else:
|
else:
|
||||||
trigger_args_unhyphend.append(worditem)
|
trigger_args_unhyphend.append(worditem)
|
||||||
if len(hyphen_args):
|
if len(hyphen_args):
|
||||||
@ -423,12 +427,20 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
|||||||
|
|
||||||
# Commands that cannot run via privmsg
|
# Commands that cannot run via privmsg
|
||||||
# TODO --check should work for commands that don't exist
|
# TODO --check should work for commands that don't exist
|
||||||
if botcom.dict["hyphen_arg"] in ['check']:
|
|
||||||
|
if not botcom.dict["hyphen_arg"]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# handle numbered args
|
||||||
|
if str(botcom.dict["hyphen_arg"]).isdigit():
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif botcom.dict["hyphen_arg"] in ['check']:
|
||||||
if botcom.dict["com"].lower() != botcom.dict["realcom"]:
|
if botcom.dict["com"].lower() != botcom.dict["realcom"]:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid alias command for " + botcom.dict["realcomtext"])
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid alias command for " + botcom.dict["realcomtext"])
|
||||||
else:
|
else:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid command")
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid command")
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in [
|
elif botcom.dict["hyphen_arg"] in [
|
||||||
'enable', 'disable',
|
'enable', 'disable',
|
||||||
@ -443,12 +455,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
|||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " usage for?")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " usage for?")
|
||||||
else:
|
else:
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " usage for?")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " usage for?")
|
||||||
return
|
return False
|
||||||
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
|
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
|
||||||
|
|
||||||
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
|
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||||
if target != trigger.nick:
|
if target != trigger.nick:
|
||||||
@ -456,37 +468,37 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
|||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.")
|
||||||
else:
|
else:
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to disable this command for " + str(target) + " due to privilege issues.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to disable this command for " + str(target) + " due to privilege issues.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||||
|
|
||||||
if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target):
|
if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already enabled for " + str(target))
|
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already enabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], target)
|
botcommands.unset_command_disabled(botcom.dict["realcomref"], target)
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(target))
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if botcommands.check_commands_disabled(botcom.dict["realcomref"], target):
|
if botcommands.check_commands_disabled(botcom.dict["realcomref"], target):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already disabled for " + str(target))
|
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already disabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
||||||
timestamp = str(datetime.datetime.utcnow())
|
timestamp = str(datetime.datetime.utcnow())
|
||||||
|
|
||||||
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick)
|
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick)
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now disabled for " + str(target))
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now disabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
if botcom.dict["hyphen_arg"] in ['multirun', 'multiruns']:
|
if botcom.dict["hyphen_arg"] in ['multirun', 'multiruns']:
|
||||||
|
|
||||||
onoff = spicemanip.main(botcom.dict["args"], 1) or None
|
onoff = spicemanip.main(botcom.dict["args"], 1) or None
|
||||||
if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]:
|
if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]:
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Do you want to enable or disable " + str(botcom.dict["comtext"]) + " multirun usage?")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "Do you want to enable or disable " + str(botcom.dict["comtext"]) + " multirun usage?")
|
||||||
return
|
return False
|
||||||
|
|
||||||
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
||||||
if not target:
|
if not target:
|
||||||
@ -494,12 +506,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
|||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
||||||
else:
|
else:
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
||||||
return
|
return False
|
||||||
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
|
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
|
||||||
|
|
||||||
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
|
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||||
if target != trigger.nick:
|
if target != trigger.nick:
|
||||||
@ -507,53 +519,53 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
|
|||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.")
|
||||||
else:
|
else:
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.")
|
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.")
|
||||||
return
|
return False
|
||||||
|
|
||||||
if onoff in ['enable', 'unblock', "activate", "on"]:
|
if onoff in ['enable', 'unblock', "activate", "on"]:
|
||||||
|
|
||||||
if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"):
|
if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already enabled for " + str(target))
|
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already enabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], target, "multirun")
|
botcommands.unset_command_disabled(botcom.dict["realcomref"], target, "multirun")
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now enabled for " + str(target))
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now enabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"):
|
if botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"):
|
||||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already disabled for " + str(target))
|
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already disabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
||||||
timestamp = str(datetime.datetime.utcnow())
|
timestamp = str(datetime.datetime.utcnow())
|
||||||
|
|
||||||
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick, "multirun")
|
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick, "multirun")
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now disabled for " + str(target))
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now disabled for " + str(target))
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['example', 'usage']:
|
elif botcom.dict["hyphen_arg"] in ['example', 'usage']:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + ": " + str(botcom.dict["dict"]["example"]))
|
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + ": " + str(botcom.dict["dict"]["example"]))
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['filename', 'filepath']:
|
elif botcom.dict["hyphen_arg"] in ['filename', 'filepath']:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " file is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]]))
|
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " file is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]]))
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['foldername', 'folderpath']:
|
elif botcom.dict["hyphen_arg"] in ['foldername', 'folderpath']:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " folder is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]]))
|
botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " folder is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]]))
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['author']:
|
elif botcom.dict["hyphen_arg"] in ['author']:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], "The author of the " + str(botcom.dict["comtext"]) + " command is " + botcom.dict["dict"]["author"] + ".")
|
botmessagelog.messagelog(botcom.dict["log_id"], "The author of the " + str(botcom.dict["comtext"]) + " command is " + botcom.dict["dict"]["author"] + ".")
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['contribs', 'contrib', "contributors"]:
|
elif botcom.dict["hyphen_arg"] in ['contribs', 'contrib', "contributors"]:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], "The contributors of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["contributors"], "andlist") + ".")
|
botmessagelog.messagelog(botcom.dict["log_id"], "The contributors of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["contributors"], "andlist") + ".")
|
||||||
return
|
return False
|
||||||
|
|
||||||
elif botcom.dict["hyphen_arg"] in ['alias', 'aliases']:
|
elif botcom.dict["hyphen_arg"] in ['alias', 'aliases']:
|
||||||
botmessagelog.messagelog(botcom.dict["log_id"], "The alaises of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["validcoms"], "andlist") + ".")
|
botmessagelog.messagelog(botcom.dict["log_id"], "The alaises of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["validcoms"], "andlist") + ".")
|
||||||
return
|
return False
|
||||||
|
|
||||||
return
|
return False
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user