From 33077575bd8f80cfe6280e58db8fb9110cdbda25 Mon Sep 17 00:00:00 2001 From: urlbot Date: Sun, 18 Oct 2015 19:49:44 +0200 Subject: [PATCH] add 'choose' plugin --- plugins.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins.py b/plugins.py index 4cb79d0..f029c5d 100644 --- a/plugins.py +++ b/plugins.py @@ -377,6 +377,25 @@ def command_dice(argv, **args): 'msg': msg } +@pluginfunction('choose', 'chooses randomly between arguments', ptypes_COMMAND, ratelimit_class=RATE_INTERACTIVE) +def command_choose(argv, **args): + if 'choose' != argv[0]: + return + + alternatives = argv[1:] + + if 2 > len(alternatives): + return { + 'msg': '%s: choosing between one or less things is pointless' % args['reply_user'] + } + + choice = random.choice(alternatives) + + log.plugin('sent random choice') + return { + 'msg': '%s: I prefer %s!' % (args['reply_user'], choice) + } + @pluginfunction('uptime', 'prints uptime', ptypes_COMMAND) def command_uptime(argv, **args): if 'uptime' != argv[0]: