From f7cbd18f6e01f04ce8ad0fcc5974fb7167dfee17 Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 14 Mar 2019 07:30:17 -0400 Subject: [PATCH] added --list to .slur --- modules/slur.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/slur.py b/modules/slur.py index b2e3ce4..6430d2e 100644 --- a/modules/slur.py +++ b/modules/slur.py @@ -31,13 +31,23 @@ def slur(bot, trigger): -r, --race - specifies a particular race to pick on. -s, --slur - specifies a particular slur to pick. + -l, --list - prints a list of available races. """ parser = argparse.ArgumentParser() - parser.add_argument("-r", "--race", type=str) + parser.add_argument("-r", "--race", type=str, nargs='+') parser.add_argument("-s", "--slur", type=str) + parser.add_argument("-l", "--list", action="store_true") args = parser.parse_args(trigger.group[3:]) + if args.list: + races = bot.db.execute("SELECT DISTINCT race FROM slur").fetchall() + races = [race[0] for race in races] + races.sort() + bot.msg(", ".join(races)) + return + if args.race: + args.race = " ".join(args.race) slur = bot.db.execute( "SELECT * FROM `slur` WHERE `race` = ? COLLATE NOCASE " \ + "ORDER BY RANDOM() LIMIT 1", (args.race,)).fetchone()