This is basically a "telegram bot manager" for simply sending messages, such as notifications.
Later could be extensions of posibilities of bot itself.
Imagine you have a program that you need to extract information from and send it somewhere else. For example, a parser for a news site or school Olympiad that sends notifications when new news is uploaded. We'll call this program the "client".
A really good option for you is to send a message to yourself through Telegram. To do this, you need to write code that will run the bot and send the message. But instead of that, you could just use tg-notify. You'll only need to write a couple of lines of code to send requests to the tg-notify API.
- Run tg-notify.
- Run the client.
- The client should send requests to the local tg-notify API.
- /create a bot session with the given arguments: api_id, api_hash, bot_token.
- /run this bot session.
- /send a message through this session to a specific user for as long as you want.
- /stop this bot session if you need to.
And you could run as many sessions as you want for as many clients as you want. All you have to do is run only one instance of tg-notify and create a new Telegram bot with its own token for each session.
All of runs in parallel using multiprocessing.
Required Python 3.10 and above
Tested on Python 3.10.10
pip install -r requirements.txt
python main.py -h
# or --help for list of commands
# Example of usage
python main.py -H <host> -p <port> -c <config-dir>
data:
session_name: str
api_id: str
api_hash: str
bot_token: str
default_user: str | None = None
data:
session_name: str
api_id: str | None = None
api_hash: str | None = None
bot_token: str | None = None
default_user: str | None = None
data:
session_name: str
data:
session_name: str
data:
session_name: str
User defines only by username for now
data:
session_name: str
username: str
msg: str
- Add info about /get_result in readme
- Make get_state command
- Configure logging
- Refactoring
- Write example client script
- Transfer some "global" variables to database
- Add better global exceprion catching
- Add support of default user for session
- Add check - if bot is running elsewhere (not in tg-notify)