From 406ac11e976576a0b92887b4fb785891b677d6a7 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 21 Aug 2018 12:46:34 +0200 Subject: [PATCH 1/5] Fixed delete icon --- settings.json.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.json.example b/settings.json.example index c3611ec..e8c58d4 100644 --- a/settings.json.example +++ b/settings.json.example @@ -44,11 +44,11 @@ "color":null }, "delete/delete":{ - "icon":"https://i.imgur.com/C4H84Kp.jpg", + "icon":"https://i.imgur.com/BU77GD3.png", "color":1 }, "delete/delete_redir":{ - "icon":"https://i.imgur.com/C4H84Kp.jpg", + "icon":"https://i.imgur.com/BU77GD3.png", "color":1 }, "delete/restore":{ From 51d89877565ca6adb5750c81f179f51a8dadb8f1 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 21 Aug 2018 16:14:32 +0200 Subject: [PATCH 2/5] Added more safeguards to prevent sending again the same messages --- rcgcdw.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rcgcdw.py b/rcgcdw.py index a43f692..1bc44c3 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -603,6 +603,7 @@ class recent_changes_class(object): groups = {} unsent_messages = [] streak = -1 + last_datetime = datetime.datetime.fromisoformat("1999-01-01T00:00:00") if settings["limitrefetch"] != -1: with open("lastchange.txt", "r") as record: file_content = record.read().strip() @@ -673,13 +674,17 @@ class recent_changes_class(object): self.streak = -1 send(_("Connection to {wiki} seems to be stable now.").format(wiki=settings["wikiname"]), _("Connection status"), settings["avatars"]["connection_restored"]) for change in changes: - if change["rcid"] in self.ids: + if change["rcid"] in self.ids or change["rcid"] < self.recent_id or datetime.datetime.fromisoformat(change["timestamp"][0:19]) < self.last_datetime: + logging.debug("Change ({}) is in ids or is lower than recent_id {}".format(change["rcid"]), self.recent_id) continue + logging.debug(self.ids) + logging.debug(self.recent_id) self.add_cache(change) if clean and not (self.recent_id == 0 and change["rcid"] > self.file_id): logging.debug("Rejected {val}".format(val=change["rcid"])) continue first_pass(change) + self.last_datetime = change["timestamp"] return change["rcid"] def safe_request(self, url): From 01b8be0a627723eca30efa014184242af9df4d95 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 21 Aug 2018 17:05:30 +0200 Subject: [PATCH 3/5] Date time --- rcgcdw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index 1bc44c3..cabefad 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -675,7 +675,7 @@ class recent_changes_class(object): send(_("Connection to {wiki} seems to be stable now.").format(wiki=settings["wikiname"]), _("Connection status"), settings["avatars"]["connection_restored"]) for change in changes: if change["rcid"] in self.ids or change["rcid"] < self.recent_id or datetime.datetime.fromisoformat(change["timestamp"][0:19]) < self.last_datetime: - logging.debug("Change ({}) is in ids or is lower than recent_id {}".format(change["rcid"]), self.recent_id) + logging.debug("Change ({}) is in ids or is lower than recent_id {} or date {} is earlier than {}".format(change["rcid"], self.recent_id, change["timestamp"], self.last_datetime)) continue logging.debug(self.ids) logging.debug(self.recent_id) @@ -684,7 +684,7 @@ class recent_changes_class(object): logging.debug("Rejected {val}".format(val=change["rcid"])) continue first_pass(change) - self.last_datetime = change["timestamp"] + self.last_datetime = datetime.datetime.fromisoformat(change["timestamp"][0:19]) return change["rcid"] def safe_request(self, url): From 88f9840821f60170e1bf4393e9aca157a0127729 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 21 Aug 2018 17:16:21 +0200 Subject: [PATCH 4/5] Sadly, cannot use this function due to incompatibility --- rcgcdw.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index cabefad..aecad77 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -603,7 +603,7 @@ class recent_changes_class(object): groups = {} unsent_messages = [] streak = -1 - last_datetime = datetime.datetime.fromisoformat("1999-01-01T00:00:00") + #last_datetime = datetime.datetime.fromisoformat("1999-01-01T00:00:00") if settings["limitrefetch"] != -1: with open("lastchange.txt", "r") as record: file_content = record.read().strip() @@ -674,8 +674,8 @@ class recent_changes_class(object): self.streak = -1 send(_("Connection to {wiki} seems to be stable now.").format(wiki=settings["wikiname"]), _("Connection status"), settings["avatars"]["connection_restored"]) for change in changes: - if change["rcid"] in self.ids or change["rcid"] < self.recent_id or datetime.datetime.fromisoformat(change["timestamp"][0:19]) < self.last_datetime: - logging.debug("Change ({}) is in ids or is lower than recent_id {} or date {} is earlier than {}".format(change["rcid"], self.recent_id, change["timestamp"], self.last_datetime)) + if change["rcid"] in self.ids or change["rcid"] < self.recent_id: + logging.debug("Change ({}) is in ids or is lower than recent_id {}".format(change["rcid"], self.recent_id)) continue logging.debug(self.ids) logging.debug(self.recent_id) @@ -684,7 +684,7 @@ class recent_changes_class(object): logging.debug("Rejected {val}".format(val=change["rcid"])) continue first_pass(change) - self.last_datetime = datetime.datetime.fromisoformat(change["timestamp"][0:19]) + #self.last_datetime = datetime.datetime.fromisoformat(change["timestamp"][0:19]) return change["rcid"] def safe_request(self, url): From bf7d62507746e2fd1315db95f6126fb8baf83fa6 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 21 Aug 2018 18:38:05 +0200 Subject: [PATCH 5/5] Bigger limit to the cache --- rcgcdw.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rcgcdw.py b/rcgcdw.py index aecad77..079ab1a 100644 --- a/rcgcdw.py +++ b/rcgcdw.py @@ -619,7 +619,7 @@ class recent_changes_class(object): def add_cache(self, change): self.ids.append(change["rcid"]) #self.recent_id = change["rcid"] - if len(self.ids) > settings["limit"]+5: + if len(self.ids) > settings["limitrefetch"]+5: self.ids.pop(0) def fetch(self, amount=settings["limit"]): @@ -684,7 +684,6 @@ class recent_changes_class(object): logging.debug("Rejected {val}".format(val=change["rcid"])) continue first_pass(change) - #self.last_datetime = datetime.datetime.fromisoformat(change["timestamp"][0:19]) return change["rcid"] def safe_request(self, url):