Add New Alert System for Train Search Results with Enhanced Scheduling#20
Open
davidmohedanovazquez wants to merge 6 commits intoemartinez-dev:masterfrom
Open
Add New Alert System for Train Search Results with Enhanced Scheduling#20davidmohedanovazquez wants to merge 6 commits intoemartinez-dev:masterfrom
davidmohedanovazquez wants to merge 6 commits intoemartinez-dev:masterfrom
Conversation
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/davidmohedanovazquez/renfe-bot?shareId=XXXX-XXXX-XXXX-XXXX).
Add alert functionality to the bot
…en el bucle de schedule
…all cases * Add parameter `is_scheduled_task` to `search_trains` function in `renfe-bot.py` * Modify `search_trains` function to check if results are empty and send a message to Telegram if no trains are found * Modify `check_for_changes` function to check if results are empty and avoid generating an exception
* Add a check in the `/alert` command handler to verify the existence of `last_input.json` and `last_search_results.json` files before proceeding * Add a message to inform the user to perform a search first if the files do not exist * Modify the `/shutdown_alert` command handler to check if `alerting` is already `False` and inform the user that no alerts were configured if so
Owner
|
Hey @davidmohedanovazquez, thank you for your work! The Renfe website changed so much in the last year that the latest version of the bot is barely usable, as both the scraper and the functions to make the query for the train tickets are not working right now. I will try to address all the problems that the bot has now before merging your alert system, which I find very useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new alert system for train search results and includes several changes to support this feature. The most important changes are the addition of functions to handle loading and comparing search results, scheduling alerts, and managing alert states.
Alert System Implementation:
bot/utils.py: Addedload_last_search_resultsandcompare_search_resultsfunctions to handle loading previous search results from a file and comparing them with current results.renfe-bot.py: Added new command handlers for/alertand/shutdown_alertto configure and manage search alerts. [1] [2]Scheduling and Alert Management:
renfe-bot.py: Integrated theschedulelibrary to set up periodic tasks for checking search results changes. Addedschedule_alerts,get_alert_frequency, andcheck_for_changesfunctions to handle the scheduling logic and alert checks. [1] [2]Search Function Enhancements:
renfe-bot.py: Modified thesearch_trainsfunction to handle scheduled tasks and save search results to a file. [1] [2]