From 382b3ce1797baff4cd61e62b91da854a8c2ad721 Mon Sep 17 00:00:00 2001 From: iou1name Date: Wed, 26 Feb 2020 11:33:50 -0500 Subject: [PATCH] add ship quirks command --- modules/grog.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/grog.py b/modules/grog.py index 97f5fb8..65ce1b6 100755 --- a/modules/grog.py +++ b/modules/grog.py @@ -46,3 +46,22 @@ def magic(bot, trigger): if num >= len(data)-1: num = len(data)-1 bot.msg(data[num]) + + +@commands("ship") +def magic(bot, trigger): + """ + Prints a ship quirk. If an index is not given, a random one is chosen. + """ + with open(os.path.join(bot.static, "ship_quirks.txt"), "r") as file: + data = file.read().splitlines() + num = None + try: + num = int(trigger.args[1]) - 1 + except (IndexError, ValueError): + pass + if num == None: + num = random.randint(0, len(data)-1) + if num >= len(data)-1: + num = len(data)-1 + bot.msg(data[num])