mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
integrate args system into modules
This commit is contained in:
parent
d5c35103bd
commit
2d8992c993
@ -12,24 +12,24 @@ class BotPrerun():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.dict = {}
|
self.dict = {}
|
||||||
|
|
||||||
def args(self, command_type='module_command'):
|
def args(self, trigger_command_type='module_command'):
|
||||||
def actual_decorator(function):
|
def actual_decorator(function):
|
||||||
@functools.wraps(function)
|
@functools.wraps(function)
|
||||||
def argsbuilder(bot, trigger, *args, **kwargs):
|
def argsbuilder(bot, trigger, *args, **kwargs):
|
||||||
trigger.sb = self.sopel_triggerargs(bot, trigger, command_type)
|
trigger.sb = self.sopel_trigger_args(bot, trigger, trigger_command_type)
|
||||||
return function(bot, trigger, *args, **kwargs)
|
return function(bot, trigger, *args, **kwargs)
|
||||||
return argsbuilder
|
return argsbuilder
|
||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
def sopel_triggerargs(self, bot, trigger, command_type='module_command'):
|
def sopel_trigger_args(self, bot, trigger, trigger_command_type='module_command'):
|
||||||
triggerargs = spicemanip.main(trigger.args[1], 'create')
|
trigger_args = spicemanip.main(trigger.args[1], 'create')
|
||||||
if command_type in ['nickname', 'nickname_command', 'nickname_commands']:
|
if trigger_command_type in ['nickname', 'nickname_command', 'nickname_commands']:
|
||||||
command = spicemanip.main(triggerargs, 2).lower()
|
trigger_command = spicemanip.main(trigger_args, 2).lower()
|
||||||
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
trigger_args = spicemanip.main(trigger_args, '3+', 'list')
|
||||||
else:
|
else:
|
||||||
command = spicemanip.main(triggerargs, 1).lower()[1:]
|
trigger_command = spicemanip.main(trigger_args, 1).lower()[1:]
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
trigger_args = spicemanip.main(trigger_args, '2+', 'list')
|
||||||
argsdict = {"com": command, "args": triggerargs, "type": command_type}
|
argsdict = {"com": trigger_command, "args": trigger_args, "type": trigger_command_type}
|
||||||
return argsdict
|
return argsdict
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -38,23 +38,6 @@ github_dict = {
|
|||||||
"""Sopel Wrapping Tools"""
|
"""Sopel Wrapping Tools"""
|
||||||
|
|
||||||
|
|
||||||
def sopel_triggerargs(bot, trigger, command_type='module_command'):
|
|
||||||
triggerargs = []
|
|
||||||
|
|
||||||
if len(trigger.args) > 1:
|
|
||||||
triggerargs = spicemanip.main(trigger.args[1], 'create')
|
|
||||||
triggerargs = spicemanip.main(triggerargs, 'create')
|
|
||||||
|
|
||||||
if command_type in ['nickname_command']:
|
|
||||||
command = spicemanip.main(triggerargs, 2).lower()
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
|
||||||
else:
|
|
||||||
command = spicemanip.main(triggerargs, 1).lower()[1:]
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
|
||||||
|
|
||||||
return triggerargs, command, command_type
|
|
||||||
|
|
||||||
|
|
||||||
def bot_privs(bot, privtype):
|
def bot_privs(bot, privtype):
|
||||||
if privtype == 'owners':
|
if privtype == 'owners':
|
||||||
privtype = 'owner'
|
privtype = 'owner'
|
||||||
|
|||||||
@ -10,25 +10,24 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY])
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('(.*)')
|
@sopel.module.nickname_commands('(.*)')
|
||||||
def bot_command_nick(bot, trigger):
|
def bot_command_nick(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
if not trigger.sb['com']:
|
||||||
|
|
||||||
if not triggercommand:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand[0] == "?":
|
if trigger.sb['com'][0] == "?":
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand in SpiceBot.commands.dict['commands']["nickname"].keys():
|
if trigger.sb['com'] in SpiceBot.commands.dict['commands']["nickname"].keys():
|
||||||
return
|
return
|
||||||
triggerargs.insert(0, triggercommand)
|
trigger.sb['args'].insert(0, trigger.sb['com'])
|
||||||
|
|
||||||
fulltrigger = spicemanip.main(triggerargs, 0).lower()
|
fulltrigger = spicemanip.main(trigger.sb['args'], 0).lower()
|
||||||
|
|
||||||
if fulltrigger.lower().startswith("what is"):
|
if fulltrigger.lower().startswith("what is"):
|
||||||
searchterm = spicemanip.main(triggerargs, "3+") or None
|
searchterm = spicemanip.main(trigger.sb['args'], "3+") or None
|
||||||
if searchterm:
|
if searchterm:
|
||||||
searchreturn = SpiceBot.googlesearch(bot, searchterm)
|
searchreturn = SpiceBot.googlesearch(bot, searchterm)
|
||||||
if not searchreturn:
|
if not searchreturn:
|
||||||
@ -40,7 +39,7 @@ def bot_command_nick(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower().startswith("where is"):
|
elif fulltrigger.lower().startswith("where is"):
|
||||||
searchterm = spicemanip.main(triggerargs, "3+") or None
|
searchterm = spicemanip.main(trigger.sb['args'], "3+") or None
|
||||||
if searchterm:
|
if searchterm:
|
||||||
|
|
||||||
if searchterm.lower() in ['waldo', 'wally']:
|
if searchterm.lower() in ['waldo', 'wally']:
|
||||||
@ -68,14 +67,14 @@ def bot_command_nick(bot, trigger):
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
# elif fulltrigger.lower().startswith(tuple(["have you seen"])):
|
# elif fulltrigger.lower().startswith(tuple(["have you seen"])):
|
||||||
# posstarget = spicemanip.main(triggerargs, 4) or 0
|
# posstarget = spicemanip.main(trigger.sb['args'], 4) or 0
|
||||||
# message = seen_search(bot, botcom, posstarget)
|
# message = seen_search(bot, botcom, posstarget)
|
||||||
# bot.osd(message)
|
# bot.osd(message)
|
||||||
# return
|
# return
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])):
|
elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])):
|
||||||
makemea = spicemanip.main(triggerargs, "4+") or None
|
makemea = spicemanip.main(trigger.sb['args'], "4+") or None
|
||||||
if makemea:
|
if makemea:
|
||||||
bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action')
|
bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action')
|
||||||
else:
|
else:
|
||||||
@ -83,7 +82,7 @@ def bot_command_nick(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower().startswith("beam me to"):
|
elif fulltrigger.lower().startswith("beam me to"):
|
||||||
location = spicemanip.main(triggerargs, "4+") or None
|
location = spicemanip.main(trigger.sb['args'], "4+") or None
|
||||||
if location:
|
if location:
|
||||||
bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action')
|
bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action')
|
||||||
else:
|
else:
|
||||||
@ -131,7 +130,7 @@ def bot_command_nick(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif fulltrigger.lower().startswith("can you see"):
|
elif fulltrigger.lower().startswith("can you see"):
|
||||||
target = spicemanip.main(triggerargs, "4+") or None
|
target = spicemanip.main(trigger.sb['args'], "4+") or None
|
||||||
if not target:
|
if not target:
|
||||||
bot.osd(trigger.nick + ", I can see clearly.")
|
bot.osd(trigger.nick + ", I can see clearly.")
|
||||||
return
|
return
|
||||||
|
|||||||
@ -9,21 +9,22 @@ import spicemanip
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('owners', 'owner')
|
@sopel.module.nickname_commands('owners', 'owner')
|
||||||
def bot_command_owners(bot, trigger):
|
def bot_command_owners(bot, trigger):
|
||||||
bot_command_process(bot, trigger)
|
bot_command_process(bot, trigger)
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('admins')
|
@sopel.module.nickname_commands('admins')
|
||||||
def bot_command_admins(bot, trigger):
|
def bot_command_admins(bot, trigger):
|
||||||
bot_command_process(bot, trigger)
|
bot_command_process(bot, trigger)
|
||||||
|
|
||||||
|
|
||||||
def bot_command_process(bot, trigger):
|
def bot_command_process(bot, trigger):
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
|
||||||
|
|
||||||
if triggercommand == 'owner':
|
if trigger.sb['com'] == 'owner':
|
||||||
triggercommand = 'owners'
|
trigger.sb['com'] = 'owners'
|
||||||
|
|
||||||
privlist = spicemanip.main(SpiceBot.bot_privs(bot, triggercommand), 'andlist')
|
privlist = spicemanip.main(SpiceBot.bot_privs(bot, trigger.sb['com']), 'andlist')
|
||||||
bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist)
|
bot.osd(str(bot.nick) + " " + trigger.sb['com'] + ": " + privlist)
|
||||||
|
|||||||
@ -10,17 +10,16 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED])
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('channels', 'channel')
|
@sopel.module.nickname_commands('channels', 'channel')
|
||||||
def nickname_comand_channels(bot, trigger):
|
def nickname_comand_channels(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
if not len(trigger.sb['args']):
|
||||||
|
|
||||||
if not len(triggerargs):
|
|
||||||
commandused = 'list'
|
commandused = 'list'
|
||||||
else:
|
else:
|
||||||
commandused = spicemanip.main(triggerargs, 1).lower()
|
commandused = spicemanip.main(trigger.sb['args'], 1).lower()
|
||||||
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||||
|
|
||||||
if commandused == 'list':
|
if commandused == 'list':
|
||||||
chanlist = spicemanip.main(bot.channels.keys(), 'andlist')
|
chanlist = spicemanip.main(bot.channels.keys(), 'andlist')
|
||||||
@ -60,10 +59,10 @@ def nickname_comand_channels(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif commandused == 'topic':
|
elif commandused == 'topic':
|
||||||
if not len(triggerargs):
|
if not len(trigger.sb['args']):
|
||||||
bot.osd("Channel name input missing.")
|
bot.osd("Channel name input missing.")
|
||||||
return
|
return
|
||||||
channel = spicemanip.main(triggerargs, 1)
|
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||||
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
||||||
bot.osd("Channel name {} not valid.".format(channel))
|
bot.osd("Channel name {} not valid.".format(channel))
|
||||||
return
|
return
|
||||||
@ -73,14 +72,14 @@ def nickname_comand_channels(bot, trigger):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']:
|
if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']:
|
||||||
if not len(triggerargs):
|
if not len(trigger.sb['args']):
|
||||||
if trigger.is_privmsg:
|
if trigger.is_privmsg:
|
||||||
bot.osd("Channel name required.")
|
bot.osd("Channel name required.")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
channel = trigger.sender
|
channel = trigger.sender
|
||||||
else:
|
else:
|
||||||
channel = spicemanip.main(triggerargs, 1)
|
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||||
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
||||||
bot.osd("Channel name {} not valid.".format(channel))
|
bot.osd("Channel name {} not valid.".format(channel))
|
||||||
return
|
return
|
||||||
@ -100,7 +99,7 @@ def nickname_comand_channels(bot, trigger):
|
|||||||
|
|
||||||
# Users List
|
# Users List
|
||||||
if commandused == 'users':
|
if commandused == 'users':
|
||||||
channel = spicemanip.main(triggerargs, 1)
|
channel = spicemanip.main(trigger.sb['args'], 1)
|
||||||
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
|
||||||
bot.osd("Channel name {} not valid.".format(channel))
|
bot.osd("Channel name {} not valid.".format(channel))
|
||||||
return
|
return
|
||||||
|
|||||||
@ -11,20 +11,19 @@ import spicemanip
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('(.*)')
|
@sopel.module.nickname_commands('(.*)')
|
||||||
def query_detection_nick(bot, trigger):
|
def query_detection_nick(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
|
||||||
|
|
||||||
# command issued, check if valid
|
# command issued, check if valid
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not triggercommand[0] == "?":
|
if not trigger.sb['com'][0] == "?":
|
||||||
return
|
return
|
||||||
triggercommand = triggercommand[1:]
|
trigger.sb['com'] = trigger.sb['com'][1:]
|
||||||
|
|
||||||
if not SpiceBot.letters_in_string(triggercommand):
|
if not SpiceBot.letters_in_string(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
commands_list = dict()
|
commands_list = dict()
|
||||||
@ -32,46 +31,46 @@ def query_detection_nick(bot, trigger):
|
|||||||
if com not in commands_list.keys():
|
if com not in commands_list.keys():
|
||||||
commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com]
|
commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com]
|
||||||
|
|
||||||
if triggercommand.endswith("+"):
|
if trigger.sb['com'].endswith("+"):
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand.lower() not in list(commands_list.keys()):
|
if trigger.sb['com'].lower() not in list(commands_list.keys()):
|
||||||
dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(triggercommand) + "."]
|
dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(trigger.sb['com']) + "."]
|
||||||
closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
|
closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||||
if len(closestmatches):
|
if len(closestmatches):
|
||||||
dispmsg.append("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||||
bot.notice(dispmsg, trigger.nick)
|
bot.notice(dispmsg, trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
realcom = triggercommand
|
realcom = trigger.sb['com']
|
||||||
if "aliasfor" in commands_list[triggercommand].keys():
|
if "aliasfor" in commands_list[trigger.sb['com']].keys():
|
||||||
realcom = commands_list[triggercommand]["aliasfor"]
|
realcom = commands_list[trigger.sb['com']]["aliasfor"]
|
||||||
validcomlist = commands_list[realcom]["validcoms"]
|
validcomlist = commands_list[realcom]["validcoms"]
|
||||||
bot.notice("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
|
bot.notice("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand.endswith("?"):
|
if trigger.sb['com'].endswith("?"):
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
|
closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||||
if not len(closestmatches):
|
if not len(closestmatches):
|
||||||
bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(triggercommand) + ".", trigger.nick)
|
bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick)
|
||||||
else:
|
else:
|
||||||
bot.notice("The following " + bot.nick + " commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
|
bot.notice("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
commandlist = []
|
commandlist = []
|
||||||
for command in list(commands_list.keys()):
|
for command in list(commands_list.keys()):
|
||||||
if command.lower().startswith(str(triggercommand).lower()):
|
if command.lower().startswith(str(trigger.sb['com']).lower()):
|
||||||
commandlist.append(command)
|
commandlist.append(command)
|
||||||
|
|
||||||
if not len(commandlist):
|
if not len(commandlist):
|
||||||
bot.notice("No " + bot.nick + " commands start with " + str(triggercommand) + ".", trigger.nick)
|
bot.notice("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick)
|
||||||
else:
|
else:
|
||||||
bot.notice("The following " + bot.nick + " commands start with " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)
|
bot.notice("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)
|
||||||
|
|||||||
@ -11,16 +11,15 @@ import spicemanip
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
||||||
|
@SpiceBot.prerun.args('query_command')
|
||||||
@sopel.module.rule('^\?(.*)')
|
@sopel.module.rule('^\?(.*)')
|
||||||
def query_detection(bot, trigger):
|
def query_detection(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command')
|
|
||||||
|
|
||||||
# command issued, check if valid
|
# command issued, check if valid
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not SpiceBot.letters_in_string(triggercommand):
|
if not SpiceBot.letters_in_string(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
commands_list = dict()
|
commands_list = dict()
|
||||||
@ -30,46 +29,46 @@ def query_detection(bot, trigger):
|
|||||||
if com not in commands_list.keys():
|
if com not in commands_list.keys():
|
||||||
commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com]
|
commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com]
|
||||||
|
|
||||||
if triggercommand[:-1] == "+":
|
if trigger.sb['com'][:-1] == "+":
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand.lower() not in list(commands_list.keys()):
|
if trigger.sb['com'].lower() not in list(commands_list.keys()):
|
||||||
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."]
|
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(trigger.sb['com']) + "."]
|
||||||
closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
|
closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||||
if len(closestmatches):
|
if len(closestmatches):
|
||||||
dispmsg.append("The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||||
bot.notice(dispmsg, trigger.nick)
|
bot.notice(dispmsg, trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
realcom = triggercommand
|
realcom = trigger.sb['com']
|
||||||
if "aliasfor" in commands_list[triggercommand].keys():
|
if "aliasfor" in commands_list[trigger.sb['com']].keys():
|
||||||
realcom = commands_list[triggercommand]["aliasfor"]
|
realcom = commands_list[trigger.sb['com']]["aliasfor"]
|
||||||
validcomlist = commands_list[realcom]["validcoms"]
|
validcomlist = commands_list[realcom]["validcoms"]
|
||||||
bot.notice("The following commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
|
bot.notice("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand[:-1] == "?":
|
if trigger.sb['com'][:-1] == "?":
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
trigger.sb['com'] = trigger.sb['com'][:-1]
|
||||||
if not triggercommand or not len(triggercommand):
|
if not trigger.sb['com'] or not len(trigger.sb['com']):
|
||||||
return
|
return
|
||||||
|
|
||||||
closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
|
closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse')
|
||||||
if not len(closestmatches):
|
if not len(closestmatches):
|
||||||
bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick)
|
bot.notice("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick)
|
||||||
else:
|
else:
|
||||||
bot.notice("The following commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
|
bot.notice("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
commandlist = []
|
commandlist = []
|
||||||
for command in list(commands_list.keys()):
|
for command in list(commands_list.keys()):
|
||||||
if command.lower().startswith(str(triggercommand).lower()):
|
if command.lower().startswith(str(trigger.sb['com']).lower()):
|
||||||
commandlist.append(command)
|
commandlist.append(command)
|
||||||
|
|
||||||
if not len(commandlist):
|
if not len(commandlist):
|
||||||
bot.notice("No commands start with " + str(triggercommand) + ".", trigger.nick)
|
bot.notice("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick)
|
||||||
else:
|
else:
|
||||||
bot.notice("The following commands start with " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)
|
bot.notice("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)
|
||||||
|
|||||||
@ -12,19 +12,18 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
||||||
|
@SpiceBot.prerun.args('prefix_command')
|
||||||
@sopel.module.commands('(.*)')
|
@sopel.module.commands('(.*)')
|
||||||
def gifapi_triggers(bot, trigger):
|
def gifapi_triggers(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command')
|
if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
||||||
|
|
||||||
if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not len(triggerargs):
|
if not len(trigger.sb['args']):
|
||||||
return bot.osd("Please present a query to search.")
|
return bot.osd("Please present a query to search.")
|
||||||
|
|
||||||
query = spicemanip.main(triggerargs, 0)
|
query = spicemanip.main(trigger.sb['args'], 0)
|
||||||
searchdict = {"query": query, "gifsearch": triggercommand}
|
searchdict = {"query": query, "gifsearch": trigger.sb['com']}
|
||||||
|
|
||||||
gifdict = getGif(bot, searchdict)
|
gifdict = getGif(bot, searchdict)
|
||||||
|
|
||||||
|
|||||||
@ -12,14 +12,14 @@ import spicemanip
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
||||||
|
@SpiceBot.prerun.args('prefix_command')
|
||||||
@module.commands('gif')
|
@module.commands('gif')
|
||||||
def gif_trigger(bot, trigger):
|
def gif_trigger(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger)
|
if not len(trigger.sb['args']):
|
||||||
if not len(triggerargs):
|
|
||||||
return bot.osd("Please present a query to search.")
|
return bot.osd("Please present a query to search.")
|
||||||
|
|
||||||
query = spicemanip.main(triggerargs, 0)
|
query = spicemanip.main(trigger.sb['args'], 0)
|
||||||
searchapis = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()
|
searchapis = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()
|
||||||
searchdict = {"query": query, "gifsearch": searchapis}
|
searchdict = {"query": query, "gifsearch": searchapis}
|
||||||
|
|
||||||
|
|||||||
@ -12,19 +12,18 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
|
||||||
|
@SpiceBot.prerun.args('prefix_command')
|
||||||
@sopel.module.commands('(.*)')
|
@sopel.module.commands('(.*)')
|
||||||
def gifapi_triggers(bot, trigger):
|
def gifapi_triggers(bot, trigger):
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command')
|
if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
||||||
|
|
||||||
if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not len(triggerargs):
|
if not len(trigger.sb['args']):
|
||||||
return bot.osd("Please present a query to search.")
|
return bot.osd("Please present a query to search.")
|
||||||
|
|
||||||
query = spicemanip.main(triggerargs, 0)
|
query = spicemanip.main(trigger.sb['args'], 0)
|
||||||
searchdict = {"query": query, "gifsearch": triggercommand}
|
searchdict = {"query": query, "gifsearch": trigger.sb['com']}
|
||||||
|
|
||||||
gifdict = getGif(bot, searchdict)
|
gifdict = getGif(bot, searchdict)
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS])
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('logs', 'debug')
|
@sopel.module.nickname_commands('logs', 'debug')
|
||||||
def bot_command_logs(bot, trigger):
|
def bot_command_logs(bot, trigger):
|
||||||
|
|
||||||
@ -16,9 +17,7 @@ def bot_command_logs(bot, trigger):
|
|||||||
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
logtype = spicemanip.main(trigger.sb['args'], 1) or None
|
||||||
|
|
||||||
logtype = spicemanip.main(triggerargs, 1) or None
|
|
||||||
if not logtype:
|
if not logtype:
|
||||||
bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action')
|
bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action')
|
||||||
return
|
return
|
||||||
|
|||||||
@ -9,16 +9,19 @@ import spicemanip
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('action')
|
@sopel.module.nickname_commands('action')
|
||||||
def bot_command_action(bot, trigger):
|
def bot_command_action(bot, trigger):
|
||||||
bot_command_process(bot, trigger)
|
bot_command_process(bot, trigger)
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('notice')
|
@sopel.module.nickname_commands('notice')
|
||||||
def bot_command_notice(bot, trigger):
|
def bot_command_notice(bot, trigger):
|
||||||
bot_command_process(bot, trigger)
|
bot_command_process(bot, trigger)
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('privmsg', 'say', 'msg')
|
@sopel.module.nickname_commands('privmsg', 'say', 'msg')
|
||||||
def bot_command_privmsg(bot, trigger):
|
def bot_command_privmsg(bot, trigger):
|
||||||
bot_command_process(bot, trigger)
|
bot_command_process(bot, trigger)
|
||||||
@ -30,23 +33,21 @@ def bot_command_process(bot, trigger):
|
|||||||
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
if trigger.sb['com'] in ['say', 'msg']:
|
||||||
|
trigger.sb['com'] = 'privmsg'
|
||||||
|
|
||||||
if triggercommand in ['say', 'msg']:
|
if not len(trigger.sb['args']):
|
||||||
triggercommand = 'privmsg'
|
|
||||||
|
|
||||||
if not len(triggerargs):
|
|
||||||
bot.say("You must specify a channel or nick.")
|
bot.say("You must specify a channel or nick.")
|
||||||
return
|
return
|
||||||
|
|
||||||
target = spicemanip.main(triggerargs, 1)
|
target = spicemanip.main(trigger.sb['args'], 1)
|
||||||
if (target not in ['allchans', 'allnicks']
|
if (target not in ['allchans', 'allnicks']
|
||||||
and not SpiceBot.inlist(target.lower(), SpiceBot.channels.dict['list'].keys())
|
and not SpiceBot.inlist(target.lower(), SpiceBot.channels.dict['list'].keys())
|
||||||
and not SpiceBot.inlist(target.lower(), bot.users)):
|
and not SpiceBot.inlist(target.lower(), bot.users)):
|
||||||
bot.osd("Channel/nick name {} not valid.".format(target))
|
bot.osd("Channel/nick name {} not valid.".format(target))
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||||
|
|
||||||
if target == 'allchans':
|
if target == 'allchans':
|
||||||
targetsendlist = bot.channels.keys()
|
targetsendlist = bot.channels.keys()
|
||||||
@ -55,9 +56,9 @@ def bot_command_process(bot, trigger):
|
|||||||
else:
|
else:
|
||||||
targetsendlist = [target]
|
targetsendlist = [target]
|
||||||
|
|
||||||
botmessage = spicemanip.main(triggerargs, 0)
|
botmessage = spicemanip.main(trigger.sb['args'], 0)
|
||||||
if not botmessage:
|
if not botmessage:
|
||||||
bot.say("You must specify a message to send.")
|
bot.say("You must specify a message to send.")
|
||||||
return
|
return
|
||||||
|
|
||||||
bot.osd(botmessage, targetsendlist, triggercommand.upper())
|
bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper())
|
||||||
|
|||||||
@ -27,6 +27,7 @@ def setup(bot):
|
|||||||
bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun.args('nickname_command')
|
||||||
@sopel.module.nickname_commands('update')
|
@sopel.module.nickname_commands('update')
|
||||||
def nickname_comand_update(bot, trigger):
|
def nickname_comand_update(bot, trigger):
|
||||||
|
|
||||||
@ -34,18 +35,16 @@ def nickname_comand_update(bot, trigger):
|
|||||||
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
|
if not len(trigger.sb['args']):
|
||||||
|
|
||||||
if not len(triggerargs):
|
|
||||||
commandused = 'nodeps'
|
commandused = 'nodeps'
|
||||||
else:
|
else:
|
||||||
commandused = spicemanip.main(triggerargs, 1).lower()
|
commandused = spicemanip.main(trigger.sb['args'], 1).lower()
|
||||||
|
|
||||||
if commandused not in ['deps', 'nodeps']:
|
if commandused not in ['deps', 'nodeps']:
|
||||||
bot.say("Please specify deps or nodeps")
|
bot.say("Please specify deps or nodeps")
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
|
||||||
|
|
||||||
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
|
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
|
||||||
SpiceBot.logs.log('SpiceBot_Update', quitmessage)
|
SpiceBot.logs.log('SpiceBot_Update', quitmessage)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user