mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
, botcom
This commit is contained in:
parent
c92420bb5d
commit
03aefc7c50
@ -87,7 +87,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
||||
# split into && groupings
|
||||
and_split = trigger_and_split(trigger_args)
|
||||
|
||||
# Create dict listings for trigger.sb
|
||||
# Create dict listings for botcom.dict
|
||||
argsdict_list = trigger_argsdict_list(argsdict_default, and_split)
|
||||
|
||||
# Run the function for all splits
|
||||
@ -95,12 +95,12 @@ def prerun(t_command_type='module', t_command_subtype=None):
|
||||
runcount = 0
|
||||
for argsdict in argsdict_list:
|
||||
runcount += 1
|
||||
trigger.sb = copy.deepcopy(argsdict)
|
||||
botcom.dict = copy.deepcopy(argsdict)
|
||||
|
||||
trigger.sb["runcount"] = runcount
|
||||
botcom.dict["runcount"] = runcount
|
||||
|
||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = trigger_hyphen_args(trigger.sb["args"])
|
||||
if not trigger.sb["hyphen_arg"]:
|
||||
botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"])
|
||||
if not botcom.dict["hyphen_arg"]:
|
||||
# check if anything prohibits the nick from running the command
|
||||
if trigger_runstatus(bot, trigger):
|
||||
function(bot, trigger, botcom, *args, **kwargs)
|
||||
@ -165,15 +165,15 @@ def prerun_query(t_command_type='module', t_command_subtype=None):
|
||||
|
||||
argsdict_default["dict"] = botcommands.get_command_dict("query", 'nickname')
|
||||
|
||||
# Create dict listings for trigger.sb
|
||||
# Create dict listings for botcom.dict
|
||||
argsdict = trigger_argsdict_single(argsdict_default, trigger_args)
|
||||
|
||||
# Run the function for all splits
|
||||
botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"], argsdict_default["realcomtext"])
|
||||
|
||||
trigger.sb = copy.deepcopy(argsdict)
|
||||
botcom.dict = copy.deepcopy(argsdict)
|
||||
|
||||
trigger.sb["runcount"] = 1
|
||||
botcom.dict["runcount"] = 1
|
||||
|
||||
# check if anything prohibits the nick from running the command
|
||||
if trigger_runstatus_query(bot, trigger):
|
||||
@ -267,11 +267,11 @@ def trigger_runstatus_query(bot, trigger):
|
||||
return False
|
||||
|
||||
# Allow permissions for enabling and disabling commands via hyphenargs
|
||||
if trigger.sb["adminswitch"]:
|
||||
if botcom.dict["adminswitch"]:
|
||||
if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
return True
|
||||
else:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.")
|
||||
return False
|
||||
|
||||
# don't run commands that are disabled in channels
|
||||
@ -288,25 +288,25 @@ def trigger_runstatus_query(bot, trigger):
|
||||
# don't run commands that are disabled in channels
|
||||
if not trigger.is_privmsg:
|
||||
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender))
|
||||
if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
if botcom.dict["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
|
||||
# don't run commands that are disabled for specific users
|
||||
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick))
|
||||
if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
if botcom.dict["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
if botusers.ID(bywhom) != botusers.ID(trigger.nick):
|
||||
reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
reason = nick_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
else:
|
||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick)
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
|
||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], trigger.nick)
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(trigger.nick))
|
||||
|
||||
return True
|
||||
|
||||
@ -318,75 +318,75 @@ def trigger_runstatus(bot, trigger):
|
||||
return False
|
||||
|
||||
# Allow permissions for enabling and disabling commands via hyphenargs
|
||||
if trigger.sb["adminswitch"]:
|
||||
if botcom.dict["adminswitch"]:
|
||||
if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
return True
|
||||
else:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.")
|
||||
return False
|
||||
|
||||
if trigger.sb["hyphen_arg"]:
|
||||
if botcom.dict["hyphen_arg"]:
|
||||
return False
|
||||
|
||||
if not trigger.is_privmsg:
|
||||
if str(trigger.sender).lower() in [x.lower() for x in trigger.sb["dict"]["hardcoded_channel_block"]]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "The " + str(trigger.sb["comtext"]) + " command cannot be used in " + str(trigger.sender) + " because it is hardcoded not to.")
|
||||
if str(trigger.sender).lower() in [x.lower() for x in botcom.dict["dict"]["hardcoded_channel_block"]]:
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " command cannot be used in " + str(trigger.sender) + " because it is hardcoded not to.")
|
||||
|
||||
if trigger.sb["runcount"] > 1:
|
||||
if botcom.dict["runcount"] > 1:
|
||||
# check channel multirun blocks
|
||||
if not trigger.is_privmsg:
|
||||
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "multirun")
|
||||
if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command multirun usage was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
if botcom.dict["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command multirun usage was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
|
||||
# don't run commands that are disabled for specific users
|
||||
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "multirun")
|
||||
if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
if botcom.dict["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
if botusers.ID(bywhom) != botusers.ID(trigger.nick):
|
||||
reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command was multirun unsage disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
reason = nick_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command was multirun unsage disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
else:
|
||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "multirun")
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now enabled for " + str(trigger.nick))
|
||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], trigger.nick, "multirun")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now enabled for " + str(trigger.nick))
|
||||
|
||||
# don't run commands that are disabled in channels
|
||||
if not trigger.is_privmsg:
|
||||
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender))
|
||||
if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
if botcom.dict["realcomref"] in list(channel_disabled_list.keys()):
|
||||
reason = channel_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = channel_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
bywhom = channel_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
|
||||
# don't run commands that are disabled for specific users
|
||||
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick))
|
||||
if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
|
||||
if botcom.dict["realcomref"] in list(nick_disabled_list.keys()):
|
||||
bywhom = nick_disabled_list[botcom.dict["realcomref"]]["disabledby"]
|
||||
if botusers.ID(bywhom) != botusers.ID(trigger.nick):
|
||||
reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
|
||||
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
reason = nick_disabled_list[botcom.dict["realcomref"]]["reason"]
|
||||
timestamp = nick_disabled_list[botcom.dict["realcomref"]]["timestamp"]
|
||||
message = "The " + str(botcom.dict["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
|
||||
return trigger_cant_run(bot, trigger, message)
|
||||
else:
|
||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick)
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
|
||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], trigger.nick)
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(trigger.nick))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def trigger_cant_run(bot, trigger, message=None):
|
||||
if message:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], message)
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], message)
|
||||
if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "You however are authorized to bypass this warning with the (-a) admin switch.")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "You however are authorized to bypass this warning with the (-a) admin switch.")
|
||||
return False
|
||||
|
||||
|
||||
@ -423,137 +423,137 @@ def trigger_hyphen_arg_handler(bot, trigger):
|
||||
|
||||
# Commands that cannot run via privmsg
|
||||
# TODO --check should work for commands that don't exist
|
||||
if trigger.sb["hyphen_arg"] in ['check']:
|
||||
if trigger.sb["com"].lower() != trigger.sb["realcom"]:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is a valid alias command for " + trigger.sb["realcomtext"])
|
||||
if botcom.dict["hyphen_arg"] in ['check']:
|
||||
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"])
|
||||
else:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is a valid command")
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid command")
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in [
|
||||
elif botcom.dict["hyphen_arg"] in [
|
||||
'enable', 'disable',
|
||||
'block', 'unblock',
|
||||
"activate", "deactivate",
|
||||
"on", "off"
|
||||
]:
|
||||
|
||||
target = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
|
||||
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
||||
if not target:
|
||||
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I enabling " + str(trigger.sb["comtext"]) + " usage for?")
|
||||
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " usage for?")
|
||||
else:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " usage for?")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " usage for?")
|
||||
return
|
||||
trigger.sb["args"] = spicemanip.main(trigger.sb["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):
|
||||
botmessagelog.messagelog_error(trigger.sb["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
|
||||
|
||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
if target != trigger.nick:
|
||||
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.")
|
||||
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.")
|
||||
else:
|
||||
botmessagelog.messagelog_error(trigger.sb["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
|
||||
|
||||
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
|
||||
|
||||
if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target):
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already enabled for " + str(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))
|
||||
return
|
||||
|
||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], target)
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(target))
|
||||
botcommands.unset_command_disabled(botcom.dict["realcomref"], target)
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(target))
|
||||
return
|
||||
|
||||
else:
|
||||
|
||||
if botcommands.check_commands_disabled(trigger.sb["realcomref"], target):
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already disabled for " + str(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))
|
||||
return
|
||||
|
||||
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
||||
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
||||
timestamp = str(datetime.datetime.utcnow())
|
||||
|
||||
botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick)
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now disabled for " + str(target))
|
||||
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))
|
||||
return
|
||||
|
||||
if trigger.sb["hyphen_arg"] in ['multirun', 'multiruns']:
|
||||
if botcom.dict["hyphen_arg"] in ['multirun', 'multiruns']:
|
||||
|
||||
onoff = spicemanip.main(trigger.sb["args"], 1) or None
|
||||
onoff = spicemanip.main(botcom.dict["args"], 1) or None
|
||||
if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "Do you want to enable or disable " + str(trigger.sb["comtext"]) + " multirun usage?")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Do you want to enable or disable " + str(botcom.dict["comtext"]) + " multirun usage?")
|
||||
return
|
||||
|
||||
target = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
|
||||
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
||||
if not target:
|
||||
if onoff in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I enabling " + str(trigger.sb["comtext"]) + " multirun usage for?")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
||||
else:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " multirun usage for?")
|
||||
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
|
||||
return
|
||||
trigger.sb["args"] = spicemanip.main(trigger.sb["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):
|
||||
botmessagelog.messagelog_error(trigger.sb["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
|
||||
|
||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
if target != trigger.nick:
|
||||
if onoff in ['enable', 'unblock', "activate", "on"]:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable multirun usage on " + str(trigger.sb["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:
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable multirun usage on " + str(trigger.sb["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
|
||||
|
||||
if onoff in ['enable', 'unblock', "activate", "on"]:
|
||||
|
||||
if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "multirun"):
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is already enabled for " + str(target))
|
||||
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))
|
||||
return
|
||||
|
||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], target, "multirun")
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now enabled for " + str(target))
|
||||
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))
|
||||
return
|
||||
|
||||
else:
|
||||
|
||||
if botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "multirun"):
|
||||
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is already disabled for " + str(target))
|
||||
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))
|
||||
return
|
||||
|
||||
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
|
||||
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
|
||||
timestamp = str(datetime.datetime.utcnow())
|
||||
|
||||
botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick, "multirun")
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now disabled for " + str(target))
|
||||
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))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['example', 'usage']:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + ": " + str(trigger.sb["dict"]["example"]))
|
||||
elif botcom.dict["hyphen_arg"] in ['example', 'usage']:
|
||||
botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + ": " + str(botcom.dict["dict"]["example"]))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['filename', 'filepath']:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], "The " + str(trigger.sb["comtext"]) + " file is located at " + str(trigger.sb["dict"][trigger.sb["hyphen_arg"]]))
|
||||
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"]]))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['foldername', 'folderpath']:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], "The " + str(trigger.sb["comtext"]) + " folder is located at " + str(trigger.sb["dict"][trigger.sb["hyphen_arg"]]))
|
||||
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"]]))
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['author']:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], "The author of the " + str(trigger.sb["comtext"]) + " command is " + trigger.sb["dict"]["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"] + ".")
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['contribs', 'contrib', "contributors"]:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], "The contributors of the " + str(trigger.sb["comtext"]) + " command are " + spicemanip.main(trigger.sb["dict"]["contributors"], "andlist") + ".")
|
||||
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") + ".")
|
||||
return
|
||||
|
||||
elif trigger.sb["hyphen_arg"] in ['alias', 'aliases']:
|
||||
botmessagelog.messagelog(trigger.sb["log_id"], "The alaises of the " + str(trigger.sb["comtext"]) + " command are " + spicemanip.main(trigger.sb["dict"]["validcoms"], "andlist") + ".")
|
||||
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") + ".")
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
@ -12,19 +12,19 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@SpiceBot.prerun('nickname')
|
||||
@sopel.module.nickname_commands('owners', 'owner')
|
||||
def bot_command_owners(bot, trigger, botcom):
|
||||
bot_command_process(bot, trigger)
|
||||
bot_command_process(bot, trigger, botcom)
|
||||
|
||||
|
||||
@SpiceBot.prerun('nickname')
|
||||
@sopel.module.nickname_commands('admins', 'admin')
|
||||
def bot_command_admins(bot, trigger, botcom):
|
||||
bot_command_process(bot, trigger)
|
||||
bot_command_process(bot, trigger, botcom)
|
||||
|
||||
|
||||
def bot_command_process(bot, trigger):
|
||||
def bot_command_process(bot, trigger, botcom):
|
||||
|
||||
if not trigger.sb['com'].endswith("s"):
|
||||
trigger.sb['com'] = str(trigger.sb['com'] + "s")
|
||||
if not botcom.dict['com'].endswith("s"):
|
||||
botcom.dict['com'] = str(botcom.dict['com'] + "s")
|
||||
|
||||
privlist = spicemanip.main(SpiceBot.bot_privs(trigger.sb['com']), 'andlist')
|
||||
bot.osd(str(bot.nick) + " " + trigger.sb['com'] + ": " + privlist)
|
||||
privlist = spicemanip.main(SpiceBot.bot_privs(botcom.dict['com']), 'andlist')
|
||||
bot.osd(str(bot.nick) + " " + botcom.dict['com'] + ": " + privlist)
|
||||
|
||||
@ -14,12 +14,12 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@sopel.module.nickname_commands('channels', 'channel')
|
||||
def nickname_comand_channels(bot, trigger, botcom):
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
if not len(botcom.dict['args']):
|
||||
commandused = 'list'
|
||||
else:
|
||||
commandused = spicemanip.main(trigger.sb['args'], 1).lower()
|
||||
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
|
||||
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
if commandused == 'list':
|
||||
botcount = len(list(bot.channels.keys()))
|
||||
@ -48,7 +48,7 @@ def nickname_comand_channels(bot, trigger, botcom):
|
||||
|
||||
elif commandused == 'update':
|
||||
if not trigger.admin:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "You do not have permission to update the channel listing.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "You do not have permission to update the channel listing.")
|
||||
return
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
SpiceBot.channels.channel_list_request(bot)
|
||||
@ -62,12 +62,12 @@ def nickname_comand_channels(bot, trigger, botcom):
|
||||
return
|
||||
|
||||
elif commandused == 'topic':
|
||||
if not len(trigger.sb['args']):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel name input missing.")
|
||||
if not len(botcom.dict['args']):
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name input missing.")
|
||||
return
|
||||
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||
channel = spicemanip.main(botcom.dict['args'], 1)
|
||||
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel name {} not valid.".format(channel))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
|
||||
return
|
||||
topic = SpiceBot.channels.dict['list'][channel.lower()]['topic']
|
||||
channel = SpiceBot.channels.dict['list'][channel.lower()]['name']
|
||||
@ -75,19 +75,19 @@ def nickname_comand_channels(bot, trigger, botcom):
|
||||
return
|
||||
|
||||
if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']:
|
||||
if not len(trigger.sb['args']):
|
||||
if not len(botcom.dict['args']):
|
||||
if trigger.is_privmsg:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel name required.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name required.")
|
||||
return
|
||||
else:
|
||||
channel = trigger.sender
|
||||
else:
|
||||
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||
channel = spicemanip.main(botcom.dict['args'], 1)
|
||||
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel name {} not valid.".format(channel))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
|
||||
return
|
||||
if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "I need to be in {} to see nick privileges.".format(channel))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I need to be in {} to see nick privileges.".format(channel))
|
||||
return
|
||||
|
||||
privlist = SpiceBot.channel_privs(bot, channel, commandused.upper())
|
||||
@ -102,12 +102,12 @@ def nickname_comand_channels(bot, trigger, botcom):
|
||||
|
||||
# Users List
|
||||
if commandused == 'users':
|
||||
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||
channel = spicemanip.main(botcom.dict['args'], 1)
|
||||
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel name {} not valid.".format(channel))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
|
||||
return
|
||||
if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "I need to be in {} to see user list.".format(channel))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I need to be in {} to see user list.".format(channel))
|
||||
return
|
||||
dispmsg = []
|
||||
if not len(list(bot.channels[channel].privileges.keys())):
|
||||
|
||||
@ -18,10 +18,10 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@sopel.module.nickname_commands('commands', 'command')
|
||||
def nickname_comand_commands(bot, trigger, botcom):
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
if not len(botcom.dict['args']):
|
||||
commandused = 'list'
|
||||
else:
|
||||
commandused = spicemanip.main(trigger.sb['args'], 1).lower()
|
||||
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
|
||||
|
||||
if commandused == 'list':
|
||||
availablecomsnum, availablecomsfiles = 0, []
|
||||
|
||||
@ -23,14 +23,14 @@ def query_trigger(bot, trigger, botcom):
|
||||
def query_detection_nick(bot, trigger, botcom):
|
||||
|
||||
# command issued, check if valid
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
if not trigger.sb['com'][0] == bot.config.SpiceBot_Commands.query_prefix:
|
||||
if not botcom.dict['com'][0] == bot.config.SpiceBot_Commands.query_prefix:
|
||||
return
|
||||
trigger.sb['com'] = trigger.sb['com'][1:]
|
||||
botcom.dict['com'] = botcom.dict['com'][1:]
|
||||
|
||||
if not SpiceBot.letters_in_string(trigger.sb['com']):
|
||||
if not SpiceBot.letters_in_string(botcom.dict['com']):
|
||||
return
|
||||
|
||||
commands_list = dict()
|
||||
@ -38,49 +38,49 @@ def query_detection_nick(bot, trigger, botcom):
|
||||
if com not in list(commands_list.keys()):
|
||||
commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com]
|
||||
|
||||
if trigger.sb['com'].endswith("+"):
|
||||
if botcom.dict['com'].endswith("+"):
|
||||
|
||||
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
botcom.dict['com'] = botcom.dict['com'][:-1]
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
if trigger.sb['com'].lower() not in list(commands_list.keys()):
|
||||
dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(trigger.sb['com']) + "."]
|
||||
closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if botcom.dict['com'].lower() not in list(commands_list.keys()):
|
||||
dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(botcom.dict['com']) + "."]
|
||||
closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if len(closestmatches):
|
||||
dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||
dispmsg.append("The following " + bot.nick + " commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||
bot.osd(dispmsg, trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
realcom = trigger.sb['com']
|
||||
if "aliasfor" in list(commands_list[trigger.sb['com']].keys()):
|
||||
realcom = commands_list[trigger.sb['com']]["aliasfor"]
|
||||
realcom = botcom.dict['com']
|
||||
if "aliasfor" in list(commands_list[botcom.dict['com']].keys()):
|
||||
realcom = commands_list[botcom.dict['com']]["aliasfor"]
|
||||
validcomlist = commands_list[realcom]["validcoms"]
|
||||
bot.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following " + bot.nick + " commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
if trigger.sb['com'].endswith(bot.config.SpiceBot_Commands.query_prefix):
|
||||
if botcom.dict['com'].endswith(bot.config.SpiceBot_Commands.query_prefix):
|
||||
|
||||
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
botcom.dict['com'] = botcom.dict['com'][:-1]
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if not len(closestmatches):
|
||||
bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice')
|
||||
bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
|
||||
else:
|
||||
bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following " + bot.nick + " commands may match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
commandlist = []
|
||||
for command in list(commands_list.keys()):
|
||||
if command.lower().startswith(str(trigger.sb['com']).lower()):
|
||||
if command.lower().startswith(str(botcom.dict['com']).lower()):
|
||||
commandlist.append(command)
|
||||
|
||||
if not len(commandlist):
|
||||
bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice')
|
||||
bot.osd("No " + bot.nick + " commands start with " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
|
||||
else:
|
||||
bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following " + bot.nick + " commands start with " + str(botcom.dict['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
|
||||
|
||||
@SpiceBot.prerun_query('module', 'module')
|
||||
@ -88,10 +88,10 @@ def query_detection_nick(bot, trigger, botcom):
|
||||
def query_detection(bot, trigger, botcom):
|
||||
|
||||
# command issued, check if valid
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
if not SpiceBot.letters_in_string(trigger.sb['com']):
|
||||
if not SpiceBot.letters_in_string(botcom.dict['com']):
|
||||
return
|
||||
|
||||
commands_list = dict()
|
||||
@ -101,46 +101,46 @@ def query_detection(bot, trigger, botcom):
|
||||
if com not in list(commands_list.keys()):
|
||||
commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com]
|
||||
|
||||
if trigger.sb['com'][:-1] == "+":
|
||||
if botcom.dict['com'][:-1] == "+":
|
||||
|
||||
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
botcom.dict['com'] = botcom.dict['com'][:-1]
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
if trigger.sb['com'].lower() not in list(commands_list.keys()):
|
||||
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(trigger.sb['com']) + "."]
|
||||
closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if botcom.dict['com'].lower() not in list(commands_list.keys()):
|
||||
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(botcom.dict['com']) + "."]
|
||||
closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if len(closestmatches):
|
||||
dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||
dispmsg.append("The following commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||
bot.osd(dispmsg, trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
realcom = trigger.sb['com']
|
||||
if "aliasfor" in list(commands_list[trigger.sb['com']].keys()):
|
||||
realcom = commands_list[trigger.sb['com']]["aliasfor"]
|
||||
realcom = botcom.dict['com']
|
||||
if "aliasfor" in list(commands_list[botcom.dict['com']].keys()):
|
||||
realcom = commands_list[botcom.dict['com']]["aliasfor"]
|
||||
validcomlist = commands_list[realcom]["validcoms"]
|
||||
bot.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
if trigger.sb['com'][:-1] == "?":
|
||||
if botcom.dict['com'][:-1] == "?":
|
||||
|
||||
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||
botcom.dict['com'] = botcom.dict['com'][:-1]
|
||||
if not botcom.dict['com'] or not len(botcom.dict['com']):
|
||||
return
|
||||
|
||||
closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse')
|
||||
if not len(closestmatches):
|
||||
bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice')
|
||||
bot.osd("Cannot find any similar commands for " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
|
||||
else:
|
||||
bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following commands may match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
return
|
||||
|
||||
commandlist = []
|
||||
for command in list(commands_list.keys()):
|
||||
if command.lower().startswith(str(trigger.sb['com']).lower()):
|
||||
if command.lower().startswith(str(botcom.dict['com']).lower()):
|
||||
commandlist.append(command)
|
||||
|
||||
if not len(commandlist):
|
||||
bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice')
|
||||
bot.osd("No commands start with " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
|
||||
else:
|
||||
bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
bot.osd("The following commands start with " + str(botcom.dict['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||
|
||||
@ -20,78 +20,78 @@ import time
|
||||
@sopel.module.commands('(.*)')
|
||||
def command_dictcom(bot, trigger, botcom):
|
||||
|
||||
if trigger.sb['com'] not in list(SpiceBot.commands.dict['commands']["dictcom"].keys()):
|
||||
if botcom.dict['com'] not in list(SpiceBot.commands.dict['commands']["dictcom"].keys()):
|
||||
return
|
||||
|
||||
bot_dictcom_process(bot, trigger)
|
||||
bot_dictcom_process(bot, trigger, botcom)
|
||||
return
|
||||
time.time()
|
||||
|
||||
|
||||
def bot_dictcom_process(bot, trigger):
|
||||
def bot_dictcom_process(bot, trigger, botcom):
|
||||
|
||||
# use the default key, unless otherwise specified
|
||||
trigger.sb["responsekey"] = "?default"
|
||||
botcom.dict["responsekey"] = "?default"
|
||||
|
||||
# handling for special cases
|
||||
posscom = spicemanip.main(trigger.sb['args'], 1)
|
||||
if posscom.lower() in [command.lower() for command in trigger.sb["dict"].keys()]:
|
||||
for command in trigger.sb["dict"].keys():
|
||||
posscom = spicemanip.main(botcom.dict['args'], 1)
|
||||
if posscom.lower() in [command.lower() for command in botcom.dict["dict"].keys()]:
|
||||
for command in botcom.dict["dict"].keys():
|
||||
if command.lower() == posscom.lower():
|
||||
posscom = command
|
||||
trigger.sb["responsekey"] = posscom
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["type"] = trigger.sb["dict"][trigger.sb["responsekey"]]["type"]
|
||||
botcom.dict["responsekey"] = posscom
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"]
|
||||
|
||||
trigger.sb["nonstockoptions"] = []
|
||||
for command in trigger.sb["dict"].keys():
|
||||
botcom.dict["nonstockoptions"] = []
|
||||
for command in botcom.dict["dict"].keys():
|
||||
if command not in ["?default", "validcoms", "type", "hardcoded_channel_block"]:
|
||||
trigger.sb["nonstockoptions"].append(command)
|
||||
botcom.dict["nonstockoptions"].append(command)
|
||||
|
||||
# This allows users to specify which reply by number by using an ! and a digit (first or last in string)
|
||||
validspecifides = ['last', 'random', 'count', 'view', 'add', 'del', 'remove', 'special']
|
||||
trigger.sb["specified"] = None
|
||||
argone = spicemanip.main(trigger.sb['args'], 1)
|
||||
botcom.dict["specified"] = None
|
||||
argone = spicemanip.main(botcom.dict['args'], 1)
|
||||
if str(argone).startswith("--") and len(str(argone)) > 2:
|
||||
if str(argone[2:]).isdigit():
|
||||
trigger.sb["specified"] = int(argone[2:])
|
||||
botcom.dict["specified"] = int(argone[2:])
|
||||
elif SpiceBot.inlist(str(argone[2:]), validspecifides):
|
||||
trigger.sb["specified"] = str(argone[2:]).lower()
|
||||
elif SpiceBot.inlist(str(argone[2:]), trigger.sb["nonstockoptions"]):
|
||||
trigger.sb["specified"] = str(argone[2:]).lower()
|
||||
trigger.sb["responsekey"] = trigger.sb["specified"]
|
||||
botcom.dict["specified"] = str(argone[2:]).lower()
|
||||
elif SpiceBot.inlist(str(argone[2:]), botcom.dict["nonstockoptions"]):
|
||||
botcom.dict["specified"] = str(argone[2:]).lower()
|
||||
botcom.dict["responsekey"] = botcom.dict["specified"]
|
||||
else:
|
||||
try:
|
||||
trigger.sb["specified"] = w2n.word_to_num(str(argone[1:]))
|
||||
trigger.sb["specified"] = int(trigger.sb["specified"])
|
||||
botcom.dict["specified"] = w2n.word_to_num(str(argone[1:]))
|
||||
botcom.dict["specified"] = int(botcom.dict["specified"])
|
||||
except ValueError:
|
||||
trigger.sb["specified"] = None
|
||||
if trigger.sb["specified"]:
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
botcom.dict["specified"] = None
|
||||
if botcom.dict["specified"]:
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
# commands that can be updated
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"]:
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(SpiceBot.config.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), trigger.sb["dict"][trigger.sb["responsekey"]]["responses"], 'startup')
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(bot.nick), trigger.sb["dict"]["validcoms"][0] + "_" + str(trigger.sb["responsekey"]), 'sayings') or []
|
||||
elif trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), trigger.sb["dict"][trigger.sb["responsekey"]]["responses"], 'startup')
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), trigger.sb["dict"]["validcoms"][0] + "_" + str(trigger.sb["responsekey"]), 'sayings') or []
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(SpiceBot.config.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup')
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or []
|
||||
elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup')
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or []
|
||||
|
||||
if trigger.sb["specified"] == 'special':
|
||||
nonstockoptions = spicemanip.main(trigger.sb["nonstockoptions"], "andlist")
|
||||
return bot.osd("The special options for " + str(trigger.sb["realcom"]) + " command include: " + str(nonstockoptions) + ".")
|
||||
if botcom.dict["specified"] == 'special':
|
||||
nonstockoptions = spicemanip.main(botcom.dict["nonstockoptions"], "andlist")
|
||||
return bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(nonstockoptions) + ".")
|
||||
|
||||
elif trigger.sb["specified"] == 'count':
|
||||
return bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " command has " + str(len(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"])) + " entries.")
|
||||
elif botcom.dict["specified"] == 'count':
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.")
|
||||
|
||||
elif trigger.sb["specified"] == 'view':
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] == []:
|
||||
return bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " command appears to have no entries!")
|
||||
elif botcom.dict["specified"] == 'view':
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] == []:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command appears to have no entries!")
|
||||
else:
|
||||
bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " command contains:", trigger.nick, 'notice')
|
||||
bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:", trigger.nick, 'notice')
|
||||
listnumb, relist = 1, []
|
||||
for item in trigger.sb["dict"][trigger.sb["responsekey"]]["responses"]:
|
||||
for item in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]:
|
||||
if isinstance(item, dict):
|
||||
relist.append(str("[#" + str(listnumb) + "] COMPLEX dict Entry"))
|
||||
elif isinstance(item, list):
|
||||
@ -101,143 +101,143 @@ def bot_dictcom_process(bot, trigger):
|
||||
bot.osd(relist, trigger.nick)
|
||||
return
|
||||
|
||||
elif trigger.sb["specified"] == 'add':
|
||||
elif botcom.dict["specified"] == 'add':
|
||||
|
||||
if not trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list cannot be updated.")
|
||||
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
|
||||
|
||||
fulltext = spicemanip.main(trigger.sb['args'], 0)
|
||||
fulltext = spicemanip.main(botcom.dict['args'], 0)
|
||||
if not fulltext:
|
||||
return bot.osd("What would you like to add to the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list?")
|
||||
return bot.osd("What would you like to add to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
|
||||
|
||||
if fulltext in trigger.sb["dict"][trigger.sb["responsekey"]]["responses"]:
|
||||
return bot.osd("The following was already in the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]:
|
||||
return bot.osd("The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), fulltext, trigger.sb["specified"])
|
||||
elif trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), fulltext, trigger.sb["specified"])
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"])
|
||||
elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"])
|
||||
|
||||
return bot.osd("The following was added to the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
return bot.osd("The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
|
||||
elif trigger.sb["specified"] in ['del', 'remove']:
|
||||
elif botcom.dict["specified"] in ['del', 'remove']:
|
||||
|
||||
if not trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list cannot be updated.")
|
||||
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
|
||||
|
||||
fulltext = spicemanip.main(trigger.sb['args'], 0)
|
||||
fulltext = spicemanip.main(botcom.dict['args'], 0)
|
||||
if not fulltext:
|
||||
return bot.osd("What would you like to remove from the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list?")
|
||||
return bot.osd("What would you like to remove from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
|
||||
|
||||
if fulltext not in trigger.sb["dict"][trigger.sb["responsekey"]]["responses"]:
|
||||
return bot.osd("The following was already not in the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
if fulltext not in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]:
|
||||
return bot.osd("The following was already not in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), fulltext, trigger.sb["specified"])
|
||||
elif trigger.sb["dict"][trigger.sb["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', trigger.sb["realcom"] + "_" + str(trigger.sb["responsekey"]), fulltext, trigger.sb["specified"])
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"])
|
||||
elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user":
|
||||
SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"])
|
||||
|
||||
return bot.osd("The following was removed from the " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
return bot.osd("The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'")
|
||||
|
||||
elif trigger.sb["specified"] and not trigger.sb["dict"][trigger.sb["responsekey"]]["selection_allowed"]:
|
||||
return bot.osd("The " + str(trigger.sb["realcom"]) + " " + str(trigger.sb["responsekey"] or '') + " response list cannot be specified.")
|
||||
elif botcom.dict["specified"] and not botcom.dict["dict"][botcom.dict["responsekey"]]["selection_allowed"]:
|
||||
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " response list cannot be specified.")
|
||||
|
||||
trigger.sb["target"] = False
|
||||
botcom.dict["target"] = False
|
||||
|
||||
trigger.sb["success"] = True
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]:
|
||||
botcom.dict["success"] = True
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]:
|
||||
return bot_dictcom_responses(bot, trigger)
|
||||
else:
|
||||
command_function_run = str('bot_dictcom_' + trigger.sb["dict"][trigger.sb["responsekey"]]["type"] + '(bot, trigger)')
|
||||
command_function_run = str('bot_dictcom_' + botcom.dict["dict"][botcom.dict["responsekey"]]["type"] + '(bot, trigger, botcom)')
|
||||
eval(command_function_run)
|
||||
|
||||
|
||||
def bot_dictcom_responses(bot, trigger):
|
||||
def bot_dictcom_responses(bot, trigger, botcom):
|
||||
|
||||
commandrunconsensus = []
|
||||
reaction = False
|
||||
|
||||
# A target is required
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["target_required"]:
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["target_required"]:
|
||||
|
||||
# try first term as a target
|
||||
posstarget = spicemanip.main(trigger.sb['args'], 1) or 0
|
||||
targetbypass = trigger.sb["dict"][trigger.sb["responsekey"]]["target_bypass"]
|
||||
posstarget = spicemanip.main(botcom.dict['args'], 1) or 0
|
||||
targetbypass = botcom.dict["dict"][botcom.dict["responsekey"]]["target_bypass"]
|
||||
targetchecking = SpiceBot.users.target_check(bot, trigger, posstarget, targetbypass)
|
||||
if not targetchecking["targetgood"]:
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["target_backup"]:
|
||||
trigger.sb["target"] = trigger.sb["dict"][trigger.sb["responsekey"]]["target_backup"]
|
||||
if trigger.sb["target"] == 'instigator':
|
||||
trigger.sb["target"] = trigger.nick
|
||||
elif trigger.sb["target"] == 'random':
|
||||
trigger.sb["target"] = SpiceBot.users.random_valid_target(bot, trigger, 'random')
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["target_backup"]:
|
||||
botcom.dict["target"] = botcom.dict["dict"][botcom.dict["responsekey"]]["target_backup"]
|
||||
if botcom.dict["target"] == 'instigator':
|
||||
botcom.dict["target"] = trigger.nick
|
||||
elif botcom.dict["target"] == 'random':
|
||||
botcom.dict["target"] = SpiceBot.users.random_valid_target(bot, trigger, 'random')
|
||||
else:
|
||||
for reason in ['self', 'bot', 'bots', 'offline', 'unknown', 'privmsg', 'diffchannel', 'diffbot']:
|
||||
if targetchecking["reason"] == reason and trigger.sb["dict"][trigger.sb["responsekey"]]["react_"+reason]:
|
||||
if targetchecking["reason"] == reason and botcom.dict["dict"][botcom.dict["responsekey"]]["react_"+reason]:
|
||||
reaction = True
|
||||
commandrunconsensus.append(trigger.sb["dict"][trigger.sb["responsekey"]]["react_"+reason])
|
||||
commandrunconsensus.append(botcom.dict["dict"][botcom.dict["responsekey"]]["react_"+reason])
|
||||
if not reaction:
|
||||
commandrunconsensus.append([targetchecking["error"]])
|
||||
else:
|
||||
trigger.sb["target"] = spicemanip.main(trigger.sb['args'], 1)
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
botcom.dict["target"] = spicemanip.main(botcom.dict['args'], 1)
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
# $blank input
|
||||
trigger.sb["completestring"] = spicemanip.main(trigger.sb['args'], 0) or ''
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["blank_required"]:
|
||||
botcom.dict["completestring"] = spicemanip.main(botcom.dict['args'], 0) or ''
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"]:
|
||||
|
||||
if trigger.sb["completestring"] == '' or not trigger.sb["completestring"]:
|
||||
if botcom.dict["completestring"] == '' or not botcom.dict["completestring"]:
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["blank_backup"]:
|
||||
trigger.sb["completestring"] = trigger.sb["dict"][trigger.sb["responsekey"]]["blank_backup"]
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_backup"]:
|
||||
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_backup"]
|
||||
else:
|
||||
commandrunconsensus.append(trigger.sb["dict"][trigger.sb["responsekey"]]["blank_fail"])
|
||||
commandrunconsensus.append(botcom.dict["dict"][botcom.dict["responsekey"]]["blank_fail"])
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"]:
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"] != []:
|
||||
if spicemanip.main(trigger.sb["completestring"], 1).lower() not in trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"]:
|
||||
trigger.sb["completestring"] = trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"][0] + " " + trigger.sb["completestring"]
|
||||
elif spicemanip.main(trigger.sb["completestring"], 1).lower() in trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"]:
|
||||
if spicemanip.main(trigger.sb["completestring"], 1).lower() != trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"][0]:
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
if trigger.sb['args'] != []:
|
||||
trigger.sb["completestring"] = trigger.sb["dict"][trigger.sb["responsekey"]]["blank_phrasehandle"][0] + " " + spicemanip.main(trigger.sb['args'], 0)
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"] != []:
|
||||
if spicemanip.main(botcom.dict["completestring"], 1).lower() not in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
|
||||
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0] + " " + botcom.dict["completestring"]
|
||||
elif spicemanip.main(botcom.dict["completestring"], 1).lower() in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
|
||||
if spicemanip.main(botcom.dict["completestring"], 1).lower() != botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0]:
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
if botcom.dict['args'] != []:
|
||||
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0] + " " + spicemanip.main(botcom.dict['args'], 0)
|
||||
|
||||
if commandrunconsensus != []:
|
||||
trigger.sb["success"] = False
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["response_fail"] and not reaction:
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = trigger.sb["dict"][trigger.sb["responsekey"]]["response_fail"]
|
||||
botcom.dict["success"] = False
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["response_fail"] and not reaction:
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = botcom.dict["dict"][botcom.dict["responsekey"]]["response_fail"]
|
||||
else:
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = commandrunconsensus[0]
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = commandrunconsensus[0]
|
||||
|
||||
bot_dictcom_reply_shared(bot, trigger)
|
||||
bot_dictcom_reply_shared(bot, trigger, botcom)
|
||||
|
||||
|
||||
def bot_dictcom_reply_shared(bot, trigger):
|
||||
def bot_dictcom_reply_shared(bot, trigger, botcom):
|
||||
|
||||
if trigger.sb["specified"]:
|
||||
if trigger.sb["specified"] > len(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"]):
|
||||
currentspecified = len(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"])
|
||||
if botcom.dict["specified"]:
|
||||
if botcom.dict["specified"] > len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]):
|
||||
currentspecified = len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])
|
||||
else:
|
||||
currentspecified = trigger.sb["specified"]
|
||||
trigger.sb["replies"] = spicemanip.main(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"], currentspecified, 'return')
|
||||
trigger.sb["replynum"] = currentspecified
|
||||
currentspecified = botcom.dict["specified"]
|
||||
botcom.dict["replies"] = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], currentspecified, 'return')
|
||||
botcom.dict["replynum"] = currentspecified
|
||||
else:
|
||||
trigger.sb["replies"] = spicemanip.main(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"], 'random', 'return')
|
||||
botcom.dict["replies"] = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'random', 'return')
|
||||
try:
|
||||
trigger.sb["replynum"] = trigger.sb["dict"][trigger.sb["responsekey"]]["responses"].index(trigger.sb["replies"])
|
||||
botcom.dict["replynum"] = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].index(botcom.dict["replies"])
|
||||
except Exception as e:
|
||||
trigger.sb["replynum"] = e
|
||||
trigger.sb["replynum"] = 0
|
||||
trigger.sb["replynum"] += 1
|
||||
trigger.sb["totalreplies"] = len(trigger.sb["dict"][trigger.sb["responsekey"]]["responses"])
|
||||
botcom.dict["replynum"] = e
|
||||
botcom.dict["replynum"] = 0
|
||||
botcom.dict["replynum"] += 1
|
||||
botcom.dict["totalreplies"] = len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])
|
||||
|
||||
# This handles responses in list form
|
||||
if not isinstance(trigger.sb["replies"], list):
|
||||
trigger.sb["replies"] = [trigger.sb["replies"]]
|
||||
if not isinstance(botcom.dict["replies"], list):
|
||||
botcom.dict["replies"] = [botcom.dict["replies"]]
|
||||
|
||||
for rply in trigger.sb["replies"]:
|
||||
for rply in botcom.dict["replies"]:
|
||||
|
||||
# replies that can be evaluated as code
|
||||
if rply.startswith("time.sleep"):
|
||||
@ -246,31 +246,31 @@ def bot_dictcom_reply_shared(bot, trigger):
|
||||
|
||||
# random number
|
||||
if "$randnum" in rply:
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["randnum"]:
|
||||
randno = randint(trigger.sb["dict"][trigger.sb["responsekey"]]["randnum"][0], trigger.sb["dict"][trigger.sb["responsekey"]]["randnum"][1])
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["randnum"]:
|
||||
randno = randint(botcom.dict["dict"][botcom.dict["responsekey"]]["randnum"][0], botcom.dict["dict"][botcom.dict["responsekey"]]["randnum"][1])
|
||||
else:
|
||||
randno = randint(0, 50)
|
||||
rply = rply.replace("$randnum", str(randno))
|
||||
|
||||
# blank
|
||||
if "$blank" in rply:
|
||||
rply = rply.replace("$blank", trigger.sb["completestring"] or '')
|
||||
rply = rply.replace("$blank", botcom.dict["completestring"] or '')
|
||||
|
||||
# the remaining input
|
||||
if "$input" in rply:
|
||||
rply = rply.replace("$input", spicemanip.main(trigger.sb['args'], 0) or trigger.sb["realcom"])
|
||||
rply = rply.replace("$input", spicemanip.main(botcom.dict['args'], 0) or botcom.dict["realcom"])
|
||||
|
||||
# translation
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["translations"]:
|
||||
rply = SpiceBot.translate.bot_translate_process(rply, trigger.sb["dict"][trigger.sb["responsekey"]]["translations"])
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["translations"]:
|
||||
rply = SpiceBot.translate.bot_translate_process(rply, botcom.dict["dict"][botcom.dict["responsekey"]]["translations"])
|
||||
|
||||
# text to precede the output
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["prefixtext"] and trigger.sb["success"]:
|
||||
rply = spicemanip.main(trigger.sb["dict"][trigger.sb["responsekey"]]["prefixtext"], 'random') + rply
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["prefixtext"] and botcom.dict["success"]:
|
||||
rply = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["prefixtext"], 'random') + rply
|
||||
|
||||
# text to follow the output
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["suffixtext"] and trigger.sb["success"]:
|
||||
rply = rply + spicemanip.main(trigger.sb["dict"][trigger.sb["responsekey"]]["suffixtext"], 'random')
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["suffixtext"] and botcom.dict["success"]:
|
||||
rply = rply + spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["suffixtext"], 'random')
|
||||
|
||||
# trigger.nick
|
||||
if "$instigator" in rply:
|
||||
@ -294,7 +294,7 @@ def bot_dictcom_reply_shared(bot, trigger):
|
||||
|
||||
# target
|
||||
if "$target" in rply:
|
||||
targetnames = trigger.sb["target"] or ''
|
||||
targetnames = botcom.dict["target"] or ''
|
||||
if "$targets" in rply:
|
||||
if targetnames.lower() == "your":
|
||||
targetnames = targetnames
|
||||
@ -309,23 +309,23 @@ def bot_dictcom_reply_shared(bot, trigger):
|
||||
|
||||
# smaller variations for the text
|
||||
if "$replyvariation" in rply:
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["replyvariation"] != []:
|
||||
variation = spicemanip.main(trigger.sb["dict"][trigger.sb["responsekey"]]["replyvariation"], 'random')
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["replyvariation"] != []:
|
||||
variation = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["replyvariation"], 'random')
|
||||
rply = rply.replace("$replyvariation", variation)
|
||||
else:
|
||||
rply = rply.replace("$replyvariation", '')
|
||||
|
||||
# smaller variations for the text
|
||||
if "$responsekey" in rply:
|
||||
rply = rply.replace("$responsekey", str(trigger.sb["responsekey"]))
|
||||
rply = rply.replace("$responsekey", str(botcom.dict["responsekey"]))
|
||||
|
||||
if "$index" in rply:
|
||||
rply = rply.replace("$index", str(str(trigger.sb["replynum"]) + "/" + str(trigger.sb["totalreplies"])))
|
||||
rply = rply.replace("$index", str(str(botcom.dict["replynum"]) + "/" + str(botcom.dict["totalreplies"])))
|
||||
|
||||
# display special options for this command
|
||||
if "$specialoptions" in rply:
|
||||
nonstockoptions = []
|
||||
for command in trigger.sb["dict"].keys():
|
||||
for command in botcom.dict["dict"].keys():
|
||||
if command not in ["?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", "exampleresponse", "example", "usage", "privs"]:
|
||||
nonstockoptions.append(command)
|
||||
nonstockoptions = spicemanip.main(nonstockoptions, "andlist")
|
||||
@ -341,26 +341,26 @@ def bot_dictcom_reply_shared(bot, trigger):
|
||||
bot.osd(rply, trigger.sender, rplytype)
|
||||
|
||||
|
||||
def bot_dictcom_gif(bot, trigger):
|
||||
def bot_dictcom_gif(bot, trigger, botcom):
|
||||
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["blank_required"] and not trigger.sb["completestring"]:
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = trigger.sb["dict"][trigger.sb["responsekey"]]["blank_fail"]
|
||||
return bot_dictcom_reply_shared(bot, trigger)
|
||||
elif trigger.sb["dict"][trigger.sb["responsekey"]]["blank_required"] and trigger.sb["completestring"]:
|
||||
queries = [trigger.sb["completestring"]]
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"] and not botcom.dict["completestring"]:
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_fail"]
|
||||
return bot_dictcom_reply_shared(bot, trigger, botcom)
|
||||
elif botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"] and botcom.dict["completestring"]:
|
||||
queries = [botcom.dict["completestring"]]
|
||||
else:
|
||||
queries = trigger.sb["dict"][trigger.sb["responsekey"]]["responses"]
|
||||
queries = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]
|
||||
|
||||
# which api's are we using to search
|
||||
if "queryapi" in trigger.sb["dict"].keys():
|
||||
searchapis = trigger.sb["dict"][trigger.sb["responsekey"]]["queryapi"]
|
||||
if "queryapi" in botcom.dict["dict"].keys():
|
||||
searchapis = botcom.dict["dict"][botcom.dict["responsekey"]]["queryapi"]
|
||||
else:
|
||||
searchapis = list(SpiceBot.gif.valid_api.keys())
|
||||
|
||||
if trigger.sb["specified"]:
|
||||
if trigger.sb["specified"] > len(queries):
|
||||
trigger.sb["specified"] = len(queries)
|
||||
query = spicemanip.main(queries, trigger.sb["specified"], 'return')
|
||||
if botcom.dict["specified"]:
|
||||
if botcom.dict["specified"] > len(queries):
|
||||
botcom.dict["specified"] = len(queries)
|
||||
query = spicemanip.main(queries, botcom.dict["specified"], 'return')
|
||||
else:
|
||||
query = spicemanip.main(queries, 'random', 'return')
|
||||
|
||||
@ -374,18 +374,18 @@ def bot_dictcom_gif(bot, trigger):
|
||||
gifdict = SpiceBot.gif.get_gif(searchdict)
|
||||
|
||||
if gifdict["error"]:
|
||||
trigger.sb["success"] = False
|
||||
if trigger.sb["dict"][trigger.sb["responsekey"]]["search_fail"]:
|
||||
gifdict["error"] = trigger.sb["dict"][trigger.sb["responsekey"]]["search_fail"]
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = [gifdict["error"]]
|
||||
botcom.dict["success"] = False
|
||||
if botcom.dict["dict"][botcom.dict["responsekey"]]["search_fail"]:
|
||||
gifdict["error"] = botcom.dict["dict"][botcom.dict["responsekey"]]["search_fail"]
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = [gifdict["error"]]
|
||||
else:
|
||||
trigger.sb["dict"][trigger.sb["responsekey"]]["responses"] = [str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))]
|
||||
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = [str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))]
|
||||
|
||||
trigger.sb["specified"] = False
|
||||
bot_dictcom_reply_shared(bot, trigger)
|
||||
botcom.dict["specified"] = False
|
||||
bot_dictcom_reply_shared(bot, trigger, botcom)
|
||||
|
||||
|
||||
def bot_dictcom_feeds(bot, trigger):
|
||||
def bot_dictcom_feeds(bot, trigger, botcom):
|
||||
return bot.osd("WIP")
|
||||
"""
|
||||
|
||||
@ -394,7 +394,7 @@ def bot_dictcom_feeds(bot, trigger):
|
||||
|
||||
bot_startup_requirements_set(bot, "feeds")
|
||||
|
||||
feed = trigger.sb["dict"][trigger.sb["responsekey"]]["responses"][0]
|
||||
feed = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"][0]
|
||||
if feed not in bot.memory['feeds'].keys():
|
||||
return bot.osd(feed + " does not appear to be a valid feed.")
|
||||
|
||||
@ -407,5 +407,5 @@ def bot_dictcom_feeds(bot, trigger):
|
||||
"""
|
||||
|
||||
|
||||
def bot_dictcom_search(bot, trigger):
|
||||
def bot_dictcom_search(bot, trigger, botcom):
|
||||
bot.say("testing done")
|
||||
|
||||
@ -15,17 +15,17 @@ import spicemanip
|
||||
@sopel.module.commands('gif')
|
||||
def gif_trigger(bot, trigger, botcom):
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
return SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Please present a query to search.")
|
||||
if not len(botcom.dict['args']):
|
||||
return SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please present a query to search.")
|
||||
|
||||
query = spicemanip.main(trigger.sb['args'], 0)
|
||||
query = spicemanip.main(botcom.dict['args'], 0)
|
||||
searchapis = list(SpiceBot.gif.valid_api.keys())
|
||||
searchdict = {"query": query, "gifsearch": searchapis}
|
||||
|
||||
gifdict = SpiceBot.gif.get_gif(searchdict)
|
||||
|
||||
if gifdict["error"]:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], gifdict["error"])
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], gifdict["error"])
|
||||
else:
|
||||
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))
|
||||
|
||||
@ -34,18 +34,18 @@ def gif_trigger(bot, trigger, botcom):
|
||||
@sopel.module.commands('(.*)')
|
||||
def gifapi_triggers(bot, trigger, botcom):
|
||||
|
||||
if trigger.sb['com'] not in list(SpiceBot.gif.valid_api.keys()):
|
||||
if botcom.dict['com'] not in list(SpiceBot.gif.valid_api.keys()):
|
||||
return
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
return SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Please present a query to search.")
|
||||
if not len(botcom.dict['args']):
|
||||
return SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please present a query to search.")
|
||||
|
||||
query = spicemanip.main(trigger.sb['args'], 0)
|
||||
searchdict = {"query": query, "gifsearch": trigger.sb['com']}
|
||||
query = spicemanip.main(botcom.dict['args'], 0)
|
||||
searchdict = {"query": query, "gifsearch": botcom.dict['com']}
|
||||
|
||||
gifdict = SpiceBot.gif.get_gif(searchdict)
|
||||
|
||||
if gifdict["error"]:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], gifdict["error"])
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], gifdict["error"])
|
||||
else:
|
||||
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))
|
||||
|
||||
@ -17,10 +17,10 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
def bot_command_logs(bot, trigger, botcom):
|
||||
|
||||
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
return
|
||||
|
||||
logtype = spicemanip.main(trigger.sb['args'], 1) or None
|
||||
logtype = spicemanip.main(botcom.dict['args'], 1) or None
|
||||
if not logtype:
|
||||
bot.osd("Current valid log(s) include: " + spicemanip.main(list(SpiceBot.logs.dict["list"].keys()), 'andlist'), trigger.sender, 'action')
|
||||
return
|
||||
@ -28,9 +28,9 @@ def bot_command_logs(bot, trigger, botcom):
|
||||
if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())):
|
||||
closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse')
|
||||
if not len(closestmatches):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "No valid logs match " + str(logtype) + ".", trigger.nick, 'notice')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "No valid logs match " + str(logtype) + ".", trigger.nick, 'notice')
|
||||
else:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
|
||||
|
||||
return
|
||||
|
||||
@ -39,7 +39,7 @@ def bot_command_logs(bot, trigger, botcom):
|
||||
logindex = SpiceBot.logs.get_logs(logtype)
|
||||
|
||||
if not len(logindex):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "No logs found for " + str(logtype) + ".")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "No logs found for " + str(logtype) + ".")
|
||||
return
|
||||
|
||||
bot.osd("Is Examining " + str(logtype) + " log(s).")
|
||||
|
||||
@ -12,42 +12,42 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@SpiceBot.prerun('nickname')
|
||||
@sopel.module.nickname_commands('action')
|
||||
def bot_command_action(bot, trigger, botcom):
|
||||
bot_command_process(bot, trigger)
|
||||
bot_command_process(bot, trigger, botcom)
|
||||
|
||||
|
||||
@SpiceBot.prerun('nickname')
|
||||
@sopel.module.nickname_commands('notice')
|
||||
def bot_command_notice(bot, trigger, botcom):
|
||||
bot_command_process(bot, trigger)
|
||||
bot_command_process(bot, trigger, botcom)
|
||||
|
||||
|
||||
@SpiceBot.prerun('nickname')
|
||||
@sopel.module.nickname_commands('privmsg', 'say', 'msg')
|
||||
def bot_command_privmsg(bot, trigger, botcom):
|
||||
bot_command_process(bot, trigger)
|
||||
bot_command_process(bot, trigger, botcom)
|
||||
|
||||
|
||||
def bot_command_process(bot, trigger):
|
||||
def bot_command_process(bot, trigger, botcom):
|
||||
|
||||
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
return
|
||||
|
||||
if trigger.sb['com'] in ['say', 'msg']:
|
||||
trigger.sb['com'] = 'privmsg'
|
||||
if botcom.dict['com'] in ['say', 'msg']:
|
||||
botcom.dict['com'] = 'privmsg'
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "You must specify a channel or nick.")
|
||||
if not len(botcom.dict['args']):
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "You must specify a channel or nick.")
|
||||
return
|
||||
|
||||
target = spicemanip.main(trigger.sb['args'], 1)
|
||||
target = spicemanip.main(botcom.dict['args'], 1)
|
||||
if (target not in ['allchans', 'allnicks']
|
||||
and not SpiceBot.inlist(target.lower(), list(SpiceBot.channels.dict['list'].keys()))
|
||||
and not SpiceBot.inlist(target.lower(), bot.users)):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Channel/nick name {} not valid.".format(target))
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel/nick name {} not valid.".format(target))
|
||||
return
|
||||
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
if target == 'allchans':
|
||||
targetsendlist = list(bot.channels.keys())
|
||||
@ -56,9 +56,9 @@ def bot_command_process(bot, trigger):
|
||||
else:
|
||||
targetsendlist = [target]
|
||||
|
||||
botmessage = spicemanip.main(trigger.sb['args'], 0)
|
||||
botmessage = spicemanip.main(botcom.dict['args'], 0)
|
||||
if not botmessage:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "You must specify a message to send.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "You must specify a message to send.")
|
||||
return
|
||||
|
||||
bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper())
|
||||
bot.osd(botmessage, targetsendlist, botcom.dict['com'].upper())
|
||||
|
||||
@ -14,19 +14,19 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
def nickname_comand_update(bot, trigger, botcom):
|
||||
|
||||
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
|
||||
return
|
||||
|
||||
if not len(trigger.sb['args']):
|
||||
if not len(botcom.dict['args']):
|
||||
commandused = 'nodeps'
|
||||
else:
|
||||
commandused = spicemanip.main(trigger.sb['args'], 1).lower()
|
||||
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
|
||||
|
||||
if commandused not in ['deps', 'nodeps']:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Please specify deps or nodeps")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please specify deps or nodeps")
|
||||
return
|
||||
|
||||
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
|
||||
|
||||
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
|
||||
SpiceBot.logs.log('SpiceBot_Update', quitmessage)
|
||||
@ -46,7 +46,7 @@ def nickname_comand_update(bot, trigger, botcom):
|
||||
def nickname_comand_restart(bot, trigger, botcom):
|
||||
|
||||
if not trigger.admin:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "You are not authorized to perform this function.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "You are not authorized to perform this function.")
|
||||
|
||||
quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!"
|
||||
SpiceBot.logs.log('SpiceBot_Restart', quitmessage)
|
||||
|
||||
@ -14,14 +14,14 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@sopel.module.commands('search', 'find', 'google', 'lookup')
|
||||
def search_main(bot, trigger, botcom):
|
||||
|
||||
searchterm = spicemanip.main(trigger.sb['args'], 0) or None
|
||||
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
|
||||
if not searchterm:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Not sure what you want me to look for.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
|
||||
return
|
||||
|
||||
searchreturn = SpiceBot.google.search(searchterm)
|
||||
if not searchreturn:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], 'I cannot find anything about that')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], 'I cannot find anything about that')
|
||||
else:
|
||||
bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)])
|
||||
|
||||
@ -30,14 +30,14 @@ def search_main(bot, trigger, botcom):
|
||||
@sopel.module.commands("where", "whereis")
|
||||
def search_where(bot, trigger, botcom):
|
||||
|
||||
searchterm = spicemanip.main(trigger.sb['args'], 0) or None
|
||||
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
|
||||
if not searchterm:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Not sure what you want me to look for.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
|
||||
return
|
||||
|
||||
searchreturn = SpiceBot.google.search(searchterm, 'maps')
|
||||
if not searchreturn:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], 'I cannot find anything about that')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], 'I cannot find anything about that')
|
||||
else:
|
||||
bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)])
|
||||
|
||||
@ -46,14 +46,14 @@ def search_where(bot, trigger, botcom):
|
||||
@sopel.module.commands("what", "whatis")
|
||||
def search_what(bot, trigger, botcom):
|
||||
|
||||
searchterm = spicemanip.main(trigger.sb['args'], 0) or None
|
||||
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
|
||||
if not searchterm:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Not sure what you want me to look for.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
|
||||
return
|
||||
|
||||
searchreturn = SpiceBot.google.search(searchterm)
|
||||
if not searchreturn:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], 'I cannot find anything about that')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], 'I cannot find anything about that')
|
||||
else:
|
||||
bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)])
|
||||
|
||||
@ -62,13 +62,13 @@ def search_what(bot, trigger, botcom):
|
||||
@sopel.module.commands("youtube", "video")
|
||||
def search_video(bot, trigger, botcom):
|
||||
|
||||
searchterm = spicemanip.main(trigger.sb['args'], 0) or None
|
||||
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
|
||||
if not searchterm:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], "Not sure what you want me to look for.")
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
|
||||
return
|
||||
|
||||
searchreturn = SpiceBot.google.search(searchterm, 'youtube')
|
||||
if not searchreturn:
|
||||
SpiceBot.messagelog.messagelog_error(trigger.sb["log_id"], 'I cannot find anything about that')
|
||||
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], 'I cannot find anything about that')
|
||||
else:
|
||||
bot.osd(["[Youtube search for '" + str(searchterm) + "']", str(searchreturn)])
|
||||
|
||||
@ -15,15 +15,15 @@ def bot_command_sherlock(bot, trigger, botcom):
|
||||
|
||||
netlist = list(SpiceBot.sherlock.dict.keys())
|
||||
|
||||
username = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
|
||||
trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", 'list')
|
||||
username = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
||||
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", 'list')
|
||||
|
||||
checklist = netlist
|
||||
checklistname = 'all'
|
||||
if SpiceBot.inlist(username, netlist):
|
||||
checklistname = SpiceBot.inlist_match(username, netlist)
|
||||
checklist = [checklistname]
|
||||
username = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
|
||||
username = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
||||
|
||||
bot.osd("Checking username " + username + " in " + checklistname + " network.")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user