commit 9e547bfe0ccd72feba961336570f42065d8109ae
parent d0e26509cbf0afffb27301a3e81821ded8bffb0d
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Sun, 24 Sep 2023 12:26:09 +0200

feat: snap to chat media

Diffstat:
Mcore/src/main/assets/lang/en_US.json | 4++++
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt | 1+
Acore/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt | 29+++++++++++++++++++++++++++++
Mcore/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt | 2++
4 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/core/src/main/assets/lang/en_US.json b/core/src/main/assets/lang/en_US.json @@ -304,6 +304,10 @@ "name": "Prevent Message Sending", "description": "Prevents sending certain types of messages" }, + "snap_to_chat_media": { + "name": "Snap to Chat Media", + "description": "Converts snaps to chat external media" + }, "better_notifications": { "name": "Better Notifications", "description": "Adds more information in received notifications" diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/MessagingTweaks.kt @@ -17,6 +17,7 @@ class MessagingTweaks : ConfigContainer() { "EXTERNAL_MEDIA", "STICKER" ) + val snapToChatMedia = boolean("snap_to_chat_media") val preventMessageSending = multiple("prevent_message_sending", *NotificationType.getOutgoingValues().map { it.key }.toTypedArray()) { customOptionTranslationPath = "features.options.notifications" } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt b/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/spying/SnapToChatMedia.kt @@ -0,0 +1,28 @@ +package me.rhunk.snapenhance.features.impl.spying + +import me.rhunk.snapenhance.core.util.protobuf.ProtoReader +import me.rhunk.snapenhance.core.util.protobuf.ProtoWriter +import me.rhunk.snapenhance.data.ContentType +import me.rhunk.snapenhance.data.wrapper.impl.Message +import me.rhunk.snapenhance.features.Feature +import me.rhunk.snapenhance.features.FeatureLoadParams +import me.rhunk.snapenhance.hook.HookStage +import me.rhunk.snapenhance.hook.hookConstructor + +class SnapToChatMedia : Feature("SnapToChatMedia", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + if (!context.config.messaging.snapToChatMedia.get()) return + context.classCache.message.hookConstructor(HookStage.AFTER) { param -> + val message = Message(param.thisObject()) + + if (message.messageContent.contentType != ContentType.SNAP) return@hookConstructor + + val snapMessageContent = ProtoReader(message.messageContent.content).followPath(11)?.getBuffer() ?: return@hookConstructor + message.messageContent.content = ProtoWriter().apply { + from(3) { + addBuffer(3, snapMessageContent) + } + }.toByteArray() + } + } +}+ \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt @@ -15,6 +15,7 @@ import me.rhunk.snapenhance.features.impl.privacy.PreventMessageSending import me.rhunk.snapenhance.features.impl.spying.AnonymousStoryViewing import me.rhunk.snapenhance.features.impl.spying.MessageLogger import me.rhunk.snapenhance.features.impl.spying.PreventReadReceipts +import me.rhunk.snapenhance.features.impl.spying.SnapToChatMedia import me.rhunk.snapenhance.features.impl.spying.StealthMode import me.rhunk.snapenhance.features.impl.tweaks.* import me.rhunk.snapenhance.features.impl.ui.ClientBootstrapOverride @@ -84,6 +85,7 @@ class FeatureManager(private val context: ModContext) : Manager { AddFriendSourceSpoof::class, DisableReplayInFF::class, OldBitmojiSelfie::class, + SnapToChatMedia::class, ) initializeFeatures()