mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
bad paste tabbing
This commit is contained in:
parent
2ab6b0f287
commit
a0216e81fb
@ -98,91 +98,91 @@ class BotPrerun():
|
||||
|
||||
return True
|
||||
|
||||
"""Hyphenargs"""
|
||||
"""Hyphenargs"""
|
||||
|
||||
def hyphenargs(self):
|
||||
def actual_decorator(function):
|
||||
@functools.wraps(function)
|
||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
||||
if not trigger.sb["hyphen_arg"]:
|
||||
# check if anything prohibits the nick from running the command
|
||||
if self.trigger_runstatus(bot, trigger):
|
||||
return function(bot, trigger, *args, **kwargs)
|
||||
else:
|
||||
return self.trigger_hyphen_arg_handler(bot, trigger)
|
||||
return internal_prerun
|
||||
return actual_decorator
|
||||
|
||||
def trigger_hyphen_args(self, trigger_args_part):
|
||||
valid_hyphen_args = [
|
||||
'check',
|
||||
'enable', 'disable'
|
||||
]
|
||||
hyphen_args = []
|
||||
trigger_args_unhyphend = []
|
||||
for worditem in trigger_args_part:
|
||||
if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args:
|
||||
hyphen_args.append(worditem[2:])
|
||||
def hyphenargs(self):
|
||||
def actual_decorator(function):
|
||||
@functools.wraps(function)
|
||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
||||
if not trigger.sb["hyphen_arg"]:
|
||||
# check if anything prohibits the nick from running the command
|
||||
if self.trigger_runstatus(bot, trigger):
|
||||
return function(bot, trigger, *args, **kwargs)
|
||||
else:
|
||||
trigger_args_unhyphend.append(worditem)
|
||||
if len(hyphen_args):
|
||||
hyphenarg = hyphen_args[0]
|
||||
return self.trigger_hyphen_arg_handler(bot, trigger)
|
||||
return internal_prerun
|
||||
return actual_decorator
|
||||
|
||||
def trigger_hyphen_args(self, trigger_args_part):
|
||||
valid_hyphen_args = [
|
||||
'check',
|
||||
'enable', 'disable'
|
||||
]
|
||||
hyphen_args = []
|
||||
trigger_args_unhyphend = []
|
||||
for worditem in trigger_args_part:
|
||||
if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args:
|
||||
hyphen_args.append(worditem[2:])
|
||||
else:
|
||||
hyphenarg = None
|
||||
return trigger_args_unhyphend, hyphenarg
|
||||
trigger_args_unhyphend.append(worditem)
|
||||
if len(hyphen_args):
|
||||
hyphenarg = hyphen_args[0]
|
||||
else:
|
||||
hyphenarg = None
|
||||
return trigger_args_unhyphend, hyphenarg
|
||||
|
||||
def trigger_hyphen_arg_handler(self, bot, trigger):
|
||||
|
||||
# Commands that cannot run via privmsg
|
||||
if trigger.sb["hyphen_arg"] in ['check']:
|
||||
if trigger.sb["com"].lower() != trigger.sb["realcom"]:
|
||||
bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"])
|
||||
else:
|
||||
bot.say(trigger.sb["com"] + " is a valid command")
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['enable']:
|
||||
|
||||
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.")
|
||||
return
|
||||
|
||||
if trigger.is_privmsg:
|
||||
bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick)
|
||||
return
|
||||
|
||||
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)
|
||||
return
|
||||
|
||||
commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender)
|
||||
bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['disable']:
|
||||
|
||||
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.")
|
||||
return
|
||||
|
||||
if trigger.is_privmsg:
|
||||
bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick)
|
||||
return
|
||||
|
||||
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)
|
||||
return
|
||||
|
||||
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
||||
timestamp = str(datetime.datetime.utcnow())
|
||||
|
||||
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))
|
||||
return
|
||||
def trigger_hyphen_arg_handler(self, bot, trigger):
|
||||
|
||||
# Commands that cannot run via privmsg
|
||||
if trigger.sb["hyphen_arg"] in ['check']:
|
||||
if trigger.sb["com"].lower() != trigger.sb["realcom"]:
|
||||
bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"])
|
||||
else:
|
||||
bot.say(trigger.sb["com"] + " is a valid command")
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['enable']:
|
||||
|
||||
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.")
|
||||
return
|
||||
|
||||
if trigger.is_privmsg:
|
||||
bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick)
|
||||
return
|
||||
|
||||
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)
|
||||
return
|
||||
|
||||
commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender)
|
||||
bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['disable']:
|
||||
|
||||
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.")
|
||||
return
|
||||
|
||||
if trigger.is_privmsg:
|
||||
bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick)
|
||||
return
|
||||
|
||||
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)
|
||||
return
|
||||
|
||||
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
||||
timestamp = str(datetime.datetime.utcnow())
|
||||
|
||||
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))
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
|
||||
prerun = BotPrerun()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user