From f3996592314a1b4f79e8be1764dab0ddeb3e5e82 Mon Sep 17 00:00:00 2001 From: iou1name Date: Sat, 9 Jun 2018 01:07:40 -0400 Subject: [PATCH] added net libram list to grog.py --- modules/grog.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/grog.py b/modules/grog.py index 9084236..17dc0a5 100755 --- a/modules/grog.py +++ b/modules/grog.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """ Selects a random Grog of Substantial Whimsy effect. +Also does stuff from the Net Libram of Random Magic Effects. """ import os import random @@ -25,3 +26,23 @@ def grog(bot, trigger): if num >= len(data)-1: num = len(data)-1 bot.msg(data[num]) + + +@commands("magic") +def magic(bot, trigger): + """ + Prints a magic effect from the Net Libram of Random Magic Effects. If an + index is not given, a random one is chosen. + """ + with open(os.path.join(bot.static, "netlibram.txt"), "r") as file: + data = file.read().splitlines() + num = None + try: + num = int(trigger.group(2)) - 1 + except: + pass + if num == None: + num = random.randint(0, len(data)-1) + if num >= len(data)-1: + num = len(data)-1 + bot.msg(data[num]) \ No newline at end of file