Comments (8)
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.
您好,linux似乎用不了:P
from telegram-anti-revoke.
@zhihuiyuze 插件准备尝试支持 Linux,相关信息或进度可以到 #39 issue 进行跟踪。
from telegram-anti-revoke.
理论可行,但能力有限。我只会 Windows C++ 开发,不会移动端的
from telegram-anti-revoke.
理论可行,但能力有限。我只会 Windows C++ 开发,不会移动端的
啊真的希望有大佬能跟你一起合作把移动端的防撤回拿下
辛苦了~!
from telegram-anti-revoke.
@zhihuiyuze 是的,因为 Linux 我也不擅长 :/
from telegram-anti-revoke.
作者能讲讲原理吗,只学过java,c++完全看不懂😂😂😂也许我能为它移植到安卓出一份力
from telegram-anti-revoke.
Android Telegram防撤回,这个想法不错!在之前用过QQ的撤回版本,很好用很有趣,如果能够实现在Android TG上,这将是很有趣很实用的一个功能!
from telegram-anti-revoke.
Related Issues (20)
- [Feature Request] Download images as they are delivered HOT 1
- [Bug report] Incorrect work of the plugin with the TG 3.1.7 (beta) HOT 3
- [Bug report] InitDynamicData_EditedIndex() failed. HOT 5
- An error has occurred HOT 2
- [Feature Request] Some ideas HOT 3
- Plugin does not work with Telegram version 3.1.8 X64 Protable HOT 1
- [FIX] InitDynamicData_EditedIndex() failed. HOT 2
- 能否找出所有被刪除的信息 HOT 1
- [Feature Request] 請問能增加匯出已經刪除對話訊息的功能嗎? Could you add the function of exporting deleted dialog messages? HOT 1
- [Feature Request] Hide sponsored messages HOT 2
- 64gram compatibility HOT 5
- Not working since v3.2.5 (x86 only) HOT 14
- [Bug report] InitDynamicData() failed in Telegram Desktop x86 (Version3.2.5)(在Telegram桌面版(版本3.2.5)中出现"InitDynamicData() failed"异常) HOT 1
- [Bug report] 插件失效 Failure to work
- [Question] new version HOT 1
- [Bug report] Failures on Telegram 3.2.6 HOT 5
- [Feature Request] Show origin content if message being edited HOT 1
- [Question] Deteled message disappeared after the program restart HOT 2
- an error has occurred /... this most time happened after update telegram HOT 2
- [Bug report] Crash on Telegram 3.3 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-anti-revoke.