diff --git a/src/bot.py b/src/bot.py index fb0db34..7949a7e 100644 --- a/src/bot.py +++ b/src/bot.py @@ -169,10 +169,13 @@ class RcQueue: if db_wiki["wiki"] in current_domain["irc"].updated: # Priority wikis are the ones with IRC, if they get updated forcefully add them to queue current_domain["irc"].updated.remove(db_wiki["wiki"]) current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20), forced=True) + logger.debug("Updated in IRC so adding to queue.") continue elif all_wikis[db_wiki["wiki"]].last_check+settings["irc_overtime"] > time.time(): # if time went by and wiki should be updated now use default mechanics + logger.debug("Overtime so adding to queue.") pass else: # Continue without adding + logger.debug("No condition fulfilled so skipping.") continue if not db_wiki["ROWID"] < current_domain["last_rowid"]: current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20)) diff --git a/src/irc_feed.py b/src/irc_feed.py index 3f5b520..a9a22e4 100644 --- a/src/irc_feed.py +++ b/src/irc_feed.py @@ -7,12 +7,18 @@ logger = logging.getLogger("rcgcdw.irc_feed") class AioIRCCat(irc.client_aio.AioSimpleIRCClient): + def connect(self, *args, **kwargs): + super().connect(*args, **kwargs) + self.connection_details = (args, kwargs) + def __init__(self, targets, all_wikis): irc.client_aio.SimpleIRCClient.__init__(self) self.targets = targets self.updated = set() # Storage for edited wikis self.updated_discussions = set() self.wikis = all_wikis + self.connection.buffer_class.errors = "replace" # Ignore encoding errors + self.connection_details = None def on_welcome(self, connection, event): # Join IRC channels for channel in self.targets.values(): @@ -28,7 +34,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): c.nick(c.get_nickname() + "_") def on_disconnect(self, connection, event): - connection.reconnect() + self.connect(*self.connection_details[0], **self.connection_details[1]) # attempt to reconnect def parse_fandom_message(self, message: str): message = message.split("\x035*\x03") @@ -44,6 +50,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient): self.updated.add(full_url) logger.debug("New website appended to the list! {}".format(full_url)) + def parse_fandom_discussion(self, message: str): try: post = json.loads(message)