Tool:Zhmrtbot
![]() | |
---|---|
Description | Chinese Message Rapid Transport Bot |
Keywords | irc, node |
Maintainer(s) | WhitePhosphorus and others (View all) |
Source code | https://github.com/fossifer/LilyWhiteBot |
License | GNU Affero General Public License 3.0 |
zhmrtbot is a bot deployed on Toolforge which bridges messages between Telegram, IRC (Libera.Chat), Discord, and Tencent QQ.
Technical details related to bot maintenance are tentatively written in Chinese because it is the primary language used by bot maintainers and users. If you need English translations, please contact WhitePhosphorus.
Bot accounts
The bot is currently running in various Wikimedia related groups in Chinese language. To request new bridges, please contact one of the maintainers. Merely adding the bot to new groups will not have any effect.
- libera.chat IRC
-
- account: zhmrtbot
- nick: zhmrtbot (sometimes zhmrtbot1)
- Telegram
-
- account: zhmrtbot
- Discord
-
- account: IRC-Bridge#2251
程序位置
本文中 ~
或 $HOME
为家目录,位于 /data/project/zhmrtbot
。
~/LilyWhiteBot
是生产环境所在目录。~/LilyWhiteBotTest/LilyWhiteBot
是测试环境所在目录。二者可以同时运行。
这两个目录的 git origin remote 是 https://github.com/lziad/LilyWhiteBot.git ,注意代码在 reborn
branch 下(以后可能会改)。其他的目录请尽量不要修改,可以随便看。
配置文件
以下假设当前目录是 ~/LilyWhiteBot
,测试环境文件结构一样。比较重要的文件位置:
config.yaml
是机器人的配置文件,许多设定都在这里完成。(是yaml
不是yml
,代码遗留问题)badwords.yml
是转发到 QQ 会变成星号的敏感词列表。
请确保你了解 yaml 文件格式和正则表达式再进行更改。
另外可以参考 config.example.yml
,里面有详细注释各项配置的功能。
filter 的部分主要是防止 Telegram 上一些 G11 的关键字被转发出去,是区分大小写的正则表达式,需要经常更新。注意特殊符号转义需要用两个反斜杠,例如 +
-> \\+
。如果你看不懂这里在说什么,请不要改。更新完需要重启机器人。
常用命令
重启:
~/bin/zhmrtbot.sh restart # 重启生产环境
~/bin/zhmrtbot-test.sh restart # 重启测试环境,没什么用,因为平时不跑
restart
可以换成 start
和 stop
,功能就不用说了吧。
查看机器人运行状态:
~/bin/zhmrtbot.sh status
输出大致如下:
Active pods: NAME READY STATUS RESTARTS AGE zhmrtbot.bot-7ccddd7cfb-nwcwm 1/1 Running 0 233m
如果 STATUS 是 Running 的话就是正常运行。没有看到 zhmrtbot 那行的话说明没在运行。出现 CrashLoopBackOff 的话请通知我。
查看机器人的输出:
~/bin/zhmrtbot.sh tail # 可能会很长,如果看到提示 QQ 需要扫码验证或者被封号了之类的请通知我
自动重启
鉴于机器人运行一段时间后常出现不明问题无法转发出 Telegram 消息,在 ~/etc/zhmrtbot/deployment.yaml
中设定了每天自动重启,通过 livenessProbe 实现。参考这个 StackOverflow 答案及其评论区。command 中的 2030 代表重启的时间 (UTC),即东八区凌晨 4:30,根据主群统计信息东八区 4AM - 5AM 是发言量最少的时间段。请尽量避开机器人重启的时间段进行跨群讨论。
其他方法比如尝试设定 cronjob,或者用 toolforge-jobs
提交一个 ./bin/zhmrtbot.sh restart
的方法都行不通,因为基金会给的 docker 环境里没有安装 kubectl。
See also
- Tool:Bridgebot is a similar bridge bot between Telegram, IRC, Discord and Mattermost.