mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fix always broken comment
This commit is contained in:
parent
7367973ea7
commit
f5050a87ae
|
@ -34,6 +34,7 @@ for wiki in db_cursor.execute('SELECT DISTINCT wiki FROM rcgcdw'):
|
||||||
|
|
||||||
|
|
||||||
def calculate_delay() -> float:
|
def calculate_delay() -> float:
|
||||||
|
"""Calculate the delay between fetching each wiki to avoid rate limits"""
|
||||||
min_delay = 60 / settings["max_requests_per_minute"]
|
min_delay = 60 / settings["max_requests_per_minute"]
|
||||||
if (len(all_wikis) * min_delay) < settings["minimal_cooldown_per_wiki_in_sec"]:
|
if (len(all_wikis) * min_delay) < settings["minimal_cooldown_per_wiki_in_sec"]:
|
||||||
return settings["minimal_cooldown_per_wiki_in_sec"] / len(all_wikis)
|
return settings["minimal_cooldown_per_wiki_in_sec"] / len(all_wikis)
|
||||||
|
@ -42,6 +43,10 @@ def calculate_delay() -> float:
|
||||||
|
|
||||||
|
|
||||||
def generate_targets(wiki_url: str) -> defaultdict:
|
def generate_targets(wiki_url: str) -> defaultdict:
|
||||||
|
"""To minimize the amount of requests, we generate a list of language/display mode combinations to create messages for
|
||||||
|
this way we can send the same message to multiple webhooks which have the same wiki and settings without doing another
|
||||||
|
request to the wiki just to duplicate the message.
|
||||||
|
"""
|
||||||
combinations = defaultdict(list)
|
combinations = defaultdict(list)
|
||||||
for webhook in db_cursor.execute('SELECT webhook, lang, display FROM rcgcdw WHERE wiki = ?', (wiki_url,)):
|
for webhook in db_cursor.execute('SELECT webhook, lang, display FROM rcgcdw WHERE wiki = ?', (wiki_url,)):
|
||||||
combination = (webhook["lang"], webhook["display"])
|
combination = (webhook["lang"], webhook["display"])
|
||||||
|
@ -133,7 +138,7 @@ def global_exception_handler(loop, context):
|
||||||
"""Global exception handler for asyncio, lets us know when something crashes"""
|
"""Global exception handler for asyncio, lets us know when something crashes"""
|
||||||
msg = context.get("exception", context["message"])
|
msg = context.get("exception", context["message"])
|
||||||
logger.error("Global exception handler:" + msg)
|
logger.error("Global exception handler:" + msg)
|
||||||
|
requests.post("https://discord.com/api/webhooks/"+settings["monitoring_webhook"], data={"content": "test"})
|
||||||
|
|
||||||
async def main_loop():
|
async def main_loop():
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
|
@ -59,8 +59,8 @@ def parse_link(domain: str, to_parse: str) -> str:
|
||||||
"""Because I have strange issues using the LinkParser class myself, this is a helper function
|
"""Because I have strange issues using the LinkParser class myself, this is a helper function
|
||||||
to utilize the LinkParser properly"""
|
to utilize the LinkParser properly"""
|
||||||
LinkParse.WIKI_JUST_DOMAIN = domain
|
LinkParse.WIKI_JUST_DOMAIN = domain
|
||||||
LinkParse.feed(to_parse)
|
|
||||||
LinkParse.new_string = ""
|
LinkParse.new_string = ""
|
||||||
|
LinkParse.feed(to_parse)
|
||||||
LinkParse.recent_href = ""
|
LinkParse.recent_href = ""
|
||||||
return LinkParse.new_string
|
return LinkParse.new_string
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue