• This repository has been archived on 22/May/2021
  • Stars
    star
    133
  • Rank 264,159 (Top 6 %)
  • Language
    JavaScript
  • Created over 5 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Telegram bot to forward messages

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.

More Repositories

1

evolutionSimulator

Evolution Simulator with Box2D
JavaScript
159
star
2

kathmandu-university-cs-notes

Computer Science, Kathmandu University course codes
C++
6
star
3

kalimati-rate

API that provides Kalimati, Nepal Current Market Rate
JavaScript
4
star
4

brick-game-neuroevolution

[NeuroEvolution] Mini game where a Neural Network learns to avoid falling walls.
JavaScript
4
star
5

cryptoCompare

An easy way to Compare the top 7 cryptocurrencies performance and rank over the last week.
JavaScript
4
star
6

protohackers

Protohackers is a casual programming challenge in which you create servers for network protocols
Go
3
star
7

ml

Mini Machine Learning Projects
JavaScript
3
star
8

botLimbu

A Utility Messenger Bot
JavaScript
3
star
9

simple-telegram-bot-api

A simple Telegram Bot API wrapper with zero dependencies
JavaScript
2
star
10

hamrobazar

Monitor new items on hamrobazaar.com
Go
2
star
11

sierpinski_triangle

Simulating Sierpinski Triangle (Chaos Game)
JavaScript
2
star
12

Kantipur

Kantipur News Rest API Built
Python
2
star
13

bitcoin-java

Java
2
star
14

tokensystem

Python
2
star
15

dotfiles

Dotfiles Backup
Shell
2
star
16

3patti-telegram-game

Telegram multi player game
JavaScript
2
star
17

google-kickstart-coding-challenges

JavaScript
2
star
18

www.adityathebe.com

Gatsby Blog
JavaScript
2
star
19

two-cars

[Game] Two Cars in JavaScript
JavaScript
2
star
20

kura

HTML
2
star
21

KU-BOT

A Messenger Bot for Kathmandu University
JavaScript
2
star
22

jwt-wordlist-cracker

Go
2
star
23

tic-tac-toe-minimax

Tic Tac Toe AI with Minimax Algorithm
JavaScript
2
star
24

hamrobazar-cli

Browser Hamrobazar.com from your terminal
JavaScript
2
star
25

astronvim

Configs for astronvim
Lua
1
star
26

POC-CVE-2018-0114

POC for CVE-2018-0114 written in Go
Go
1
star
27

telegram-assistant

Go
1
star
28

disaster_vis_nepal

A Program written with P5.JS to visualize the effect of disasters in Nepal
JavaScript
1
star
29

interpolation

A Simple library in Node
JavaScript
1
star
30

num_conv

A Website for Number System Conversion
JavaScript
1
star
31

electionNepal

API for live election Stats
JavaScript
1
star
32

neuralNetwork

My attempt to learn Neural networks by creating everything from scratch
JavaScript
1
star
33

redditBot

A Streamable mirror reddit bot for Football fans
Python
1
star
34

Space

Shows the number of person in space in real time
HTML
1
star