telegram-task-bot
Library to setup telegram bots with recurring tasks.
Usage
pip install telegram-task-bot
.env Variables
ALLOWED_USERSspecifies the users which are allowed, ifany, every one is allowed to use the bot.BOT_TOKENthe token of the bot.START_MESSAGEthe message to be send as response to the start command.
Classes
There are several classes included in this Package.
Task
Base class for recurring tasks.
Configuration
job_name: strName of the job defined in this taskdisable_notifications: boolDisable notifications, flag send to the telegram servergeneric: boolDefines if the task looks the same for each userfirst_time:timeFirst time to run the task, 0 is now takes adatetime.timerepeat_time: timedeltaDefines the time between two executions of the job, takesdatetime.timedeltafilename: strFilename under which data specific to this job should be saved
GenericTask
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.
UrlTask
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.
Example Project
https://github.com/bb4L/digitec_daily_bot
License
Release files for telegram-task-bot 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| telegram-task-bot-0.1.2.tar.gz | 9.5 kB | Details |
Release files / telegram-task-bot-0.1.2.tar.gz
| Download URL | telegram-task-bot-0.1.2.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
942350ef466f60e8a0105f15f236df68596e4db0b40a460ee3628713a8071b5a
|
|
BLAKE2b-256 checksum How to use checksums |
3f8ef8d32036819819ed824de84e935e2c8f65fead0d2791198429a27777e363
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|