TelegramChat

Scalable Telegram-Bot.

API
information
management

Installation command

!!MCDR plugin install telegram_chat

Author

Synced at

...

Last update

...

Latest version

Total downloads

5

Back to catalogue

TelegramChat

TelegramChat

✨🎉 An Extensible Telegram Bot Plugin Powered by python-telegram-bot! 🎉✨

Warning


Due to f**king Tencent's issues, the entire plugin is now being developed for Telegram. QQ-based versions will no longer be supported. The plugin wrote for SaltyQQChat can still be used; simply modify a little of the codes.

Introduction

This is a Telegram bot plugin based on python-telegram-bot.

Additionally, it supports simple bot extension through API calls, allowing you to add your own custom commands!

Features we have:

  • Supports ignoring commands from specific users via /ban and /pardon
  • Allows the bot to execute more Minecraft native commands without using /command (such as /ban, /pardon)
  • Allows starting and stopping the server through the bot
  • Supports replying when the bot is mentioned, instead of just responding to a command
  • Supports executing bot commands within Minecraft
  • Check bot status via /ping and /info commands
  • [Development Feature] Remote plugin reload via /reload
  • Customizable one-way/two-way MC <==> Telegram group forwarding
  • Easily extendable command tree based on regular expressions
  • Automatically handle group join requests, friend requests, and group invitations.
  • Verify if the Minecraft player exists when binding to a player.
  • Spacing added between Chinese, numbers, and English, with a more humorous tone in the responses

Features we don't have:

  • No "management group", "main group", or "message sync group" functionality. Instead, it uses multi-group synchronization (though typically, only one group is used)
  • No "MultiServer" feature, as it leads to unpredictable bugs and has limited use

Installation

Install via MCDR

Use !!MCDR plugin install telegram_chat in the MCDR console, then !!MCDR confirm.

Install via Release

Download the corresponding .mcdr file from the Releases page and place it in the plugins folder, then reload the plugin.

Install via Source Code

Run git clone https://github.com/SALTWOOD/TelegramChat or git clone [email protected]:SALTWOOD/TelegramChat in the plugins folder, then reload the plugin.

API

One of the most interesting features of this plugin is that you can extend it by adding custom commands via other MCDR plugins. Here's an example of a single-file plugin:

from typing import Any, Callable, List

from mcdreforged.api.types import PluginServerInterface
from telegram import Update
from telegram.ext import ContextTypes

import re

PLUGIN_METADATA = {
    'id': 'tc_extension',
    'version': '1.0.0',
    'name': 'TC extension plugin',
    'description': 'TelegramChat\'s extension plugin',
    'author': 'NONE',
    'link': 'https://github.com',
    'dependencies': {
        'telegram_chat': '>=2.0.0'
    }
}

plugin: Any
send_to: Callable

def on_load(server: PluginServerInterface, old):
    global plugin, send_to
    plugin = server.get_plugin_instance("telegram_chat")

    send_to = plugin.tools.send_to

    plugin.command_tree.add_command(re.compile(r'/your-command (.*)'), [str], handler)

async def handler(server: PluginServerInterface, event: Update, context: ContextTypes.DEFAULT_TYPE, command: List[str],
                  event_type: MessageType):
    message = command[0]
    await send_to(
        event,
        context,
        f"You provided the parameter: \"{message}\""
    )

Special Thanks

  • python-telegram-bot - Provides a way to access Telegram.
  • SALTWO∅D server members - For helping me test the bot and discovering security vulnerabilities before the release

Introduction source: README-EN.md