Add choose plugin
This commit is contained in:
parent
f3220bee21
commit
5eb9031583
|
@ -0,0 +1,24 @@
|
|||
import plugin, random
|
||||
|
||||
RNG = random.SystemRandom()
|
||||
|
||||
RESPONSES = ["I dunno, I think I'll go with \"{}\".","Hmm, it's a hard choice, but \"{}\".","Hmm... \"{}\". Hands down."]
|
||||
|
||||
@plugin.command("choose")
|
||||
def choose(bot,channel,nick,*choices_raw):
|
||||
choices = []
|
||||
s = ""
|
||||
quote = False
|
||||
for choice in choices_raw:
|
||||
if quote:
|
||||
s+=" "+choice
|
||||
if choice.endswith('"'):
|
||||
quote = False
|
||||
choices.append(s.strip('"'))
|
||||
s = ""
|
||||
elif choice.startswith('"'):
|
||||
quote = True
|
||||
s+=choice
|
||||
else:
|
||||
choices.append(choice)
|
||||
bot.say(channel,"{}: {}".format(nick,RNG.choice(RESPONSES).format(RNG.choice(choices))))
|
Loading…
Reference in New Issue