In this tutorial, we’ll explore how to set up and use a bot that forwards messages from a Telegram chat to a Discord channel. The project is hosted on GitHub.

Download the Script Here:

Introduction

This bot allows you to forward messages from a specific Telegram chat to a Discord channel. You can configure it to forward all messages or only those containing specific keywords. This can be particularly useful for community managers or anyone looking to bridge communications between these two platforms.

Prerequisites

Before we start, make sure you have the following:

  • Python 3.7 or higher installed on your machine.
  • Telegram API credentials (API ID, API Hash, Phone Number).
  • Discord bot token.

You can obtain your API ID and API Hash from the Telegram API development tools, and the Discord bot token from the Discord Developer Portal.

Step-by-Step Setup

1. Clone the Repository

First, clone the repository to your local machine:

git clone https://github.com/redianmarku/telegram-to-discord.git

cd telegram-to-discord

2. Create a Virtual Environment

Next, create a virtual environment to manage dependencies:

python -m venv env

Activate the virtual environment:

  • On Windows:shCopy code.\env\Scripts\activate
  • On macOS and Linux:shCopy codesource env/bin/activate

3. Install Required Packages

Install the necessary packages using pip:

pip install -r requirements.txt

4. Configuration

When you run the run.py script for the first time, it will prompt you to enter your API ID, API Hash, Phone Number, and Discord bot token. The script will automatically save these credentials to the credentials.txt file.

5. Running the Script

To run the script, simply execute:

python run.py

The script will prompt you to enter your credentials the first time it runs and save them for future use. Once the credentials are set, you can choose from the following options:

  1. List Chats: This option lists all your Telegram chats and saves them to a file.
  2. Forward Messages: This option forwards messages from a specified Telegram chat to a Discord channel. You can specify keywords to filter which messages get forwarded.
  3. Exit: This option exits the script.

Usage Example

Here’s a simple example of how to use the bot:

  1. Run the script:shCopy codepython run.py
  2. Choose an option:Choose an option: 1. List Chats 2. Forward Messages 3. Exit Enter your choice:
  3. If you choose to forward messages, you’ll be prompted to enter the source chat ID, destination Discord channel ID, and keywords (if any).

Conclusion

With this setup, you can easily bridge communications between Telegram and Discord, automating the process of forwarding messages. This can be incredibly useful for managing communities and ensuring important messages are shared across platforms.

For more details and to access the source code, visit the GitHub repository.

Video Tutorial

For a detailed video tutorial, you can watch my YouTube video below:

https://youtu.be/OjJ8ujkA4lg