From 58f3cce7d09e9e485ba37502a09d77fa94150d3b Mon Sep 17 00:00:00 2001 From: iou1name Date: Wed, 28 Mar 2018 23:03:06 -0400 Subject: [PATCH] some light housekeeping, reworking grog.py, renamed rundown() correctly --- README.md | 2 +- bot.py | 2 +- modules/grog.py | 28 ++++++++++++++-------------- modules/rundown.py | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 05001e5..8914c02 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ NIGGER DICKS 2: Electric Boogaloo It's like Sopel, except rewritten from scratch using Twisted as a base and over half the features ripped out. -Dependencies: `twisted, python-dateutil, wolfram, requests, bs4, pyenchant` +Dependencies: `twisted, python-dateutil, requests, bs4, wolfram, pyenchant` TODO: Fix the movie table diff --git a/bot.py b/bot.py index d45a8aa..b7f5890 100755 --- a/bot.py +++ b/bot.py @@ -72,7 +72,7 @@ class Fulvia(irc.IRCClient): self._commands = {} """ - A dictionary containingv all commands to look for and the name + A dictionary containing all commands to look for and the name of the function they call. """ diff --git a/modules/grog.py b/modules/grog.py index 99fce38..721212d 100755 --- a/modules/grog.py +++ b/modules/grog.py @@ -10,18 +10,18 @@ from module import commands @commands("grog") def grog(bot, trigger): """ - Picks a random status effect from Grog of Substantial Whimsy effect. + Prints a status effect from Grog of Substantial Whimsy effect. If an + index is not given, a random one is chosen. """ - path = os.path.join(bot.config["core"].get("homedir"), "static", "grog.txt") - with open(path, "r") as file: - data = file.read().split("\n") - num = 0 - if trigger.group(2): - try: - num = int(trigger.group(2)) - 1 - except: - pass - if num and num < len(data): - bot.say(data[num]) - else: - bot.say(random.choice(data)) + with open(os.path.join(bot.static, "grog.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.say(data[num]) diff --git a/modules/rundown.py b/modules/rundown.py index 3018620..aea7803 100755 --- a/modules/rundown.py +++ b/modules/rundown.py @@ -9,7 +9,7 @@ from module import commands, example @commands("rundown") @example(".rundown") -def grog(bot, trigger): +def rundown(bot, trigger): """ Provides rundown on demand. """