一个将 Minecraft 服务器与 Telegram 群组连接起来的 Fabric 模组。
功能特性
- 聊天桥接: 将游戏内聊天转发至你的 Telegram 群组,并将来自 Telegram 的消息中继回 Minecraft 服务器。
- 远程指令: 通过灵活的权限系统,直接从 Telegram 执行服务器指令(例如
/list、/whitelist)。
- 玩家通知: 向 Telegram 聊天广播玩家加入、离开和死亡的提示消息。
构建
./gradlew build
设置指南
按照以下步骤让 TeleFabric 运行起来。
1. 创建 Telegram Bot
- 打开 Telegram,给 @BotFather 发送私信。
- 发送
/newbot 命令并按照屏幕上的指示操作。
- 注意:请留意 Bot 的名称和用户名之间的区别。稍后你需要用到的是用户名。
- Bot 创建完成后,复制 BotFather 提供的 Bot Token。
- 将你新创建的 Bot 添加到你想要关联的 Telegram 群组中。
2. 安装模组
- 从 Releases 页面下载最新的
.jar 文件。
- 将该
.jar 文件放入服务器的 mods 目录中(/path/to/server/mods/)。
3. 初始配置
- 启动一次服务器以生成配置文件。
- 停止服务器。
- 打开并编辑位于
/path/to/server/config/telefabric.yml 的新文件。
- 填入从 BotFather 处获得的凭据,即
bot_token 和 bot_username 字段。
4. 获取聊天 ID 和用户 ID
- 再次启动服务器。此时 Bot 应该已上线。
- 在你添加了 Bot 的 Telegram 群组中,输入指令
/getid。
- Bot 会回复 Chat ID 和你的个人 User ID。复制这些值。
- 重要提示:群组 Chat ID 以连字符(
-)开头。不要忘记包含它。
5. 完成配置
-
停止服务器并再次打开 telefabric.yml。
-
将 Chat ID(s) 和管理员 User ID(s) 添加到相应的字段中。
# Bot 监听并向其广播消息的 Chat ID 列表。
chats: [-100123456789, -1145141919810] # <-- 替换为你的 Chat ID(s)
features:
# ...
bot_cmd_command:
enabled: true
commands:
whitelist:
# 允许从 Telegram 执行此指令的用户 ID 列表。
allowed_users: [123456789] # <-- 替换为管理员的 User ID
permission: users
# ...
# ...
-
保存文件并启动服务器。桥接功能现已完全配置完毕!
-
如果之后需要在不重启服务器的情况下应用更改,你可以在服务器控制台中使用 /telefabric reload 指令。
故障排除
Bot 设置不正确
- 症状: Bot 在私信中能响应指令(如
/getid),但在群组聊天中忽略所有指令。
- 解决方案: 这很可能是由于 Bot 的隐私设置所致。
- 给 @BotFather 发私信并发送
/mybots 命令。
- 从列表中选择你的 Bot。
- 导航至
Bot Settings -> Group Privacy。
- 确保群聊隐私设置已 关闭 (OFF)。禁用后,Bot 可以接收群组中发送的所有消息。
致谢
本项目是为了纪念一位同行开发者而创建的。
在为 Minecraft 1.21.4 搜索 Fabric-Telegram 桥接模组时,我发现了 CuteNekoOwO/FabricTgBridge。得知其创作者 MeowBot233 不幸离世,且该项目将永远停留在 1.20 版本,我感到非常难过。?️
受他们工作的启发,我决定为现代版本的 Minecraft 创建一个具有类似功能的新模组。于是,TeleFabric 应运而生。
依赖项
本项目依赖于以下开源库:
A Fabric mod that bridges your Minecraft server with a Telegram group.
Features
- Chat Bridging: Forward in-game chat to your Telegram group and relay messages from Telegram back to the Minecraft server.
- Remote Commands: Execute server commands (e.g.,
/list, /whitelist) directly from Telegram with a flexible permission system.
- Player Notifications: Broadcast player join, leave, and death notifications to your Telegram chat.
Build
./gradlew build
Setup Guide
Follow these steps to get TeleFabric up and running.
1. Create a Telegram Bot
- Open Telegram and send a direct message to @BotFather.
- Send the
/newbot command and follow the on-screen instructions.
- Note: Pay attention to the distinction between the bot's name and username. You will need the username later.
- Once the bot is created, copy the bot token provided by BotFather.
- Add your new bot to the Telegram group you want to link.
2. Install the Mod
- Download the latest
.jar file from the Releases page.
- Place the
.jar file into your server's mods directory (/path/to/server/mods/).
3. Initial Configuration
- Start your server once to generate the configuration file.
- Stop the server.
- Open and edit the new file at
/path/to/server/config/telefabric.yml.
- Fill in the
bot_token and bot_username fields with the credentials you received from BotFather.
4. Get Your Chat & User IDs
- Start your server again. The bot should now be online.
- In the Telegram group where you added the bot, type the command
/getid.
- The bot will reply with the Chat ID and your personal User ID. Copy these values.
- Important: Group Chat IDs start with a hyphen (
-). Don't forget to include it.
5. Finalize Configuration
-
Stop the server and open telefabric.yml again.
-
Add the Chat ID(s) and admin User ID(s) to the appropriate fields.
# A list of chat IDs the bot will listen to and broadcast messages to.
chats: [-100123456789, -1145141919810] # <-- Replace with your Chat ID(s)
features:
# ...
bot_cmd_command:
enabled: true
commands:
whitelist:
# A list of user IDs allowed to execute this command from Telegram.
allowed_users: [123456789] # <-- Replace with an admin's User ID
permission: users
# ...
# ...
-
Save the file and start your server. The bridge is now fully configured!
-
If you need to apply changes later without restarting the server, you can use the /telefabric reload command in the server console.
Troubleshooting
Incorrect Bot Settings
- Symptom: The bot responds to commands (like
/getid) in a direct message but ignores all commands in the group chat.
- Solution: This is likely due to the bot's privacy settings.
- DM @BotFather and send the
/mybots command.
- Select your bot from the list.
- Navigate to
Bot Settings -> Group Privacy.
- Ensure that group privacy is turned OFF. When disabled, the bot can receive all messages sent in the group.
Acknowledgements
This project was created in memory of a fellow developer.
While searching for a Fabric-Telegram bridge mod for Minecraft 1.21.4, I came across CuteNekoOwO/FabricTgBridge. I was deeply saddened to learn that its creator, MeowBot233, had passed away, and the project would remain on version 1.20 forever. ?️
Inspired by their work, I decided to create a new mod with similar functionality for modern versions of Minecraft. And so, TeleFabric was born.
Dependencies
This project relies on the following open-source libraries:
评论 0
登录后参与评分
还没有评论,来抢沙发吧