From 0c45287ae68871cd7438b724e0a9b2cc04d8fc2f Mon Sep 17 00:00:00 2001 From: jenz Date: Mon, 20 Jun 2022 21:01:10 +0200 Subject: [PATCH] changed posting events slightly to be bold, updated pipeline to not accidentally delete wrong event, updated scraper to skip leader field but also handle if its not present at all --- event_notification/python/discord_event.py | 2 +- event_notification/python/pipelines.py | 3 ++- event_notification/python/scrape_event.py | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/event_notification/python/discord_event.py b/event_notification/python/discord_event.py index 13c791a7..c1924887 100644 --- a/event_notification/python/discord_event.py +++ b/event_notification/python/discord_event.py @@ -106,7 +106,7 @@ async def discord_task(): """ cur.execute(sql_statement, [event_title]) try: - event_msg = f"NEW EVENT POSTED:\nTitle: {event_title}\nServer: {event_server}\nMaps: {event_maps}\nDate: {event_date}\nTime: {event_time}\nRewards: {event_reward}\nURL: {event_url}\n\n" + event_msg = f"**- New Event Posted! -**\nTitle: {event_title}\nServer: {event_server}\nMaps: {event_maps}\nDate: {event_date}\nTime: {event_time}\nRewards: {event_reward}\nURL: {event_url}\n\n" for r in client.get_all_channels(): if r.name == 'events': await r.send(event_msg) diff --git a/event_notification/python/pipelines.py b/event_notification/python/pipelines.py index 5efcd8de..0d47a99c 100644 --- a/event_notification/python/pipelines.py +++ b/event_notification/python/pipelines.py @@ -16,9 +16,10 @@ class contentPipeline: if res is None: sql_statement = f""" delete from unloze_event.event - where event_server like '%{item['event_server'].split(":270")[1]}%' + where event_server like '%{item['event_server'].split(":27")[1]}%' """ #very cheap way of replacing rows + print("deleting thread: ", sql_statement) cur.execute(sql_statement) sql_statement = f""" insert into unloze_event.event diff --git a/event_notification/python/scrape_event.py b/event_notification/python/scrape_event.py index 57333583..0593b5f6 100644 --- a/event_notification/python/scrape_event.py +++ b/event_notification/python/scrape_event.py @@ -60,8 +60,11 @@ class unloze_spider(scrapy.Spider): if index == 2: event_date = r if index == 3: - event_time = r[:-1] - if index == 4: + event_time = r + #just skipping the leader part on ze + if index == 4 and '27015' not in event_server: + event_reward = r + if index == 5 and '27015' in event_server: event_reward = r index += 1 event_maps = ""