Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Latest commit

 

History

History
56 lines (30 loc) · 2.26 KB

README.md

File metadata and controls

56 lines (30 loc) · 2.26 KB

Telegram Forwarding Bot (MVP)

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.

Overview

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.

Installation and configuration

This bot was developed and tested on Ubuntu 22.04 with Python v3.10.6.

To run the bot:

  1. install two packages:

    • pip install python-telegram-bot
    • pip install tinydb
  2. Set up the specified environment variables.

  3. 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.

Usage

Simple forwarding

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:

Alt text

The result in the target channel:

Alt text

Forwarding and adding hashtags

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:

Source chat with args

The bot will send forward the message message :

Target channel with args