diff --git a/modules/watcher.py b/modules/watcher.py index 820618a..315c2ca 100755 --- a/modules/watcher.py +++ b/modules/watcher.py @@ -13,7 +13,8 @@ def setup(bot): """ Establishes the bot's dictionary of watched threads. """ - bot.memory["watcher"] = {} + if not bot.memory.get("watcher"): + bot.memory["watcher"] = {} con = bot.db.connect() cur = con.cursor() @@ -30,6 +31,8 @@ def setup(bot): con.close() else: for thread in watching: + if get_thread_url(thread[0]) in bot.memory["watcher"].keys(): + continue t = WatcherThread(bot, thread[0], thread[1], thread[2], thread[3], thread[4]) t.start() @@ -167,7 +170,7 @@ class WatcherThread(threading.Thread): if res.status_code == 404: msg = "[\x0304Watcher\x03] Thread deleted: " \ + f"\x0307{get_thread_url(self.api_url)}" - self.bot.say(msg, channel) + self.bot.say(msg, self.channel) self.stop.set() continue @@ -178,7 +181,7 @@ class WatcherThread(threading.Thread): if thread["posts"][0].get("closed"): msg = "[\x0304Watcher\x03] Thread closed: " \ + f"\x0307{get_thread_url(self.api_url)}" - self.bot.say(msg, channel) + self.bot.say(msg, self.channel) self.stop.set() continue @@ -187,5 +190,5 @@ class WatcherThread(threading.Thread): self.last_post = new_last_post msg = "[\x0304Watcher\x03] New post from \x0308" \ + f"{self.name}\x03 in \x0307{get_thread_url(self.api_url)}" - self.bot.say(msg, channel) + self.bot.say(msg, self.channel)