Note
This bot is good enough for an MVP and is no longer maintained. For an enhanced version that already works in the largest Russian-speaking community of technical writers, see Auto Forwarder Bot.
This is a bot that allows forwarding messages from a group chat to a channel. It is designed to create some kind of knowledge base in the target channel and can keep track of hashtags.
This bot is built on top of the python-telegram-bot library v20+.
The main use-case is simple message forwarding. Optionally, you can add hashtags in a simple way to mark your messages.
The bot uses TinyDB as a persistent storage for hashtags so that you can extract them later. It is extremely easy to use and requires just a json
file to store data.
This bot was developed and tested on Ubuntu 22.04 with Python v3.10.6.
To run the bot:
-
install two packages:
pip install python-telegram-bot
pip install tinydb
-
Set up the specified environment variables.
-
Run the
main.py
script. The bot will run until you manually stop it.
Note
Just like other bots that process messages, this bot should be admin in the target channel. You need to disable the privacy mode too.
To forward a message, reply to it with the /repost
command. Each forwarded message is preceeded with another message that contains a link to the original message in the source chat. Thi is how it looks in the source chat:
The result in the target channel:
This command also accepts a list of space-separated words as optional arguments. Each argument should be a single word, and the following special symbols are prohibited: -_*[]()~`>#+=|{}.!
. The arguments are transformed to hashtags after forwarding. The bot adds the resulting hashtag list to the message with a link to the original message.
You can do it as follows:
The bot will send forward the message message :