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 = []

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,23 +34,15 @@ 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)
if botcom.dict["hyphen_arg"]:
botcom.dict["specified"] = botcom.dict["hyphen_arg"]
else:
validspecifides = ['last', 'random', 'add', 'del', 'remove'] validspecifides = ['last', 'random', 'add', 'del', 'remove']
botcom.dict["specified"] = None botcom.dict["specified"] = None
argone = spicemanip(botcom.dict['args'], 1) argone = spicemanip(botcom.dict['args'], 1)
if str(argone).startswith("--") and len(str(argone)) > 2: if str(argone).startswith("--") and len(str(argone)) > 2:
if str(argone[2:]).isdigit(): if SpiceBot.inlist(str(argone[2:]), validspecifides):
botcom.dict["specified"] = int(argone[2:])
elif SpiceBot.inlist(str(argone[2:]), validspecifides):
botcom.dict["specified"] = str(argone[2:]).lower() botcom.dict["specified"] = str(argone[2:]).lower()
elif SpiceBot.inlist(str(argone[2:]), botcom.dict["dict"]["nonstockoptions"]):
botcom.dict["specified"] = str(argone[2:]).lower()
botcom.dict["responsekey"] = botcom.dict["specified"]
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"]: if botcom.dict["specified"]:
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')