Skip to content

Commit cf92e9f

Browse files
committed
feat: hide stories from service notifications
1 parent ea20b5e commit cf92e9f

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

app/src/main/java/cc/ioctl/tmoe/fragment/SettingsFragment.kt

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class SettingsFragment : BaseHierarchyFragment() {
125125
ShowExactLastSeenTime, "ShowExactLastSeenTime", R.string.ShowExactLastSeenTime,
126126
"ShowExactLastSeenTimeDesc", R.string.ShowExactLastSeenTimeDesc
127127
)
128+
functionSwitch(
129+
HideServiceStories, "HideServiceStories", R.string.HideServiceStories
130+
)
128131
}
129132
category("LostMsgMitigation", R.string.LostMsgMitigation) {
130133
functionSwitch(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cc.ioctl.tmoe.hook.func
2+
3+
import cc.ioctl.tmoe.base.annotation.FunctionHookEntry
4+
import cc.ioctl.tmoe.hook.base.CommonDynamicHook
5+
import com.github.kyuubiran.ezxhelper.utils.argTypes
6+
import com.github.kyuubiran.ezxhelper.utils.field
7+
import com.github.kyuubiran.ezxhelper.utils.hookAfter
8+
import com.github.kyuubiran.ezxhelper.utils.loadClass
9+
import com.github.kyuubiran.ezxhelper.utils.method
10+
import com.github.kyuubiran.ezxhelper.utils.staticMethod
11+
import com.github.kyuubiran.ezxhelper.utils.tryOrLogFalse
12+
13+
@FunctionHookEntry
14+
object HideServiceStories : CommonDynamicHook() {
15+
override fun initOnce(): Boolean = tryOrLogFalse {
16+
// Telegram uses this method to decide if users can hide the stories
17+
// https://github.com/DrKLO/Telegram/blob/a906f12aaec2768969c77650a7e4b377baa6cf2a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java#L4913-L4916
18+
val mIsService = loadClass("org.telegram.messenger.UserObject").staticMethod(
19+
"isService",
20+
Boolean::class.java,
21+
argTypes(Long::class.java)
22+
)
23+
val kUser = loadClass("org.telegram.tgnet.TLRPC\$User")
24+
val fHidden = kUser.field("stories_hidden", false, Boolean::class.java)
25+
loadClass("org.telegram.messenger.MessagesController").method(
26+
"getUser",
27+
kUser,
28+
false,
29+
argTypes(Long::class.javaObjectType)
30+
).hookAfter { param ->
31+
if (isEnabled && mIsService.invoke(null, param.args[0]) == true) {
32+
fHidden.set(param.result, true)
33+
}
34+
}
35+
}
36+
}

app/src/main/res/values-zh-rCN/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@
6363
<string name="ShowExactLastSeenTime">最后上线精确到秒</string>
6464
<string name="ShowExactLastSeenTimeDesc">仅对有权限查看用户最后上线时间的用户有效</string>
6565
<string name="DisableInstantCamera">禁用即时相机</string>
66+
<string name="HideServiceStories">隐藏“服务通知”的动态</string>
6667
</resources>

app/src/main/res/values-zh-rTW/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@
4444
<string name="AddReloadMsgBtn">新增重新整理訊息按鈕</string>
4545
<string name="AddReloadMsgBtnDesc">在聊天選單新增重新整理訊息按鈕</string>
4646
<string name="KeepVideoMuted">按音量鍵時保持影片靜音</string>
47+
<string name="HideServiceStories">隱藏“服務通知”的動態</string>
4748
</resources>

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@
9191
<string name="FuckTrackingHook">Remove tracking</string>
9292
<string name="FuckTrackingHookDesc">If you click on an ad provided by Telegram, they will track it and might use it as the basis for personalizing the ad.This function is to disable it</string>
9393
<string name="DisableInstantCamera">Disable Instant Camera</string>
94+
<string name="HideServiceStories">Hide stories from service notifications</string>
9495
</resources>

0 commit comments

Comments
 (0)