Coder Social home page Coder Social logo

maxovtsin / telegram_forwarder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrmissx/telegram_forwarder

0.0 1.0 0.0 35 KB

Forward message automatically from channel/group with telegram bot @/heroku

License: GNU General Public License v3.0

Python 100.00%

telegram_forwarder's Introduction

Telegram Forwarder

A simple Telegram Python bot running on Python3 to automatically forward messages from one chat to another.

Starting The Bot

Once you've setup your database and your configuration (see below) is complete, simply run:

python3 -m forwarder

or you can host and run this bot on Heroku

Host on Heroku

Deploy to Heroku

Setting Up The Bot (Read Before Trying To Use!):

Please make sure to use the latest Python version. (Recommended)

Configuration

There are two possible ways of configuring your bot: a config.py file, or ENV variables.

The prefered version is to use a config.py file, as it makes it easier to see all your settings grouped together. This file should be placed in forwarder folder, alongside the __main__.py file . This is where your bot token will be loaded from, and most of your other settings.

It is recommended to import sample_config and extend the Config class, as this will ensure your config contains all defaults set in the sample_config, hence making it easier to upgrade.

An example config.py file could be:

from auto_forwarder.sample_config import Config


class Development(Config):
    API_KEY = "1234567890:Abcdef1234567890GHIJ"  # Your bot API key
    OWNER_ID = 1234567890  # Your user id

    # Make sure to include the '-' sign in group and channel ids.
    FROM_CHATS = [-1001234567890]  # List of chat id's to forward messages from.
    TO_CHATS = [-1001234567890, -1234567890]  # List of chat id's to forward messages to.
    
    WORKERS = 4

If you can't have a config.py file (EG on Heroku), it is also possible to use environment variables. The following environment variables are supported:

  • ENV: Setting this to ANYTHING will enable environment variables.

  • API_KEY: Your bot API key, as a string.

  • OWNER_ID: An integer of consisting of your owner ID.

  • FROM_CHATS: Space separated list of chat ID's to forward messages from. Do not forget to include the minus (-) sign in the chat ID's of groups and channels. You can add ID's of users too, to forward their messages with the bot.

  • TO_CHATS: Space separated list of chat ID's to forward messages to. Do not forget to include the minus (-) sign in the chat ID's of groups and channels. You can add ID's of users too, to forward messages to them.

  • WEBHOOK: Setting this to ANYTHING will enable webhooks when in env mode messages.

  • URL: The URL your webhook should connect to (only needed for webhook mode).

  • CERT_PATH: Path to your webhook certificate.

  • PORT: Port to use for your webhooks.

  • WORKERS: Number of threads to use. 4 is the recommended (and default) amount, but your experience may vary. NOTE: You may need to use more workers if the number of messages to be forwarded are more. But going crazy with more threads wont necessarily speed up your bot due to the way python asynchronous calls work.

Python dependencies

Install the necessary python dependencies by moving to the project directory and running:

pip3 install -r requirements.txt.

This will install all necessary python packages.

Credits

telegram_forwarder's People

Contributors

maxovtsin avatar mrmissx avatar saksham2410 avatar

Watchers

 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.