GithubHelp home page GithubHelp logo

ferdiaprilyan / tglf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weebzone/tglf

0.0 0.0 0.0 22 KB

This is a Python bot built using Pyrogram that automatically forwards messages with links from a source channel to multiple destination channels. The bot can be configured using a JSON file and can be run using either a user session or a bot token

License: GNU General Public License v3.0

Python 86.31% Dockerfile 13.69%

tglf's Introduction


Tglf Bot

This is a Python bot built using Pyrogram that automatically forwards messages with links from a source channel to multiple destination channels. The bot can be configured using a JSON file and can be run using either a user session or a bot token.

Prerequisites

  • Python 3.6 or higher
  • A Telegram account
  • API ID and API hash for creating a Pyrogram client
  • Bot token or user session string for bot authentication
  • A config.env file for storing environment variables (API_ID, API_HASH, BOT_TOKEN, USER_SESSION)
  • A chat_id.json file for specifying channel mappings and modifications

Installation

  1. Clone this repository:

    git clone https://github.com/weebzone/tglf.git
    cd tglf
  2. Install the required dependencies:

    pip install -r requirements.txt
  3. Create a config.env file in the project directory with the following content:

    API_ID=your_api_id
    API_HASH=your_api_hash
    BOT_TOKEN=your_bot_token
    USER_SESSION=your_user_session_string (if available)

Configuration

  1. Create a JSON file named chat_list.json in the same directory as the script.

  2. Define the channel mappings within the JSON file. Each mapping consists of the following properties:

    • "source": The ID of the source channel from which you want to forward messages.

    • "destinations": An array of channel IDs where the messages with links will be forwarded to.

    • "prefix" (Optional): A string that will be added before the link in the forwarded message. This can be useful for providing additional context to the forwarded content.

    • "suffix" (Optional): A string that will be added after the link in the forwarded message. Similar to the prefix, this can be used to add context.

  3. Define the channel mappings in the JSON file:

    [
        {
            "source": "source_channel_id",
            "destinations": ["destination_channel_id1", "destination_channel_id2"],
            "prefix": "Optional prefix",
            "suffix": "Optional suffix"
        }
    ]
  4. Here's an example of a chat_list.json file with multiple mappings:

    [
        {
            "source": "source_channel_id1",
            "destinations": ["destination_channel_id1", "destination_channel_id2"],
            "prefix": "Check out this link:"
        },
        {
            "source": "source_channel_id2",
            "destinations": ["destination_channel_id3"],
            "suffix": "๐Ÿ”—"
        },
        {
            "source": "source_channel_id3",
            "destinations": ["destination_channel_id4"]
        }
        // Add more mappings as needed
    ]

In this example:

  • The first mapping forwards messages from source_channel_id1 to destination_channel_id1 and destination_channel_id2. It adds a prefix before the link.

  • The second mapping forwards messages from source_channel_id2 to destination_channel_id3 and adds a suffix after the link.

  • The third mapping forwards messages from source_channel_id3 to destination_channel_id4 without any prefix or suffix.

Remember to replace source_channel_id and destination_channel_id with the actual channel IDs you want to use.

If you don't want to use prefixes or suffixes, simply omit the "prefix" and "suffix" properties from the mapping.

Running the Bot

  1. Open a terminal and navigate to the bot's directory.
  2. Run the bot script:
    python bot.py
    
  3. The bot will start forwarding messages with links from the source channel to the specified destination channels. It will add optional prefixes and suffixes to the forwarded messages.

Notes

  • Make sure the bot has necessary permissions to read messages from source and send messages to destination channels.
  • The bot forwards messages with links from the source channel to all specified destination channels.
  • The forwarding process is subject to a delay of 5 seconds between messages to avoid spamming.

tglf's People

Contributors

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