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