Code Monkey home page Code Monkey logo

telegramforwarder's Introduction

Telegram Forwarder Bot

  • Automatically forward messages from Channels and Groups (private or public)
  • Group channels into Thematic feeds
  • Clone all messages from any channel to your own channel

Pre Installation

You'll require two different api keys. One for the telegram bot api and one for the telegram account used as an agent.

A. Bot API

Telegram offers a neat way to create api keys for telegram bots. You need to message @botfather - a telegram bot to get create new bots! The bot will guide you through the process of creating and managing new bots and the api keys.

Create Telegram bot with @botfather

B. Telegram API

To get the API id and Hash id for the telegram account visit https://my.telegram.org/auth?to=apps

Installation

Clone the repository

git clone https://github.com/adityathebe/telegramForwarder.git

1. Docker (Recommended)

The docker-compose file requires few environment variables. Create a .env file in the root directory. Docker compose will automatically pull the required environment variables from this file. Here's an example of my .env file

TG_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TG_API_ID=XXXX
TG_HASH_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TG_BOT_USERNAME=@XXXXXXXXXXXXXXXXXbot

With that set up you're ready to go !

docker-compose up

Things might go wrong the first time you run this command. If that happens, stop the process and re-run the command

2. Manual

1. Install Python Packages

cd agent
pip install -r requirements.txt

2. Install Nodejs Packages

cd bot
npm install

3. Install and setup postgress

Install the postgres server and create a new database named telegram.

4. Run everything

Post Installation

Once you get the database, python agent and node server running, you need to login with the telegram account that you want to use as the forwarder agent.

Visit http://localhost:3000/login to login

Things to keep in mind

  1. If you're running the code via docker and docker-compose then you'll need to rebuild the docker images after pulling new updates.
docker-compose up --build
  1. Docker will persist the postgres database even after you stop the docker containers. If for some reason you want to start fresh and clean the database you need to purge the docker volume.
docker-compose down -v

Access database from the docker container

If you've already installed psql or any other Postgres GUI tools then you can simply connect to the database as the port 5432 is exposed and mapped to the host system's port 5432.

However, if you don't have any of those tools and don't want to bother installing them, you can simply get an interactive shell on the docker container and access database from there. If you run the command below, you will get a shell on the postgres docker container

docker container exec -it telegramforwarder_postgres-db_1 psql -U postgres

Note 1: The PostgreSQL image sets up trust authentication locally so you may notice a password is not required when connecting from localhost (inside the same container). However, a password will be required if connecting from a different host/container.

-- \c telegram
select * FROM users;

FAQ:

-Q: How to start using the bot?
A: Send /start command to the bot and follow the instructions.

Q: Does the bot need admin permissions in a channel/group it forwards from?
A: No.

Q: Does the bot need admin permissions in a channel/group it forwards to?
A: Yes.

Q: Can I filter out ads or media content (videos, stickers, etc.)?
A: Yes.

Q: Can I set up automatic forwarding from another bot?
A: Yes.

telegramforwarder's People

Contributors

adityathebe avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.