Coder Social home page Coder Social logo

Comments (8)

SpriteOvO avatar SpriteOvO commented on September 2, 2024 10

@xgmo9

TG 桌面端在 History 类中有一个 destroyMessage 函数用于销毁消息(即撤回消息),会从其他两处地方调用,分别是主动删除消息和收到服务端消息撤回请求。

Hook 后者的调用处,判断是否是真正的消息(过滤入群、退群提示等),是则存入缓存中,由另一条线程循环处理。

另一条线程,循环遍历所有缓存中的消息,先取到消息的 TimeText (用于显示消息时间的字符串),判断字符串是否有效(TG 设计仅在当前打开的群/频道中,才会显示有效字符串),在 TimeText 字符串最前面拼接上 "deleted " 即可。

在桌面端中不同状态(是否已编辑、是否署名等)的消息, TimeText 由不同的 RuntimeComponent 管理,里面有一个算法,粗略看了下,重新实现可能比较复杂,于是 workaround 一下直接调用其 Index 函数,可以判断和计算消息状态的 Component 是否存在并得到指针。

加上标记后,需要修改消息宽度,否则会导致消息左移或右移。普通消息直接改消息的 MainView 宽度和 TimeText 的宽度即可,MainView 包含 MainViewMedia 的(通常是 贴纸、large emoji 或 随机 emoji)还需要修改 MainViewMedia 的宽度,回复消息还需要修改 HistoryMessageReply 中的 MaxReply 宽度。
(目前 master 分支中的最新提交对于回复贴纸和随机 emoji 处理有问题,会导致消息位移,会在下个版本中修复,代码目前还没 push 上来)

还 Hook 了 free 函数,原目的是想把强制销毁的消息(跳转到很久以前的消息会导致 TG 清空现有缓存中的所有消息)从插件的缓存中移出去,但是目前来看作用不大,以后有空再尝试改进吧。

大概就这么多。但是移动端如果要做,肯定会和桌面端的实现有出入(甚至我怀疑移动端处理起来可能会更简单,盲猜至少宽度不会这么复杂

from telegram-anti-revoke.

zhihuiyuze avatar zhihuiyuze commented on September 2, 2024 1

您好,linux似乎用不了:P

from telegram-anti-revoke.

SpriteOvO avatar SpriteOvO commented on September 2, 2024 1

@zhihuiyuze 插件准备尝试支持 Linux,相关信息或进度可以到 #39 issue 进行跟踪。

from telegram-anti-revoke.

SpriteOvO avatar SpriteOvO commented on September 2, 2024

理论可行,但能力有限。我只会 Windows C++ 开发,不会移动端的

from telegram-anti-revoke.

TaoChingChung avatar TaoChingChung commented on September 2, 2024

理论可行,但能力有限。我只会 Windows C++ 开发,不会移动端的

真的希望有大佬能跟你一起合作把移动端的防撤回拿下
辛苦了~!

from telegram-anti-revoke.

SpriteOvO avatar SpriteOvO commented on September 2, 2024

@zhihuiyuze 是的,因为 Linux 我也不擅长 :/

from telegram-anti-revoke.

xgmo9 avatar xgmo9 commented on September 2, 2024

作者能讲讲原理吗,只学过java,c++完全看不懂😂😂😂也许我能为它移植到安卓出一份力

from telegram-anti-revoke.

YIRUIJIE avatar YIRUIJIE commented on September 2, 2024

Android Telegram防撤回,这个想法不错!在之前用过QQ的撤回版本,很好用很有趣,如果能够实现在Android TG上,这将是很有趣很实用的一个功能!

from telegram-anti-revoke.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.