From 3eaa6ded85c7a1403f8c5b657b3298edcad00c19 Mon Sep 17 00:00:00 2001 From: mpellicc Date: Fri, 26 Jan 2024 01:49:40 +0100 Subject: [PATCH] gitignore --- .gitignore | 5 ++++- README.md | 6 +++--- clean_wiki_data.py | 20 +++++++------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 8021ff8..59e2c08 100644 --- a/.gitignore +++ b/.gitignore @@ -163,4 +163,7 @@ cython_debug/ #.idea/ # IDEs -.vscode/ \ No newline at end of file +.vscode/ + +TODO.md +.python-version \ No newline at end of file diff --git a/README.md b/README.md index 3e49dfc..7ba551c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ To get started with Fanta Formazioni Reminder, follow these steps: Before running the bot, you'll need the following: -- Python 3.x installed on your system. +- Python 3.x installed on your system. The bot is developed in Python 3.11.4. - A Telegram account and a bot token obtained from the [BotFather](https://core.telegram.org/bots#botfather). ### Installation @@ -78,8 +78,8 @@ The bot provides various commands to interact with it. You can start a chat with - `/start`: Start a chat with the bot and get an introduction. - `/aggiungi_data`: Save a custom date to be reminded in the chat you used this command. -- `/prossima_scadenza`: Display the next deadline for setting up your team's lineup. -- `/annulla`: Cancel an ongoing conversation with the bot. +- `/prossima_scadenza`: Display the next deadline for setting up your team's lineup. +- `/annulla`: Cancel an ongoing conversation with the bot. - `/help`: Display a help message with available commands. Feel free to explore and customize the bot's functionality as per your requirements. diff --git a/clean_wiki_data.py b/clean_wiki_data.py index cdb35d7..5dbad85 100644 --- a/clean_wiki_data.py +++ b/clean_wiki_data.py @@ -13,34 +13,28 @@ CSV_PATH: Final = os.getenv("SERIE_A_CALENDAR_PATH") CSV_URL: Final = os.getenv("SERIE_A_CALENDAR_URL") + def download_csv(url, dest_path) -> None: response = requests.get(url) - with open(dest_path, 'wb') as file: + with open(dest_path, "wb") as file: file.write(response.content) + def get_cleaned_dates() -> List[datetime]: - # Download the CSV file download_csv(CSV_URL, CSV_PATH) - + # Read the data from the CSV file - with open(CSV_PATH, newline='', encoding='utf-8') as csvfile: + with open(CSV_PATH, newline="", encoding="utf-8") as csvfile: reader = csv.DictReader(csvfile) - + # Initialize a dictionary to store the earliest date for each round dates = {} - # Map month names to integers using a dictionary - months_mapping = { - "gen.": 1, "feb.": 2, "mar.": 3, "apr.": 4, "mag.": 5, "giu.": 6, - "lug.": 7, "ago.": 8, "set.": 9, "ott.": 10, "nov.": 11, "dic.": 12, - } - # Iterate through each row in the CSV file for row in reader: # Extract date and time from the CSV row date_str = row["Date"] - time_str = date_str.split()[-1] # Extract time from the end of the date string # Convert date string to datetime object date_obj = datetime.strptime(date_str, "%d/%m/%Y %H:%M") @@ -48,7 +42,7 @@ def get_cleaned_dates() -> List[datetime]: # Subtract 5 minutes from the datetime date_obj -= timedelta(minutes=5) - # Extract round number from the CSV row + # Extract round number from the CSV row round_number = int(row["Round Number"]) # Update the earliest date for the round if needed