This commit is contained in:
deathbybandaid 2019-09-19 11:49:26 -04:00
parent f7f7d51cac
commit 355145d33d
2 changed files with 35 additions and 38 deletions

View File

@ -104,12 +104,13 @@ def prerun(t_command_type='module', t_command_subtype=None):
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"])
# special handling
botcom = special_handling(botcom)
args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom)
if args_pass: if args_pass:
# special handling
botcom = special_handling(botcom)
if trigger_runstatus(bot, trigger, botcom): if trigger_runstatus(bot, trigger, botcom):
function(bot, trigger, botcom, *args, **kwargs) function(bot, trigger, botcom, *args, **kwargs)
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
@ -118,20 +119,6 @@ def prerun(t_command_type='module', t_command_subtype=None):
return actual_decorator return actual_decorator
def special_handling(botcom):
botcom.dict["responsekey"] = "?default"
# handling for special cases
posscom = spicemanip(botcom.dict['args'], 1)
if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]:
for command in botcom.dict["dict"]["nonstockoptions"]:
if command.lower() == posscom.lower():
posscom = command
botcom.dict["responsekey"] = posscom
return botcom
def prerun_query(t_command_type='module', t_command_subtype=None): def prerun_query(t_command_type='module', t_command_subtype=None):
def actual_decorator(function): def actual_decorator(function):
@ -447,6 +434,25 @@ def trigger_cant_run(bot, trigger, botcom, message=None):
return False return False
def special_handling(botcom):
botcom.dict["responsekey"] = "?default"
if str(botcom.dict["hyphen_arg"]).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]:
botcom.dict["responsekey"] = str(botcom.dict["hyphen_arg"]).lower()
else:
# handling for special cases
posscom = spicemanip(botcom.dict['args'], 1)
if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]:
for command in botcom.dict["dict"]["nonstockoptions"]:
if command.lower() == posscom.lower():
posscom = command
botcom.dict["responsekey"] = posscom
return botcom
def trigger_hyphen_args(trigger_args_part): def trigger_hyphen_args(trigger_args_part):
hyphen_args = [] hyphen_args = []
@ -472,7 +478,7 @@ def trigger_hyphen_args(trigger_args_part):
clipped_word = w2n.word_to_num(str(clipped_word)) clipped_word = w2n.word_to_num(str(clipped_word))
hyphen_args.append(int(clipped_word)) hyphen_args.append(int(clipped_word))
# word is not a valid arg or number # word is not a valid arg or number
except ValueError: except ValueError:
trigger_args_unhyphend.append(worditem) trigger_args_unhyphend.append(worditem)
else: else:

View File

@ -11,7 +11,6 @@ import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.spicemanip import spicemanip from sopel_modules.spicemanip import spicemanip
from word2number import w2n
from random import randint from random import randint
import time import time
@ -35,25 +34,17 @@ def bot_dictcom_process(bot, trigger, botcom):
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
# This allows users to specify which reply by number by using an ! and a digit (first or last in string) # This allows users to specify which reply by number by using an ! and a digit (first or last in string)
validspecifides = ['last', 'random', 'add', 'del', 'remove'] if botcom.dict["hyphen_arg"]:
botcom.dict["specified"] = None botcom.dict["specified"] = botcom.dict["hyphen_arg"]
argone = spicemanip(botcom.dict['args'], 1) else:
if str(argone).startswith("--") and len(str(argone)) > 2: validspecifides = ['last', 'random', 'add', 'del', 'remove']
if str(argone[2:]).isdigit(): botcom.dict["specified"] = None
botcom.dict["specified"] = int(argone[2:]) argone = spicemanip(botcom.dict['args'], 1)
elif SpiceBot.inlist(str(argone[2:]), validspecifides): if str(argone).startswith("--") and len(str(argone)) > 2:
botcom.dict["specified"] = str(argone[2:]).lower() if SpiceBot.inlist(str(argone[2:]), validspecifides):
elif SpiceBot.inlist(str(argone[2:]), botcom.dict["dict"]["nonstockoptions"]): botcom.dict["specified"] = str(argone[2:]).lower()
botcom.dict["specified"] = str(argone[2:]).lower() if botcom.dict["specified"]:
botcom.dict["responsekey"] = botcom.dict["specified"] botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
else:
try:
botcom.dict["specified"] = w2n.word_to_num(str(argone[1:]))
botcom.dict["specified"] = int(botcom.dict["specified"])
except ValueError:
botcom.dict["specified"] = None
if botcom.dict["specified"]:
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
# commands that can be updated # commands that can be updated
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: