mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
nickname commands
This commit is contained in:
parent
f2dbfc9589
commit
b894ee93c5
@ -18,6 +18,15 @@ def query_detection(bot, trigger):
|
|||||||
while not bot_events_check(bot, '2002'):
|
while not bot_events_check(bot, '2002'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command')
|
||||||
|
|
||||||
|
# command issued, check if valid
|
||||||
|
if not triggercommand or not len(triggercommand):
|
||||||
|
return
|
||||||
|
|
||||||
|
if not letters_in_string(triggercommand):
|
||||||
|
return
|
||||||
|
|
||||||
commands_list = dict()
|
commands_list = dict()
|
||||||
for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys():
|
for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys():
|
||||||
if commandstype != 'rule':
|
if commandstype != 'rule':
|
||||||
@ -31,55 +40,56 @@ def query_detection(bot, trigger):
|
|||||||
else:
|
else:
|
||||||
commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com]
|
commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com]
|
||||||
|
|
||||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command')
|
botnick_coms = list(bot.memory['SpiceBot_CommandsQuery']['commands']['nickname'].keys())
|
||||||
|
# botnick_coms.extend(bot.memory['SpiceBot_CommandsQuery']['nickrules'])
|
||||||
|
|
||||||
# command issued, check if valid
|
if triggercommand.lower().startswith(str(bot.nick).lower()):
|
||||||
if not triggercommand or not len(triggercommand):
|
searchlist = botnick_coms
|
||||||
|
searchitem = spicemanip.main([triggercommand].extend(triggerargs), 0)
|
||||||
|
else:
|
||||||
|
searchlist = list(commands_list.keys())
|
||||||
|
searchitem = triggercommand
|
||||||
|
|
||||||
|
if searchitem.endswith("+"):
|
||||||
|
|
||||||
|
searchitem = searchitem[:-1]
|
||||||
|
if not searchitem or not len(searchitem):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not letters_in_string(triggercommand):
|
if searchitem.lower() not in searchlist:
|
||||||
return
|
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(searchitem) + "."]
|
||||||
|
closestmatches = similar_list(bot, searchitem, searchlist, 10, 'reverse')
|
||||||
if triggercommand.endswith("+"):
|
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
|
||||||
if not triggercommand or not len(triggercommand):
|
|
||||||
return
|
|
||||||
|
|
||||||
if triggercommand not in commands_list.keys():
|
|
||||||
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."]
|
|
||||||
closestmatches = similar_list(bot, triggercommand, 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(searchitem) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
|
||||||
bot.notice(dispmsg, trigger.nick)
|
bot.notice(dispmsg, trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
realcom = triggercommand
|
realcom = searchitem
|
||||||
if "aliasfor" in commands_list[triggercommand].keys():
|
if "aliasfor" in commands_list[searchitem].keys():
|
||||||
realcom = commands_list[triggercommand]["aliasfor"]
|
realcom = commands_list[searchitem]["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(searchitem) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
if triggercommand.endswith("?"):
|
if searchitem.endswith("?"):
|
||||||
|
|
||||||
triggercommand = triggercommand[:-1]
|
searchitem = searchitem[:-1]
|
||||||
if not triggercommand or not len(triggercommand):
|
if not searchitem or not len(searchitem):
|
||||||
return
|
return
|
||||||
|
|
||||||
closestmatches = similar_list(bot, triggercommand, commands_list.keys(), 10, 'reverse')
|
closestmatches = similar_list(bot, searchitem, searchlist, 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(searchitem) + ".", 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(searchitem) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
commandlist = []
|
commandlist = []
|
||||||
for command in commands_list.keys():
|
for command in searchlist:
|
||||||
if command.lower().startswith(str(triggercommand).lower()):
|
if command.lower().startswith(str(searchitem).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(searchitem) + ".", 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(searchitem) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user