diff --git a/.github/workflows/telegram-bot.yml b/.github/workflows/telegram-bot.yml index f08d73a5..671b3fd3 100644 --- a/.github/workflows/telegram-bot.yml +++ b/.github/workflows/telegram-bot.yml @@ -15,13 +15,17 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10"] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.x uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: ${{ matrix.python-version }} - name: Install dependencies for requirements and testing run: | python -m pip install --upgrade pip diff --git a/.gitignore b/.gitignore index 70692c1f..977fbb58 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,4 @@ pydrive/* .vscode .idea data/json/subjs.json -.DS_store +**/.DS_Store diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e77d8464..14bd70d8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -24,4 +24,5 @@ This project is made possible thanks to the contributions of: - [Paolo Rabbito](https://github.com/IlRabbino) - [Andrea Maugeri](https://github.com/v0lp3) - [Simone Costanzo](https://github.com/scraccio) -- [Salvo Polizzi](https://github.com/salvo-polizzi) \ No newline at end of file +- [Salvo Polizzi](https://github.com/salvo-polizzi) +- [Andrei](https://github.com/Picred) diff --git a/README.md b/README.md index 69b7aa7d..a123d38f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ pip3 install -r requirements.txt version: "2" services: dmibot: - image: ghcr.io/unict-dmi/telegram-dmi-bot + image: ghcr.io/unict-dmi/telegram-dmi-bot:master container_name: dmibot volumes: - :/dmibot/config/settings.yaml @@ -62,7 +62,7 @@ services: ### docker cli ```bash -docker run -v :/dmibot/config/settings.yaml -v :/dmibot/data/DMI_DB.db -v :/dmibot/config/drive_credentials.json -t unictdmi/dmibot +docker run -v :/dmibot/config/settings.yaml -v :/dmibot/data/DMI_DB.db -v :/dmibot/config/drive_credentials.json -t ghcr.io/unict-dmi/telegram-dmi-bot:master ``` ### Parameter diff --git a/config/settings.yaml.dist b/config/settings.yaml.dist index f285ce24..e7212e59 100755 --- a/config/settings.yaml.dist +++ b/config/settings.yaml.dist @@ -35,3 +35,9 @@ test: token: '' representatives_group: '' dev_group_chatid: '' + +lectures: + href_token: "sites/default" + dmi_link: "https://web.dmi.unict.it/" + file_orario_path: "./data/Orario.pdf" + expire_time: 86400 diff --git a/data/markdown/aule_studio.md b/data/markdown/aule_studio.md new file mode 100644 index 00000000..205283df --- /dev/null +++ b/data/markdown/aule_studio.md @@ -0,0 +1,3 @@ +Aula Studio: principale | Lunedì - Venerdì 08.00 - 19.00 | Sabato 09.00 - 13.00 +Aula Studio: Jonshon | Lunedì - Venerdì 08.00 - 19.00 | Sabato 09.00 - 13.00 +Aula Studio: Laboratorio 145 | Lunedì - Venerdì 08.00 - 19.00 diff --git a/data/markdown/informatica_link.md b/data/markdown/informatica_link.md new file mode 100644 index 00000000..d8e1d227 --- /dev/null +++ b/data/markdown/informatica_link.md @@ -0,0 +1 @@ +https://web.dmi.unict.it/ \ No newline at end of file diff --git a/data/markdown/lezioni_link.md b/data/markdown/lezioni_link.md index e236352c..014d4253 100644 --- a/data/markdown/lezioni_link.md +++ b/data/markdown/lezioni_link.md @@ -1,4 +1,4 @@ -L-31:http://web.dmi.unict.it/corsi/l-31/orario-lezioni -L-35:http://web.dmi.unict.it/corsi/l-35/orario-lezioni -LM-18:http://web.dmi.unict.it/corsi/lm-18/orario-lezioni -LM-40:http://web.dmi.unict.it/corsi/lm-40/orario-lezioni \ No newline at end of file +L-31:https://web.dmi.unict.it/corsi/l-31/orario-delle-lezioni +L-35:http://web.dmi.unict.it/corsi/l-35/orario-delle-lezioni +LM-18:http://web.dmi.unict.it/corsi/lm-18/orario-delle-lezioni +LM-40:http://web.dmi.unict.it/corsi/lm-40/orario-delle-lezioni \ No newline at end of file diff --git a/data/markdown/rappresentanti_dmi.md b/data/markdown/rappresentanti_dmi.md index 060436e0..2e6a7d2c 100644 --- a/data/markdown/rappresentanti_dmi.md +++ b/data/markdown/rappresentanti_dmi.md @@ -1,12 +1,12 @@ -Campo Filippo - @filippocampo98 -Carnemolla Davide - @Herbrant -Cascino Andrea - @Mag1candry +Curto Sofia - @Sofia\_Curto +Frasca Valentina - @valentina\_frasca +Minissale Giuseppe Virgilio - @pepp\_00 +Spina Simone - @simonze0 Cigna Gaia - @GaiaCigna -Cocuzza Daniele - @danielecocuzza +Tragna Agnese +Russo Miriana - @Miryrusso03 +Russo Mirko - @altair\_mr +D'Anna Kamil - @Heavenly0000 +Sorbello Angelica - @ange\_l\_1c4 Fragapane Leonardo - @leofragap06 -Gibilterra Martin - @w8floosh -Ippolito Simone -Minissale Giuseppe Virgilio - @Pepp\_00 -Pistorio Anna - @annapistorio -Seminara Luigi - @Gigii\_G -Tilotta Fabio - @fatilo422 +La Rocca Lorenzo - @lorelarocca diff --git a/data/markdown/rappresentanti_informatica.md b/data/markdown/rappresentanti_informatica.md index 7bb968cd..fc46a861 100644 --- a/data/markdown/rappresentanti_informatica.md +++ b/data/markdown/rappresentanti_informatica.md @@ -1,2 +1,2 @@ -Triennale:Campo Filippo - @filippocampo98|Cascino Andrea - @Mag1candry|Cigna Gaia - @GaiaCigna|Coco Giuseppe - @peppe10001|Cocuzza Daniele - @danielecocuzza|Gibilterra Martin - @w8floosh|Parlavecchio Martina - @makapx|Patania Alex - @under3\_5|Pistorio Anna - @annapistorio -Magistrale:Trupia Andrea - @andreatrups +Triennale:Cipria Fabrizio - @FabrizioCipria|D'Anna Kamil - @Heavenly0000|Gigliuto Emily - @imemgi|La Rocca Lorenzo - @lorelarocca|Lo Castro Giuseppe - @shownunderlight|Mirabella Leonardo - @infra\_blue|Russo Mirko - @altair\_mr|Spina Simone - @simonze0|Vaccaro Giuseppe - @VaccSpacc +Magistrale:Cigna Gaia - @GaiaCigna|Salemi Andrea Filippo - @AndreaNinetyFive diff --git a/data/markdown/rappresentanti_matematica.md b/data/markdown/rappresentanti_matematica.md index 2d0a533a..e8fdf5e6 100644 --- a/data/markdown/rappresentanti_matematica.md +++ b/data/markdown/rappresentanti_matematica.md @@ -1,2 +1,2 @@ -Triennale:Catania Valentina - @valentina\_catania|Curto Sofia - @Sofia\_Curto Fragapane Leonardo - @leofragap06|Minissale Giuseppe Virgilio - @Pepp\_00|Tilotta Fabio - @fatilo422 -Magistrale:\(°^°)/ +Triennale:Candiano Francesco - @fr4nc3sc003|Luglio Gaia - @gxaja|Pitari Mario - @mariopitari|Di Blasi Marco - @Diblahh30|Tragna Agnese +Magistrale:Frasca Valentina - @valentina\_frasca|Curto Sofia - @Sofia\_Curto|Minissale Giuseppe Virgilio - @pepp\_00|Fragapane Leonardo - @leofragap06 diff --git a/data/markdown/trasporto_urbano_unict.md b/data/markdown/trasporto_urbano_unict.md index 2c19b39e..fe692b3c 100644 --- a/data/markdown/trasporto_urbano_unict.md +++ b/data/markdown/trasporto_urbano_unict.md @@ -1,5 +1,5 @@ Percorso Autobus AMT 901: https://www.amts.ct.it/mappa-delle-linee?percorso=901 -Orari Collegamento FCE Milo-Cittadella-S.Sofia:https://www.circumetnea.it/linee_orari_autobus/COLLEGAMENTO%20METRO%20Milo%20-%20CITTADELLA%20-Santa%20sofia.pdf +Orari Collegamento FCE Milo-Cittadella-S.Sofia: https://www.circumetnea.it/metro-shuttle-fce-santa-sofia/ Percorso Autobus AMT: https://www.amts.ct.it/percorsi-e-orari diff --git a/data/translations/en.yaml b/data/translations/en.yaml index 677b983f..12ffe6de 100644 --- a/data/translations/en.yaml +++ b/data/translations/en.yaml @@ -51,6 +51,7 @@ HELP_ALL_COMMANDS_TOOLTIP_ID: |- 👔 /prof - _es. /prof Barbanera_ 👥 /rappresentanti - _list of representatives_ 📚 /biblioteca - _DMI's library working hours_ + 📚 /aule_studio - _DMI's aule working hours location_ /cus - _location and contacts_ ☁ /cloud - _ access to cloud shared folders_ 📣 /report - _submit a report to representatives_ @@ -60,12 +61,12 @@ HELP_ALL_COMMANDS_TOOLTIP_ID: |- 🧑‍💻 /contributors - _shows the developers that contributed to the bot development_ 🧾 /regolamentodidattico - _gives a pdf file of the desired year's educational regulations_ ❓ /faq - _shows the frequently asked questions_ - + *Receptionist's contacts and working hours:* ✍ /sdidattica - _edcational receptionist_ 📓 /studenti - _student receptionist_ /cea - _information for Center for Computing Systems and Scientific and Educational Applications_ - + *ERSU's contactsand working hours:* 🗃 /ersu - _location of the main ersu office_ 🗃 /ufficioersu - _(ersu office for student cards)_ @@ -96,14 +97,18 @@ HELP_CDL_CLASSES_LINK_TOOLTIP_ID: |- _Mathematics Master (LM-40):_ [link](%capybara%) HELP_CDL_LIBRARY_TOOLTIP_ID: |- *Library working hours:* - + Reading room: - + %capybara% Leasing Service: - + %capybara% +HELP_CDL_AULESTUDIO_TOOLTIP_ID: |- + Study Room: %capybara% + + Study Room: %capybara% # /help-Reprs command REPRS_HEADER_TEXT_ID: "With which representatives you want to talk?" @@ -113,19 +118,19 @@ REPRS_DMI_MATH_TEXT_ID: "Mathematics Reps" REPRS_DMI_TOOLTIP_ID: "*DMI's Representatives*" REPRS_DMI_CS_TOOLTIP_ID: |- *Computer Science Bachelor Program Representatives* - + %capybara% - + *Computer Science Master Program Representatives* - + %capybara% REPRS_DMI_MATH_TOOLTIP_ID: |- *Mathematics Bachelor Program Representatives* - + %capybara% - + *Mathematics Master Program Representatives* - + %capybara% # /help-Segr command @@ -136,7 +141,7 @@ SEGR_DID_TOOLTIP_ID: |- Headquarters at the Department of Mathematics and Computer Science (second floor near the Directorate) **Secretarial staff** - + %capybara% **Didactic Secretariat** @@ -148,49 +153,49 @@ SEGR_DID_TOOLTIP_ID: |- %capybara% SEGR_STU_TOOLTIP_ID: |- *Student receptionist* - + Location: - + %capybara% - + Contacts: - + %capybara% 🕑 Working hours: - + %capybara% 🕑 Winter working hours: - + %capybara% Student Careers Office - Scientific Area Mathematics Bachelor & Master Programs (L-LM) - + %capybara% Master Program Bachelor Program (L) - + %capybara% - + Computer Science Master Program (LM) - + %capybara% SEGR_CEA_TOOLTIP_ID: |- *Center for Computing Systems and Scientific and Educational Applications (CEA)* - + Contacts: - + %capybara% - + Location: - + %capybara% - + Website: - + %capybara% # /help-ERSU command @@ -199,27 +204,27 @@ ERSU_OFFICE_TEXT_ID: "ERSU's Office" ERSU_URP_TEXT_ID: "URP" ERSU_TOOLTIP_ID: |- *ERSU Catania - Headquarters* - + Location: - + %capybara% - + Contacts: - + %capybara% 🕑 Working hours: - + %capybara% ERSU_OFFICE_TOOLTIP_ID: |- *ERSU Catania - Student ID Card Office* - + Location: - + %capybara% - + 🕑 Working hours: - + %capybara% Location: @@ -231,17 +236,17 @@ ERSU_OFFICE_TOOLTIP_ID: |- %capybara% ERSU_URP_TOOLTIP_ID: |- *URP Students* - + Location: - + %capybara% - + Contacts: - + %capybara% 🕑 Working hours: - + %capybara% # /help-projct/credits command @@ -322,4 +327,4 @@ EXAMS_USAGE_TEXT_ID: |- Enter the name of the subject in the format: ins: subject_name Example: - ins: SisTeMi oPeRaTIvI \ No newline at end of file + ins: SisTeMi oPeRaTIvI diff --git a/data/translations/it.yaml b/data/translations/it.yaml index 7573e9f3..c185757f 100644 --- a/data/translations/it.yaml +++ b/data/translations/it.yaml @@ -52,6 +52,7 @@ HELP_ALL_COMMANDS_TOOLTIP_ID: |- 👔 /prof - _es. /prof Barbanera_ 👥 /rappresentanti - _elenco dei rappresentanti_ 📚 /biblioteca - _orario biblioteca DMI_ + 📚 /aule_studio - _orario locazione aule studio DMI_ /cus - _sede e contatti_ ☁ /cloud - _linka le cartelle condivise su cloud_ 📣 /report - _permette di inviare una segnalazione ai rappresentanti_ @@ -61,12 +62,12 @@ HELP_ALL_COMMANDS_TOOLTIP_ID: |- 🧑‍💻 /contributors - _mostra gli sviluppatori che hanno contribuito allo sviluppo del bot_ 🧾 /regolamentodidattico - _invia il pdf del regolamento didattico per l'anno desiderato_ ❓ /faq - _mostra le domande chieste più frequentemente_ - + *Segreteria orari e contatti:* ✍ /sdidattica - _segreteria didattica_ 📓 /studenti - _segreteria studenti_ /cea - _informazioni Centro per i sistemi di Elaborazione e Applicazioni scientifiche e didattiche_ - + *ERSU orari e contatti:* 🗃 /ersu - _informazioni sede centrale ersu_ 🗃 /ufficioersu - _(ufficio tesserini)_ @@ -79,6 +80,7 @@ HELP_CDL_LESSONS_TIMETABLE_TEXT_ID: "📘 Orari lezioni (link)" HELP_CDL_PROF_INFO_TEXT_ID: "👨‍🏫 Info Professori" HELP_CDL_REPRS_TEXT_ID: "👥 Rappresentanti" HELP_CDL_LIBRARY_TEXT_ID: "📚 Biblioteca" +HELP_CDL_AULESTUDIO_TEXT_ID: "📚 Aule_studio" HELP_CDL_GROUPS_TEXT_ID: "📊 Gruppi" HELP_CDL_PROF_TOOLTIP_ID: |- Per avere info sui professori puoi utilizzare il seguente comando: @@ -97,15 +99,20 @@ HELP_CDL_CLASSES_LINK_TOOLTIP_ID: |- _Matematica magistrale (LM-40):_ [link](%capybara%) HELP_CDL_LIBRARY_TOOLTIP_ID: |- *Orari della biblioteca:* - + Sala Lettura: - + %capybara% Servizio Distribuzione: - + %capybara% +HELP_CDL_AULESTUDIO_TOOLTIP_ID: |- + Aula Studio: %capybara% + + Aula Studio: %capybara% + # /help-Reprs command REPRS_HEADER_TEXT_ID: "Quali rappresentanti vuoi contattare?" REPRS_DMI_TEXT_ID: "Rapp. DMI" @@ -114,19 +121,19 @@ REPRS_DMI_MATH_TEXT_ID: "Rapp. Matematica" REPRS_DMI_TOOLTIP_ID: "*Rappresentanti DMI*" REPRS_DMI_CS_TOOLTIP_ID: |- *Rappresentanti Corso di Laurea Informatica Triennale* - + %capybara% - + *Rappresentanti Corso di Laurea Informatica Magistrale* - + %capybara% REPRS_DMI_MATH_TOOLTIP_ID: |- *Rappresentanti Corso di Laurea Matematica Triennale* - + %capybara% - + *Rappresentanti Corso di Laurea Matematica Magistrale* - + %capybara% # /help-Segr command @@ -137,7 +144,7 @@ SEGR_DID_TOOLTIP_ID: |- Sede presso il Dipartimento di Matematica e Informatica (primo piano vicino alla direzione) **Personale di segreteria** - + %capybara% **Segreteria didattica** @@ -149,49 +156,49 @@ SEGR_DID_TOOLTIP_ID: |- %capybara% SEGR_STU_TOOLTIP_ID: |- *Segreteria studenti* - + Posizione: - + %capybara% - + Contatti: - + %capybara% 🕑 Orario ordinario: - + %capybara% 🕑 Orario invernale: - + %capybara% Ufficio carriere studenti - Settore scientifico Matematica Triennale e Magistrale (L-LM) - + %capybara% Informatica Triennale (L) - + %capybara% - + Informatica Magistrale (LM) - + %capybara% SEGR_CEA_TOOLTIP_ID: |- *Centro per i sistemi di elaborazione e le applicazioni scientifiche e didattiche (CEA)* - + Contatti: - + %capybara% - + Posizione: - + %capybara% - + Sito web: - + %capybara% # /help-ERSU command @@ -200,29 +207,29 @@ ERSU_OFFICE_TEXT_ID: "Ufficio ERSU" ERSU_URP_TEXT_ID: "URP" ERSU_TOOLTIP_ID: |- *ERSU Catania - sede centrale* - + Posizione: - + %capybara% - + Contatti: - + %capybara% 🕑 Orari: - + %capybara% ERSU_OFFICE_TOOLTIP_ID: |- *ERSU Catania - Ufficio Tesserini* - + Posizione: - + %capybara% 🕑 Orari: - + %capybara% - + Posizione: %capybara% @@ -232,13 +239,13 @@ ERSU_OFFICE_TOOLTIP_ID: |- %capybara% ERSU_URP_TOOLTIP_ID: |- *URP Studenti* - + Posizione: - + %capybara% - + Contatti: - + %capybara% 🕑 Orari: @@ -323,4 +330,4 @@ EXAMS_USAGE_TEXT_ID: |- Inserire il nome della materia nel formato: ins: nome insegnamento Esempio: - ins: SisTeMi oPeRaTIvI \ No newline at end of file + ins: SisTeMi oPeRaTIvI diff --git a/main.py b/main.py index fb29784a..1ce404f0 100755 --- a/main.py +++ b/main.py @@ -48,6 +48,7 @@ def add_commands(up: Updater) -> None: BotCommand("urp", "URP"), BotCommand("mensa", "orari e menù della mensa"), BotCommand("biblioteca", "orari della biblioteca"), + BotCommand("aule_studio", "tutta la descrizione qui"), BotCommand("drive", "accedi alla cartella Drive"), BotCommand("drive_contribute", "ottieni i permessi per caricare materiale sulla cartella Drive"), BotCommand("git", "accedi al materiale didattico su GitLab"), @@ -62,7 +63,7 @@ def add_commands(up: Updater) -> None: BotCommand("cloud", "risorse didattiche in cloud"), BotCommand("regolamentodidattico", "lista dei regolamenti didattici"), BotCommand("ricevimenti", "lista orari ricevimenti dei professori"), - BotCommand("trasporto_urbano_unict", "link orari BRTU"), + BotCommand("trasporto_urbano_unict", "link orari Metro Shuttle FCE"), BotCommand("dmi_3d", "mappa in 3D del DMI"), BotCommand("mercatino", "bot per la vendita e l'acquisto di libri"), BotCommand("faq", "mostra le domande chieste più frequentemente"), @@ -96,6 +97,7 @@ def add_handlers(dp: Dispatcher) -> None: dp.add_handler(CommandHandler('ufficioersu', informative_callback)) dp.add_handler(CommandHandler('urp', informative_callback)) dp.add_handler(CommandHandler('biblioteca', informative_callback)) + dp.add_handler(CommandHandler('aule_studio', informative_callback)) dp.add_handler(CommandHandler('gruppi', informative_callback)) dp.add_handler(CommandHandler('cus', informative_callback)) dp.add_handler(CommandHandler('ricevimenti', informative_callback)) diff --git a/module/commands/lezioni.py b/module/commands/lezioni.py index 3ae7e35a..0f615af0 100644 --- a/module/commands/lezioni.py +++ b/module/commands/lezioni.py @@ -2,21 +2,68 @@ """/lezioni command""" import logging import re +import requests +import os +import time +import datetime +from bs4 import BeautifulSoup from typing import Tuple, Optional from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, CallbackQuery from telegram.ext import CallbackContext from module.data import Lesson -from module.shared import check_log, send_message +from module.shared import check_log, send_message, read_md, config_map from module.data.vars import TEXT_IDS, PLACE_HOLDER from module.utils.multi_lang_utils import get_locale, get_locale_code + logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) +def get_url(courses: str) -> str: + """Extract the L-31 url from markdown file. + + Args: + courses: all available courses + + Returns: + link of the website + """ + course_index = courses.find("L-31") + if course_index != -1: + token_pos = courses.find(":", course_index) + endl_index = courses.find("\n", course_index) + + if token_pos != -1: + main_link = courses[token_pos + 1:endl_index] + return main_link + + +def get_orario_file() -> Optional[bytes]: + """Download pdf file from website. + + Returns: + None or downloaded file + """ + main_link = get_url(read_md("lezioni_link")) + soup = BeautifulSoup(requests.get(main_link, timeout=10).content, "html.parser") + + for item in soup.find_all("a"): + if config_map['lectures']['href_token'] in str(item): + item = item.get("href") + full_pdf_link = config_map['lectures']['dmi_link'] + item + + response = requests.get(full_pdf_link, timeout=10).content + with open(config_map['lectures']['file_orario_path'], "wb") as file: + file.write(response) + return response + + return None + + def lezioni(update: Update, context: CallbackContext) -> None: """Called by the /lezioni command. - Shows the options available to execute a lesson query. + Sends a pdf file to user downloaded from website. Args: update: update event @@ -39,8 +86,31 @@ def lezioni(update: Update, context: CallbackContext) -> None: context.bot.sendMessage(chat_id=chat_id, text=get_locale(locale, TEXT_IDS.USE_WARNING_TEXT_ID).replace(PLACE_HOLDER, "/lezioni")) context.bot.sendMessage(chat_id=user_id, text=get_locale(locale, TEXT_IDS.GROUP_WARNING_TEXT_ID).replace(PLACE_HOLDER, "/lezioni")) - message_text, inline_keyboard = get_lezioni_text_InLineKeyboard(locale, context) - context.bot.sendMessage(chat_id=user_id, text=message_text, reply_markup=inline_keyboard) + if os.path.exists(config_map['lectures']['file_orario_path']): # Exist local file + current_time = time.time() + file_modified_time = os.path.getmtime(config_map['lectures']['file_orario_path']) + time_difference = current_time - file_modified_time + formatted_time= datetime.datetime.fromtimestamp(file_modified_time).strftime('%d-%m-%Y %H:%M:%S') + + if time_difference < config_map['lectures']['expire_time']: # File not expired + with open(config_map['lectures']['file_orario_path'], "rb") as file: + context.bot.sendDocument(chat_id=update.effective_chat.id, document=file) + context.bot.sendMessage(chat_id=chat_id, text=f"Ultimo aggiornamento: {formatted_time}") + return + else: # Not exists local file, so download it + pass + + file = get_orario_file() + + if file is None: + context.bot.sendMessage(chat_id=chat_id, text="Orario non disponibile attualmente. Ritenta più tardi") + if os.path.exists(config_map['lectures']['file_orario_path']): + with open(config_map['lectures']['file_orario_path'], "rb") as file: + context.bot.sendDocument(chat_id=update.effective_chat.id, document=file) + else: + with open(config_map['lectures']['file_orario_path'], "rb") as file: + context.bot.sendDocument(chat_id=update.effective_chat.id, document=file) + context.bot.sendMessage(chat_id=chat_id, text="Ultimo aggiornamento: oggi") def lezioni_handler(update: Update, context: CallbackContext) -> None: diff --git a/module/data/vars.py b/module/data/vars.py index 47458735..0275fd9b 100644 --- a/module/data/vars.py +++ b/module/data/vars.py @@ -55,6 +55,7 @@ class TEXT_IDS(Enum): HELP_CDL_EXAMS_LINK_TOOLTIP_ID = auto() HELP_CDL_CLASSES_LINK_TOOLTIP_ID = auto() HELP_CDL_LIBRARY_TOOLTIP_ID = auto() + HELP_CDL_AULESTUDIO_TOOLTIP_ID = auto() # /help-Reprs command REPRS_HEADER_TEXT_ID = auto() REPRS_DMI_TEXT_ID = auto() @@ -140,6 +141,7 @@ class TEXT_IDS(Enum): "HELP_CDL_EXAMS_LINK_TOOLTIP_ID": "esami_link", "HELP_CDL_CLASSES_LINK_TOOLTIP_ID": "lezioni_link", "HELP_CDL_LIBRARY_TOOLTIP_ID": "biblioteca", + "HELP_CDL_AULESTUDIO_TOOLTIP_ID": "aule_studio", "REPRS_DMI_TOOLTIP_ID": "rappresentanti_dmi", "REPRS_DMI_CS_TOOLTIP_ID": "rappresentanti_informatica", "REPRS_DMI_MATH_TOOLTIP_ID": "rappresentanti_matematica", @@ -156,6 +158,7 @@ class TEXT_IDS(Enum): "HELP_CDL_EXAMS_LINK_TOOLTIP_ID": "single", "HELP_CDL_CLASSES_LINK_TOOLTIP_ID": "single", "HELP_CDL_LIBRARY_TOOLTIP_ID": "multi", + "HELP_CDL_AULESTUDIO_TOOLTIP_ID": "multi", "REPRS_DMI_CS_TOOLTIP_ID": "multi", "REPRS_DMI_MATH_TOOLTIP_ID": "multi", "SEGR_DID_TOOLTIP_ID": "multi", diff --git a/tests/e2e/test_help.py b/tests/e2e/test_help.py index d1fba48a..c4f3c6f8 100644 --- a/tests/e2e/test_help.py +++ b/tests/e2e/test_help.py @@ -22,6 +22,7 @@ async def test_help_buttons(client: TelegramClient): "md_professori", "sm_help_rapp_menu", "md_biblioteca", + "md_aule_studio", "md_gruppi", ], 'reg_button_home': [], # tested by `/regolamentodidattico`