Skip to content
/ Telezy Public

Powerful tool for forwarding Telegram messages between chats using your own account. Features: keyword and regex filtering, content modification, media filtering, AI integration, and multi-platform notifications via Apprise. Perfect for news aggregation, reminders, and flexible automation without Telegram restrictions.

License

Notifications You must be signed in to change notification settings

metimol/Telezy

Repository files navigation

Telezy

License: GPL-3.0

This project is based on TelegramForwarder by heavrnl.

📖 Introduction

Telezy is a powerful message forwarding tool that allows you to forward messages from specified chats to other chats simply by having your account join channels/groups, without requiring a bot to enter the corresponding channels/groups for monitoring. It can be used for information stream integration and filtering, message reminders, content collection and many other scenarios, without being restricted by forwarding/copying prohibitions. Additionally, leveraging Apprise's powerful push functionality, you can easily distribute messages to chat software, email, SMS, Webhooks, APIs and various other platforms.

✨ Features

  • 🔄 Multi-source Forwarding: Support forwarding from multiple sources to specified targets
  • 🔍 Keyword Filtering: Support whitelist and blacklist modes
  • 📝 Regex Matching: Support regular expression matching for target text
  • 📋 Content Modification: Support multiple ways to modify message content
  • 🤖 AI Processing: Support using AI interfaces from major providers
  • 📹 Media Filtering: Support filtering specified types of media files
  • 📢 Multi-platform Push: Support pushing to multiple platforms via Apprise

📋 Table of Contents

🚀 Quick Start

1️⃣ Preparation

  1. Get Telegram API credentials:

  2. Get Bot Token:

    • Chat with @BotFather to create a bot
    • Get the bot's BOT_TOKEN
  3. Get User ID:

    • Chat with @userinfobot to get your USER_ID

2️⃣ Environment Configuration

Clone repository

git clone https://github.com/metimol/Telezy.git

Then rename the repository's .env.example file to .env

mv .env.example .env

Edit the .env file and fill in the required parameters

3️⃣ Start Service

First run (verification required):

docker-compose run -it telezy

CTRL+C to exit the container

Modify the docker-compose.yml file, change stdin_open: false and tty: false

Run in background:

docker-compose up -d

4️⃣ Update

Note: docker-compose deployment doesn't require pulling the repository source code, unless you plan to build it yourself. Otherwise, just execute the following commands in the project directory to update.

docker-compose down
docker-compose pull
docker-compose up -d

📚 User Guide

🌟 Basic Usage Examples

Suppose you have subscribed to channels "TG News" (https://t.me/tgnews) and "TG Read" (https://t.me/tgread), but want to filter out some uninteresting content:

  1. Create a Telegram group/channel (e.g., "My TG Filter")

  2. Add the bot to the group/channel and set it as an administrator

  3. Send commands in the newly created group/channel:

    /bind https://t.me/tgnews or /bind "TG News"
    /bind https://t.me/tgread or /bind "TG Read"
  4. Set message processing mode:

    /settings

    Select the rules for the corresponding channel you want to operate on, and configure according to your preferences

    For detailed settings instructions, please see 🛠️ Feature Details

  5. Add blocking keywords:

    /add advertisement promotion 'this is advertisement'
  6. If you find that the forwarded messages have formatting issues (such as extra symbols), you can use regular expressions to handle them:

    /replace \*\*

    This will remove all ** symbols from messages

Note: The above CRUD operations only affect the first bound rule, which is TG News in the example. If you want to operate on TG Read, you need to first use /settings(/s), select TG Read, then click "Apply Current Rule" to perform CRUD operations on it. You can also use /add_all(/aa), /replace_all(/ra) and other commands to apply to both rules simultaneously.

This way, you can receive filtered and formatted channel messages.

🔧 Special Use Case Examples

1. Some messages from TG channels have embedded links in text, clicking requires confirmation before jumping, such as NodeSeek's official notification channel

Original message format from the channel:

[**Post Title**](https://www.nodeseek.com/post-xxxx-1)

You can use the following commands in sequence on the notification channel's forwarding rules:

/replace \*\*
/replace \[(?:\[([^\]]+)\])?([^\]]+)\]\(([^)]+)\) [\1]\2\n(\3)
/replace \[\]\s*

