Library to setup telegram bots with recurring tasks.
pip install telegram-task-bot
ALLOWED_USERS
specifies the users which are allowed, ifany
, every one is allowed to use the bot.BOT_TOKEN
the token of the bot.START_MESSAGE
the message to be send as response to the start command.
There are several classes included in this Package.
Base class for recurring tasks.
job_name: str
Name of the job defined in this taskdisable_notifications: bool
Disable notifications, flag send to the telegram servergeneric: bool
Defines if the task looks the same for each userfirst_time:time
First time to run the task, 0 is now takes adatetime.time
repeat_time: timedelta
Defines the time between two executions of the job, takesdatetime.timedelta
filename: str
Filename under which data specific to this job should be saved
More specific class which adds the possiblity to get the actual value and implements user handling.
The data is saved to a JSON
file.
The callback method ( callback(self, context: telegram.ext.CallbackContext)
) must be implemented.
Extension of the GenericTask
to simplify the usage for jobs calling a URL and returning the link/ response to the subscribers.
It retries every 2 seconds until it gets a response.
This class adds a url
field where the information lies.
The handle_response(self, response: Response)
must be implemented to extract the data from the request and return the message string.