From 2e47ffa029374b311b7680beb903cd32c024fe79 Mon Sep 17 00:00:00 2001 From: Twentysix Date: Sun, 28 Feb 2016 18:54:58 +0100 Subject: [PATCH 1/3] hotfix for rollback --- red.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/red.py b/red.py index 84b0f696f..90d162ace 100644 --- a/red.py +++ b/red.py @@ -389,6 +389,15 @@ def check_configs(): with open(settings_path, "w") as f: f.write(json.dumps(settings)) + else: # Undoing the changes made by the broken pull request + data = load_settings() + if "default" in data: + data["ADMIN_ROLE"] = data["default"]["ADMIN_ROLE"] + data["MOD_ROLE"] = data["default"]["MOD_ROLE"] + del data["default"] + print("Rolling back settings to previous format...") + with open(settings_path, "w") as f: + f.write(json.dumps(data, indent=4,sort_keys=True,separators=(',',' : '))) cogs_s_path = "data/red/cogs.json" cogs = {} From c3bb4e18e9681efb11aaf3609779d3c3b7e76ab3 Mon Sep 17 00:00:00 2001 From: Twentysix Date: Sun, 28 Feb 2016 21:18:47 +0100 Subject: [PATCH 2/3] Delete past stream alerts after new one --- cogs/streams.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cogs/streams.py b/cogs/streams.py index 1717f5776..825f77526 100644 --- a/cogs/streams.py +++ b/cogs/streams.py @@ -191,6 +191,9 @@ class Streams: async def stream_checker(self): CHECK_DELAY = 60 + old_alerts = [] + last_twitch_alert = None + last_hitbox_alert = None while "Streams" in self.bot.cogs: old = (deepcopy(self.twitch_streams), deepcopy(self.hitbox_streams)) @@ -201,7 +204,9 @@ class Streams: stream["ALREADY_ONLINE"] = True for channel in stream["CHANNELS"]: if self.bot.get_channel(channel): - await self.bot.send_message(self.bot.get_channel(channel), "http://www.twitch.tv/{} is online!".format(stream["NAME"])) + if last_twitch_alert: + old_alerts.append(last_twitch_alert) + last_twitch_alert = await self.bot.send_message(self.bot.get_channel(channel), "http://www.twitch.tv/{} is online!".format(stream["NAME"])) else: if stream["ALREADY_ONLINE"] and not online: stream["ALREADY_ONLINE"] = False await asyncio.sleep(0.5) @@ -212,7 +217,9 @@ class Streams: stream["ALREADY_ONLINE"] = True for channel in stream["CHANNELS"]: if self.bot.get_channel(channel): - await self.bot.send_message(self.bot.get_channel(channel), "http://www.hitbox.tv/{} is online!".format(stream["NAME"])) + if last_hitbox_alert: + old_alerts.append(last_hitbox_alert) + last_hitbox_alert = await self.bot.send_message(self.bot.get_channel(channel), "http://www.hitbox.tv/{} is online!".format(stream["NAME"])) else: if stream["ALREADY_ONLINE"] and not online: stream["ALREADY_ONLINE"] = False await asyncio.sleep(0.5) @@ -220,6 +227,10 @@ class Streams: if old != (self.twitch_streams, self.hitbox_streams): fileIO("data/streams/twitch.json", "save", self.twitch_streams) fileIO("data/streams/hitbox.json", "save", self.hitbox_streams) + + for msg in old_alerts: + await self.bot.delete_message(msg) + old_alerts = [] await asyncio.sleep(CHECK_DELAY) From 76f8543888480d5c6813e0d0efce9a34d8f34c9f Mon Sep 17 00:00:00 2001 From: Twentysix Date: Sun, 28 Feb 2016 21:38:49 +0100 Subject: [PATCH 3/3] Small fix to stream alert --- cogs/streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/streams.py b/cogs/streams.py index 825f77526..787462850 100644 --- a/cogs/streams.py +++ b/cogs/streams.py @@ -187,7 +187,7 @@ class Streams: return None except: return "error" - return False + return "error" async def stream_checker(self): CHECK_DELAY = 60