How to use a variable to act as @rule in a Sopel IRC bot module?

2015-12-22 Thread arresteddevlopment
Hi everyone. I'm working with the Sopel (previously Willie and before that, Jenni/Phenny) python IRC bot as I'd like to set up a trivia quiz for our IRC channel. With Sopel, the @rule decorator lets you set a string that the bot will listen out for and which triggers a corresponding function

Re: How to use a variable to act as @rule in a Sopel IRC bot module?

2015-12-22 Thread arresteddevlopment
Apologies for the terrible formatting, let me try that again: A: from sopel.module import commands, rule import random q_and_as = [('Why?', 'because'), ('Can I kick it?', 'nope')] @commands("quizme") def ask_q(bot, trigger): q = random.choice(q_and_as) bot.say(q[0])  @rule(q[1])