Add choose plugin

This commit is contained in:
minerobber 2019-01-28 22:25:24 +00:00
parent f3220bee21
commit 5eb9031583
1 changed files with 24 additions and 0 deletions

24
plugins/choose.py Normal file
View File

@ -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))))