better handling

This commit is contained in:
deathbybandaid 2019-06-04 11:46:26 -04:00
parent 28f9015411
commit 8fec26ddee
2 changed files with 15 additions and 3 deletions

View File

@ -89,13 +89,14 @@ class SpiceBot_AI():
return aiml_response
def bot_message_precipher(self, bot, trigger, message):
message = message.upper()
puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"}
for puctuation in puct_dict.keys():
message = message.replace(puctuation, puct_dict[puctuation])
for botitem in ["nick"]:
message = message.replace(str(eval("bot." + botitem)), "bot" + botitem)
message = message.replace(str(eval("bot." + botitem)).upper(), str("bot" + botitem).upper())
for triggeritem in ["nick", "sender"]:
message = message.replace(str(eval("trigger." + triggeritem)), "trigger" + triggeritem)
message = message.replace(str(eval("trigger." + triggeritem)).upper(), str("trigger" + triggeritem).upper())
return message
def bot_message_decipher(self, bot, trigger, aiml_response):

View File

@ -6,9 +6,11 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
import spicemanip
@sopel.module.rule('(.*)')
def bot_command_nick(bot, trigger):
def bot_command_rule(bot, trigger):
# TODO add config limits
# but still allow in privmsg
@ -25,6 +27,15 @@ def bot_command_nick(bot, trigger):
if str(message).startswith(tuple(bot.config.core.prefix_list)):
return
if str(message).lower().startswith(str(bot.nick).lower()):
trigger_args, trigger_command = SpiceBot.prerun.trigger_args(trigger.args[1], 'nickname')
if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys():
return
trigger_args.insert(0, bot.nick)
message = spicemanip.main(trigger_args, 0).lower()
returnmessage = SpiceBot.botai.on_message(bot, trigger, message)
if returnmessage:
bot.osd(str(returnmessage))