Eventually all forwarded messages will be formatted as follows, so you can click the link directly without confirmation:

Post Title
(https://www.nodeseek.com/post-xxxx-1)

2. Monitoring user messages with unattractive formatting can be optimized for better display

Use the following commands in sequence:

/r ^(?=.) <blockquote>
/r (?<=.)(?=$) </blockquote>

Then set the message format to HTML, so when monitoring user messages, the message format will be much more attractive.


3. Synchronize rule operations

Enable "Sync Rules" in the Settings Menu and select the target rule. All operations on the current rule will be synchronized to the selected rule.

Suitable for the following scenarios:

  • Don't want to handle rules in the current window
  • Need to operate multiple rules simultaneously

If the current rule is only for synchronization and doesn't need to actually take effect, you can set "Enable Rule" to "No".


4. How to forward to Saved Messages

Not recommended, the operation is quite cumbersome

  1. Send the following command in any group or channel managed by your bot:

    /bind https://t.me/tgnews Your Username (i.e., displayed name)
  2. Create any rule and make the following settings:

    • Enable sync function, sync to forward to saved messages rule
    • Forwarding mode select "User mode"
    • Disable rule (set the rule's "Enable Rule" to off)

This way, you can manage the saved messages rule in other rules, and all operations will be synchronized to the forward to saved messages rule.

🛠️ Feature Details

⚡ Filtering Process

First, you need to understand the message filtering order, the options in parentheses correspond to those in the settings:

img

⚙️ Settings Description

Main Settings Interface AI Settings Interface Media Settings Interface
img img img

Main Settings Description

The following explains the setting options

Setting Option Description
Apply Current Rule When selected, keyword commands (/add,/remove_keyword,/list_keyword etc.) and replacement commands (/replace,/list_replace etc.) CRUD import/export operations will apply to the current rule
Enable Rule When selected, the current rule will be enabled, otherwise it will be disabled
Current Keyword Add Mode Click to switch between blacklist/whitelist mode. Since blacklist and whitelist are processed separately, manual switching is required. Note that keyword CRUD operations are related to this mode. If you want to use commands to perform CRUD operations on the current rule's whitelist, ensure this mode is set to whitelist
Include Sender Name and ID When Filtering Keywords When enabled, filtering keywords will include sender name and ID information (not added to actual messages), can be used for filtering specific users
Processing Mode Switch between edit/forward mode. Edit mode directly modifies original messages; forward mode forwards processed messages to target chat. Note: Edit mode only applies to messages where you are an admin and the original message is a channel message or a message you sent in a group
Filter Mode Switch between blacklist only/whitelist only/blacklist then whitelist/whitelist then blacklist modes. Since blacklist and whitelist are stored separately, you can choose different filtering methods as needed
Forward Mode Switch between user/bot mode. User mode forwards messages using user account; bot mode sends messages using bot account
Replace Mode When enabled, processes messages according to set replacement rules
Message Format Switch between Markdown/HTML format, takes effect in final sending stage, generally use default Markdown
Preview Mode Switch between enabled/disabled/follow original message. When enabled, previews the first link in the message, defaults to following the original message's preview status
Original Sender/Original Link/Send Time When enabled, adds this information when sending messages, disabled by default, custom templates can be set in "Other Settings" menu
Delayed Processing When enabled, re-fetches original message content after set delay time before starting processing flow, suitable for channels/groups with frequent message edits, custom delay times can be added in config/delay_time.txt
Delete Original Message When enabled, deletes original message, please confirm deletion permissions before use
Comments Direct Button When enabled, adds a direct button to comments section under forwarded messages, provided the original message has a comments section
Sync to Other Rules When enabled, syncs current rule operations to other rules, all settings except "Enable Rule" and "Enable Sync" will be synchronized

Media Settings Description

Setting Option Description
Media Type Filtering When enabled, filters out non-selected media types
Selected Media Types Select media types to block. Note: Telegram's classification of media files is fixed, mainly these types: photos (photo), documents (document), videos (video), audio (audio), voice (voice). All files that don't belong to photos, videos, audio, or voice will be classified as "document" type. For example, virus files (.exe), compressed files (.zip), text files (.txt), etc., all belong to "document" type in Telegram
Media Size Filtering When enabled, filters out media exceeding set size
Media Size Limit Set media size limit, unit: MB, custom sizes can be added in config/media_size.txt
Send Reminder When Media Size Exceeded When enabled, sends reminder message when media exceeds limit
Media Extension Filtering When enabled, filters out selected media extensions
Media Extension Filter Mode Switch between blacklist/whitelist mode
Selected Media Extensions Select media extensions to filter, custom extensions can be added in config/media_extensions.txt
Allow Text When enabled, doesn't block entire message when filtering media, instead forwards text separately

Other Settings Description

The other settings menu integrates several commonly used commands for direct interface interaction, including:

  • Copy Rules
  • Copy Keywords
  • Copy Replacement Rules
  • Clear Keywords
  • Clear Replacement Rules
  • Delete Rules

Among these, Clear Keywords, Clear Replacement Rules, and Delete Rules can affect other rules.

You can also set custom templates here, including: User Information Template, Time Template, Original Link Template

Setting Option Description
Reverse Blacklist When enabled, treats blacklist as whitelist. If using whitelist-then-blacklist mode, blacklist will be treated as second-level whitelist
Reverse Whitelist When enabled, treats whitelist as blacklist. If using whitelist-then-blacklist mode, whitelist will be treated as second-level blacklist

Combined with "X then X" modes, this enables dual-layer blacklist/whitelist mechanisms. For example, after reversing blacklist, the blacklist in "whitelist then blacklist" mode becomes a second-level whitelist, suitable for monitoring specific users and filtering their special keywords, among various scenarios.

🤖 AI Features

The project has built-in AI interfaces from major providers that can help you:

  • Automatically translate foreign content
  • Scheduled summarization of group messages
  • Intelligent filtering of advertising information
  • Automatic content tagging ....

Configuration

  1. Configure your AI interface in the .env file:
# OpenAI API
OPENAI_API_KEY=your_key
OPENAI_API_BASE=  # Optional, defaults to official interface

# Claude API
CLAUDE_API_KEY=your_key

# Other supported interfaces...

Custom Models

Can't find the model name you want? Add it in config/ai_models.json.

AI Processing

AI processing prompts can use the following formats:

  • {source_message_context:number} - Get specified number of latest messages from source chat window
  • {target_message_context:number} - Get specified number of latest messages from target chat window
  • {source_message_time:number} - Get messages from source chat window within specified minutes
  • {target_message_time:number} - Get messages from target chat window within specified minutes

Prompt Example:

Prerequisite: Enable AI processing then execute keyword filtering again, add "#no_forward" to filter keywords

This is a news aggregation channel that gets messages from multiple sources. Now you need to determine if new news content is duplicated with historical news content. If duplicated, just reply "#no_forward", otherwise please return the original text of the new news and maintain the format.
Remember, you can only return "#no_forward" or the original text of the new news.
Here is the historical news:{target_message_context:10}
Here is the new news:

Scheduled Summary Function

After enabling scheduled summary, the bot will automatically summarize messages from the past 24 hours at specified times (default is 7 AM daily).

  • Multiple summary time points can be added in config/summary_time.txt
  • Set default timezone in .env
  • Customize summary prompts

Note: The summary function consumes more API quota, please enable as needed.

📢 Push Features

In addition to internal Telegram message forwarding, the project also integrates Apprise. Using its powerful push functionality, you can easily distribute messages to chat software, email, SMS, Webhooks, APIs and various other platforms.

Push SettingsMain Interface Push SettingsSub Interface
img img

Settings Description

Setting Option Description
Forward to Push Configuration Only When enabled, skips forwarding filters and goes directly to push filters
Media Sending Method Supports two modes:
- Single:Each media file is pushed as a separate message
- All:Merge all media files into one message for pushing
Which mode to use depends on whether the target platform supports pushing multiple attachments at once

How to Add Push Configuration?

For complete push platform list and configuration format, please refer to Apprise Wiki

Example: Using ntfy.sh Push

  • Suppose you want to push to a topic named my_topic on ntfy.sh.
  • According to Apprise Wiki, its format is ntfy://ntfy.sh/your_topic_name
  • Then, the configuration URL you need to add is:
    ntfy://ntfy.sh/my_topic
    

🎯 Special Features

🔗 Link Forwarding Feature

Send message link to bot to forward that message to current chat window, ignoring forwarding and copying restrictions(project's own functionality already ignores forwarding and copying restrictions

📝 Command List

Command List

Basic Commands
/start - Start using
/help(/h) - Show this help information

Binding and Settings
/bind(/b) <source chat link or name> [target chat link or name] - Bind source chat
/settings(/s) [Rule ID] - Manage forwarding rules

Forwarding Rule Management
/copy_rule(/cr)  source rule ID [target rule ID] - Copy all settings of specified rule to current rule or target rule ID
/delete_rule(/dr) <Rule ID> [rule ID] [rule ID] ... - Delete specified rules
/list_rule(/lr) - List all forwarding rules

Keyword Management
/add(/a) <keyword> [keyword] ["key word"] ['key word'] ... - Add normal keywords
/add_regex(/ar) <regular expression> [regular expression] [regular expression] ... - Add regular expressions
/add_all(/aa) <keyword> [keyword] [keyword] ... - Add normal keywords to all rules bound to current channel
/add_regex_all(/ara) <regular expression> [regular expression] [regular expression] ... - Add regex keywords to all rules
/list_keyword(/lk) - List all keywords
/remove_keyword(/rk) <keyword> ["key word"] ['key word'] ... - Delete keywords
/remove_keyword_by_id(/rkbi) <ID> [ID] [ID] ... - Delete keywords by ID
/remove_all_keyword(/rak) <keyword> ["key word"] ['key word'] ... - Delete specified keywords from all rules bound to current channel
/clear_all_keywords(/cak) - Clear all keywords of current rule
/clear_all_keywords_regex(/cakr) - Clear all regex keywords of current rule
/copy_keywords(/ck) <Rule ID> - Copy keywords of specified rule to current rule
/copy_keywords_regex(/ckr) <Rule ID> - Copy regex keywords of specified rule to current rule
/copy_replace(/crp) <Rule ID> - Copy replacement rules of specified rule to current rule
/copy_rule(/cr) <Rule ID> - Copy all settings of specified rule to current rule (including keywords, regex, replacement rules, media settings, etc.)

Replacement Rule Management
/replace(/r) <regular expression> [replacement content] - Add replacement rule
/replace_all(/ra) <regular expression> [replacement content] - Add replacement rule to all rules
/list_replace(/lrp) - List all replacement rules
/remove_replace(/rr) <serial number> - Delete replacement rule
/clear_all_replace(/car) - Clear all replacement rules of current rule
/copy_replace(/crp) <Rule ID> - Copy replacement rules of specified rule to current rule

Import Export
/export_keyword(/ek) - Export keywords of current rule
/export_replace(/er) - Export replacement rules of current rule
/import_keyword(/ik) <send file simultaneously> - Import normal keywords
/import_regex_keyword(/irk) <send file simultaneously> - Import regex keywords
/import_replace(/ir) <send file simultaneously> - Import replacement rules

Tips
• Content in parentheses are command abbreviations
• Angle brackets <> indicate required parameters
• Square brackets [] indicate optional parameters
• Import commands require sending files simultaneously

📄 Open Source License

This project uses GPL-3.0 open source license, for detailed information please refer to LICENSE file.

About

Powerful tool for forwarding Telegram messages between chats using your own account. Features: keyword and regex filtering, content modification, media filtering, AI integration, and multi-platform notifications via Apprise. Perfect for news aggregation, reminders, and flexible automation without Telegram restrictions.

Topics

Resources

License

Stars

Watchers

Forks

Packages