Context:
I want to add an automated message in my telegram bot i did with python that will send a message every time a specific holiday is eligible. For example, international mans day, independance day etc.
Is this possible without using a json file? Preferably with a simple if function that will compare the current date with a specified one from a list and return a message according to date? I am new in Python if you can direct me to some documentation with an example i would appreciate it:)
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
2
Answers
You could make multiple cron jobs, for each date. Each cron job would run your script and send your message. There is probably a better way to do it. But I personally use cron for all my scripts that execute off a schedule.
Take a look at this for using cron for particular dates:
Cron expression for particular date
You can also use this to easily configure cron schedules:
https://crontab.guru/
If the number of the special holidays is not too high, you could put the dates and the messages inline in the script like so:
If
get_message
returns something other thanNone
, pass it to the Telegram bot. Run this from cron once a day.