mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
Attempt $nickname detection for rules
This commit is contained in:
parent
3387259096
commit
ca18e6a97b
@ -12,15 +12,13 @@ from sopel_modules.SpiceBot_Events.System import bot_events_check
|
||||
|
||||
@sopel.module.rule(r'(?i)(hi|hello|hey),? $nickname[ \t]*$')
|
||||
def bot_command_hello_a(bot, trigger):
|
||||
bot_command_hello(bot, trigger)
|
||||
hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random")
|
||||
punctuation = spicemanip.main(['', '!', '?'], "random")
|
||||
bot.osd(hello + ' ' + trigger.nick + punctuation)
|
||||
|
||||
|
||||
@sopel.module.nickname_commands('hello')
|
||||
def bot_command_hello_b(bot, trigger):
|
||||
bot_command_hello(bot, trigger)
|
||||
|
||||
|
||||
def bot_command_hello(bot, trigger):
|
||||
hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random")
|
||||
punctuation = spicemanip.main(['', '!', '?'], "random")
|
||||
bot.osd(hello + ' ' + trigger.nick + punctuation)
|
||||
|
||||
@ -109,8 +109,18 @@ def setup(bot):
|
||||
elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])):
|
||||
comtype = "rule"
|
||||
line = str(line).split("rule(")[-1]
|
||||
validcoms = [str("(" + line)]
|
||||
validcomdict = {"comtype": comtype, "validcoms": validcoms}
|
||||
line = str("(" + line)
|
||||
validcoms = eval(str(line))
|
||||
if isinstance(validcoms, tuple):
|
||||
validcoms = list(validcoms)
|
||||
else:
|
||||
validcoms = [validcoms]
|
||||
for validcom in validcoms:
|
||||
if validcom.startswith("$nickname"):
|
||||
comtype = "nickname"
|
||||
else:
|
||||
comtype = "rule"
|
||||
validcomdict = {"comtype": comtype, "validcoms": [validcom]}
|
||||
filelinelist.append(validcomdict)
|
||||
|
||||
if len(filelinelist):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user