mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Added updates
This commit is contained in:
parent
4025f15e1a
commit
e1aeaaaaba
|
@ -18,6 +18,7 @@ from src.queue_handler import DBHandler
|
|||
from src.wiki import Wiki, process_cats, process_mwmsgs, essential_info, essential_feeds
|
||||
from src.discord import DiscordMessage, generic_msg_sender_exception_logger, stack_message_list
|
||||
from src.wiki_ratelimiter import RateLimiter
|
||||
from src.irc_feed import AioIRCCat
|
||||
|
||||
|
||||
logging.config.dictConfig(settings["logging"])
|
||||
|
@ -64,6 +65,11 @@ class RcQueue:
|
|||
async def start_group(self, group, initial_wikis):
|
||||
"""Starts a task for given domain group"""
|
||||
if group not in self.domain_list:
|
||||
if group in settings["irc_servers"]:
|
||||
irc_connection = AioIRCCat(settings["irc_servers"]["group"]["irc_channel_mapping"], all_wikis)
|
||||
irc_connection.connect(settings["irc_servers"][group]["irc_host"], settings["irc_servers"][group]["irc_port"], "RcGcDb")
|
||||
else:
|
||||
irc_connection = None
|
||||
self.domain_list[group] = {"task": asyncio.create_task(scan_group(group)), "last_rowid": 0, "query": LimitedList(initial_wikis), "rate_limiter": RateLimiter()}
|
||||
logger.debug(self.domain_list[group])
|
||||
else:
|
||||
|
|
47
src/irc_feed.py
Normal file
47
src/irc_feed.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import irc.client_aio
|
||||
from urllib.parse import urlparse, quote
|
||||
|
||||
class AioIRCCat(irc.client_aio.AioSimpleIRCClient):
|
||||
def __init__(self, targets, all_wikis):
|
||||
irc.client.SimpleIRCClient.__init__(self)
|
||||
self.targets = targets
|
||||
self.updated = [] # Storage for edited wikis
|
||||
self.wikis = all_wikis
|
||||
|
||||
def on_welcome(self, connection, event): # Join IRC channels
|
||||
for channel in self.targets.values():
|
||||
connection.join(channel)
|
||||
|
||||
def on_pubmsg(self, channel, event):
|
||||
|
||||
|
||||
def on_nicknameinuse(self, c, e):
|
||||
c.nick(c.get_nickname() + "_")
|
||||
|
||||
async def parse_fandom_message(self, message):
|
||||
raw_msg = message
|
||||
message = message.split("\x035*\x03")
|
||||
try:
|
||||
user = message[1][4:].strip().strip(chr(3))
|
||||
except IndexError:
|
||||
return
|
||||
# print(asyncio.all_tasks())
|
||||
half = message[0].find("\x0302http")
|
||||
if half == -1:
|
||||
return
|
||||
message = message[0][half + 3:].strip()
|
||||
# print(message)
|
||||
url = urlparse(message)
|
||||
full_url = url.netloc + recognize_langs(url.path)
|
||||
if full_url in self.wikis:
|
||||
self.updated.append(full_url)
|
||||
|
||||
def recognize_langs(path):
|
||||
lang = ""
|
||||
new_path = path.split("/")
|
||||
if len(new_path)>2:
|
||||
if new_path[1] != "wiki":
|
||||
lang = "/"+new_path[1]
|
||||
return lang
|
||||
|
||||
|
Loading…
Reference in a new issue