mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -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]*$')
|
@sopel.module.rule(r'(?i)(hi|hello|hey),? $nickname[ \t]*$')
|
||||||
def bot_command_hello_a(bot, trigger):
|
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')
|
@sopel.module.nickname_commands('hello')
|
||||||
def bot_command_hello_b(bot, trigger):
|
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")
|
hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random")
|
||||||
punctuation = spicemanip.main(['', '!', '?'], "random")
|
punctuation = spicemanip.main(['', '!', '?'], "random")
|
||||||
bot.osd(hello + ' ' + trigger.nick + punctuation)
|
bot.osd(hello + ' ' + trigger.nick + punctuation)
|
||||||
|
|||||||
@ -109,8 +109,18 @@ def setup(bot):
|
|||||||
elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])):
|
elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])):
|
||||||
comtype = "rule"
|
comtype = "rule"
|
||||||
line = str(line).split("rule(")[-1]
|
line = str(line).split("rule(")[-1]
|
||||||
validcoms = [str("(" + line)]
|
line = str("(" + line)
|
||||||
validcomdict = {"comtype": comtype, "validcoms": validcoms}
|
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)
|
filelinelist.append(validcomdict)
|
||||||
|
|
||||||
if len(filelinelist):
|
if len(filelinelist):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user