Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

恢复被频道吞掉的 bot 的消息 #22

Open
ConsetHP opened this issue Jan 25, 2025 · 0 comments
Open

恢复被频道吞掉的 bot 的消息 #22

ConsetHP opened this issue Jan 25, 2025 · 0 comments

Comments

@ConsetHP
Copy link
Owner

ConsetHP commented Jan 25, 2025

背景

腾讯频道偶尔会吞消息,像是词云图片这种也就算了,毕竟能手动让 bot 重新生成,但是文字消息吞了就没办法了。而且还有接入AI模型的计划 #21 ,之后 bot 要发送的消息一定会比现在还要多的多,因此需要一个念のため,以防万一的功能

原理

频道吞文字的机制和吞图片是一样的,(猜测)大概是每个频道都有一个隐藏的官方 bot,这个 bot 谁也看不见(即使是频道主)。平时会一直监听频道内所有的 MessageEvent ,接收到 Event 后会有专门的 handle 来检查文字/图片是否违规(涉黄,涉政,脏话),如果发现消息违规就调用撤回并对全员隐藏撤回的 api,之后所有频道用户的客户端都会接收到一个撤回的 Event ,最后 QQ 客户端在接收到了 bot 的撤回 Event 后就把显示在前端 UI 上相关消息删除。这或许也就是为什么消息在吞之前会在客户端上显示几秒钟——本质上就是消息被撤回了。

至于为什么腾讯要把拦截功能做在后端服务器上,而不是在前端检测违规消息并拦截(毕竟这样可以把 违规 的消息扼杀在摇篮中),也许是为了不让竞争对手逆向出检测相关的代码?或者是因为检测比较吃性能,而且还要适配电脑手机不同操作系统的各种客户端很麻烦,所以就没做在前端。

总结

无论如何,多亏了这个机制,我可以像之前加入的恢复普通用户被吞的图片的功能一样加入恢复文字的功能,只不过需要将文字渲染成图片,然后尝试降低分辨率 + 添加噪点之类的,想办法让图片防 OCR 但确保人眼可以分辨文字内容应该就行。

除非藤子的 OCR 识别特别强大,那就再说吧

@ConsetHP ConsetHP added this to the 屋岛 Bot 的 Todo-List milestone Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant