diff --git a/plugins/choose.py b/plugins/choose.py new file mode 100644 index 0000000..be0a566 --- /dev/null +++ b/plugins/choose.py @@ -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))))