mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Added more debug + fixed disconnect logic and handling of encoding issues
This commit is contained in:
parent
8a1a61dbac
commit
23043934cd
|
@ -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
|
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["irc"].updated.remove(db_wiki["wiki"])
|
||||||
current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20), forced=True)
|
current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20), forced=True)
|
||||||
|
logger.debug("Updated in IRC so adding to queue.")
|
||||||
continue
|
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
|
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
|
pass
|
||||||
else: # Continue without adding
|
else: # Continue without adding
|
||||||
|
logger.debug("No condition fulfilled so skipping.")
|
||||||
continue
|
continue
|
||||||
if not db_wiki["ROWID"] < current_domain["last_rowid"]:
|
if not db_wiki["ROWID"] < current_domain["last_rowid"]:
|
||||||
current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20))
|
current_domain["query"].append(QueuedWiki(db_wiki["wiki"], 20))
|
||||||
|
|
|
@ -7,12 +7,18 @@ logger = logging.getLogger("rcgcdw.irc_feed")
|
||||||
|
|
||||||
|
|
||||||
class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
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):
|
def __init__(self, targets, all_wikis):
|
||||||
irc.client_aio.SimpleIRCClient.__init__(self)
|
irc.client_aio.SimpleIRCClient.__init__(self)
|
||||||
self.targets = targets
|
self.targets = targets
|
||||||
self.updated = set() # Storage for edited wikis
|
self.updated = set() # Storage for edited wikis
|
||||||
self.updated_discussions = set()
|
self.updated_discussions = set()
|
||||||
self.wikis = all_wikis
|
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
|
def on_welcome(self, connection, event): # Join IRC channels
|
||||||
for channel in self.targets.values():
|
for channel in self.targets.values():
|
||||||
|
@ -28,7 +34,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
||||||
c.nick(c.get_nickname() + "_")
|
c.nick(c.get_nickname() + "_")
|
||||||
|
|
||||||
def on_disconnect(self, connection, event):
|
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):
|
def parse_fandom_message(self, message: str):
|
||||||
message = message.split("\x035*\x03")
|
message = message.split("\x035*\x03")
|
||||||
|
@ -44,6 +50,7 @@ class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
||||||
self.updated.add(full_url)
|
self.updated.add(full_url)
|
||||||
logger.debug("New website appended to the list! {}".format(full_url))
|
logger.debug("New website appended to the list! {}".format(full_url))
|
||||||
|
|
||||||
|
|
||||||
def parse_fandom_discussion(self, message: str):
|
def parse_fandom_discussion(self, message: str):
|
||||||
try:
|
try:
|
||||||
post = json.loads(message)
|
post = json.loads(message)
|
||||||
|
|
Loading…
Reference in a new issue