mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 06:29:54 -05:00
onward
This commit is contained in:
parent
2cbc2b9041
commit
8e314f2aed
@ -22,6 +22,8 @@ class BotCommands():
|
|||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"counts": 0,
|
"counts": 0,
|
||||||
|
'nickrules': [],
|
||||||
|
'nickaiml': [],
|
||||||
"commands": {
|
"commands": {
|
||||||
'module': {},
|
'module': {},
|
||||||
'nickname': {},
|
'nickname': {},
|
||||||
@ -30,9 +32,17 @@ class BotCommands():
|
|||||||
'disabled': {}
|
'disabled': {}
|
||||||
}
|
}
|
||||||
self.module_files_parse()
|
self.module_files_parse()
|
||||||
|
self.nickrules()
|
||||||
for comtype in ['module', 'nickname', 'rule']:
|
for comtype in ['module', 'nickname', 'rule']:
|
||||||
logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
||||||
|
|
||||||
|
def nickrules(self):
|
||||||
|
for command in self.dict['commands']['rule'].keys():
|
||||||
|
if command.startswith("$nickname"):
|
||||||
|
command = command.split("$nickname")[-1]
|
||||||
|
if command not in self.dict['nickrules']:
|
||||||
|
self.dict['nickrules'].append(command)
|
||||||
|
|
||||||
def find_command_type(self, command):
|
def find_command_type(self, command):
|
||||||
for commandstype in self.dict['commands'].keys():
|
for commandstype in self.dict['commands'].keys():
|
||||||
if commandstype not in ['rule']:
|
if commandstype not in ['rule']:
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import sopel.module
|
|||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
import spicemanip
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.rule('(.*)')
|
@sopel.module.rule('(.*)')
|
||||||
def bot_command_rule(bot, trigger):
|
def bot_command_rule(bot, trigger):
|
||||||
@ -27,9 +29,25 @@ def bot_command_rule(bot, trigger):
|
|||||||
|
|
||||||
if str(message).lower().startswith(str(bot.nick).lower()):
|
if str(message).lower().startswith(str(bot.nick).lower()):
|
||||||
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname')
|
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname')
|
||||||
|
if str(trigger_command).startswith("?"):
|
||||||
|
return
|
||||||
|
fulltrigger = spicemanip.main(trigger_args, 0)
|
||||||
|
if fulltrigger in SpiceBot.commands.dict['nickrules']:
|
||||||
|
return
|
||||||
if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys():
|
if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys():
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module')
|
||||||
|
|
||||||
returnmessage = SpiceBot.botai.on_message(bot, trigger, message)
|
returnmessage = SpiceBot.botai.on_message(bot, trigger, message)
|
||||||
if returnmessage:
|
if returnmessage:
|
||||||
bot.osd(str(returnmessage))
|
bot.osd(str(returnmessage))
|
||||||
|
else:
|
||||||
|
closestmatches = SpiceBot.similar_list(bot, trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse')
|
||||||
|
if len(closestmatches):
|
||||||
|
closestmatches = spicemanip.main(closestmatches, "andlist")
|
||||||
|
bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
bot.osd("I don't know what you are asking me to do!")
|
||||||
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user