mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
test
This commit is contained in:
parent
64d2d50038
commit
aa66676ee1
@ -53,15 +53,15 @@ class BotPrerun():
|
|||||||
|
|
||||||
# Run the function for all splits
|
# Run the function for all splits
|
||||||
for argsdict in argsdict_list:
|
for argsdict in argsdict_list:
|
||||||
trigger.sb = argsdict
|
trigger.sb = copy.deepcopy(argsdict)
|
||||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
||||||
if not trigger.sb["hyphen_arg"]:
|
if not trigger.sb["hyphen_arg"]:
|
||||||
# check if anything prohibits the nick from running the command
|
# check if anything prohibits the nick from running the command
|
||||||
if self.trigger_runstatus(bot, trigger, argsdict):
|
if self.trigger_runstatus(bot, trigger):
|
||||||
function(bot, trigger, *args, **kwargs)
|
function(bot, trigger, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
self.trigger_hyphen_arg_handler(bot, trigger)
|
self.trigger_hyphen_arg_handler(bot, trigger)
|
||||||
return function(bot, trigger, *args, **kwargs)
|
|
||||||
return internal_prerun
|
return internal_prerun
|
||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
@ -115,38 +115,46 @@ class BotPrerun():
|
|||||||
bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"])
|
bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"])
|
||||||
else:
|
else:
|
||||||
bot.say(trigger.sb["com"] + " is a valid command")
|
bot.say(trigger.sb["com"] + " is a valid command")
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
elif trigger.sb["hyphen_arg"] in ['enable']:
|
elif trigger.sb["hyphen_arg"] in ['enable']:
|
||||||
|
|
||||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||||
bot.say("I was unable to disable this command due to privilege issues.")
|
bot.say("I was unable to disable this command due to privilege issues.")
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if trigger.is_privmsg:
|
if trigger.is_privmsg:
|
||||||
bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick)
|
bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick)
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender):
|
if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender):
|
||||||
bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick)
|
bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick)
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender)
|
commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender)
|
||||||
bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender))
|
bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender))
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
elif trigger.sb["hyphen_arg"] in ['disable']:
|
elif trigger.sb["hyphen_arg"] in ['disable']:
|
||||||
|
|
||||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||||
bot.say("I was unable to disable this command due to privilege issues.")
|
bot.say("I was unable to disable this command due to privilege issues.")
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if trigger.is_privmsg:
|
if trigger.is_privmsg:
|
||||||
bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick)
|
bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick)
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender):
|
if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender):
|
||||||
bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick)
|
bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick)
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
||||||
@ -154,20 +162,22 @@ class BotPrerun():
|
|||||||
|
|
||||||
commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick)
|
commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick)
|
||||||
bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender))
|
bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender))
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
|
trigger.sb["hyphen_arg"] = None
|
||||||
return
|
return
|
||||||
|
|
||||||
def trigger_runstatus(self, bot, trigger, argsdict):
|
def trigger_runstatus(self, bot, trigger):
|
||||||
|
|
||||||
# don't run commands that are disabled in channels
|
# don't run commands that are disabled in channels
|
||||||
if not trigger.is_privmsg:
|
if not trigger.is_privmsg:
|
||||||
disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {}
|
disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {}
|
||||||
if argsdict["realcom"] in disabled_list.keys():
|
if trigger.sb["realcom"] in disabled_list.keys():
|
||||||
reason = disabled_list[argsdict["realcom"]]["reason"]
|
reason = disabled_list[trigger.sb["realcom"]]["reason"]
|
||||||
timestamp = disabled_list[argsdict["realcom"]]["timestamp"]
|
timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"]
|
||||||
bywhom = disabled_list[argsdict["realcom"]]["disabledby"]
|
bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"]
|
||||||
bot.notice("The " + str(argsdict["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick)
|
bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user