From 29d913aab21a5ff377a486f20d6eb30442e3b703 Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Sun, 26 May 2019 18:19:04 +0300 Subject: [PATCH] slashcommands: Add /token command --- patches/slashcommands/903.patch | 166 +++++++++++++++++++++++++++----- patches/slashcommands/README.md | 4 +- 2 files changed, 147 insertions(+), 23 deletions(-) diff --git a/patches/slashcommands/903.patch b/patches/slashcommands/903.patch index 43e24c6..677a84c 100644 --- a/patches/slashcommands/903.patch +++ b/patches/slashcommands/903.patch @@ -1,5 +1,3 @@ -Only in com.discord-903: build -Only in com.discord-903: dist diff -crB com.discord-903-base/smali/com/discord/models/domain/ModelChannel.smali com.discord-903/smali/com/discord/models/domain/ModelChannel.smali *** com.discord-903-base/smali/com/discord/models/domain/ModelChannel.smali 2019-05-24 23:40:49.520802264 +0300 --- com.discord-903/smali/com/discord/models/domain/ModelChannel.smali 2019-05-26 16:28:14.734931852 +0300 @@ -24,7 +22,7 @@ diff -crB com.discord-903-base/smali/com/discord/models/domain/ModelChannel.smal diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com.discord-903/smali/com/discord/stores/StoreMessages.smali *** com.discord-903-base/smali/com/discord/stores/StoreMessages.smali 2019-05-24 23:40:49.670802999 +0300 ---- com.discord-903/smali/com/discord/stores/StoreMessages.smali 2019-05-26 17:06:36.361509248 +0300 +--- com.discord-903/smali/com/discord/stores/StoreMessages.smali 2019-05-26 18:11:36.112395942 +0300 *************** *** 432,437 **** --- 432,441 ---- @@ -40,7 +38,7 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. *************** *** 948,953 **** ---- 952,3560 ---- +--- 952,3606 ---- return-void .end method @@ -2231,10 +2229,6 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. + + move-result-object p0 + -+ invoke-virtual {p0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String; -+ -+ move-result-object p0 -+ + # Move to second word interpretation + + const-string v0, "channelleak " @@ -2267,7 +2261,7 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. + + invoke-virtual {v0, v1}, Lcom/discord/stores/StoreUserSettings;->setLeakChannels(Z)V + -+ const-string p0, "CTC: Set leakchannels state. (Under ideal conditions this should only be visible to you, but the world isn't always that fair, is it now?)" ++ const-string p0, "CTC: Successfully set leakchannels state." + + return-object p0 + @@ -2280,7 +2274,7 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. + + move-result v0 + -+ if-eqz v0, :cond_1 ++ if-eqz v0, :cond_3 + + # Move to config value interpretation + @@ -2304,12 +2298,62 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. + + invoke-virtual {v0, v1}, Lcom/discord/stores/StoreUserSettings;->setShowTyping(Z)V + -+ const-string p0, "CTC: Set showtyping state. (Under ideal conditions this should only be visible to you, but the world isn't always that fair, is it now?)" ++ const-string p0, "CTC: Successfully set showtyping state." ++ ++ return-object p0 ++ ++ :cond_3 ++ const-string v0, "token " ++ ++ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z ++ ++ move-result v0 ++ ++ if-eqz v0, :cond_4 ++ ++ # Move to config value interpretation ++ ++ const/16 v0, 0x6 ++ ++ invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ # Set value ++ ++ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings; ++ ++ move-result-object v0 ++ ++ invoke-virtual {v0, p0}, Lcom/discord/stores/StoreUserSettings;->setStoredToken(Ljava/lang/String;)V ++ ++ const-string p0, "CTC: Successfully changed token. Please restart application." ++ ++ return-object p0 ++ ++ :cond_4 ++ const-string v0, "token" ++ ++ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z ++ ++ move-result v0 ++ ++ if-eqz v0, :cond_1 ++ ++ # Get value ++ ++ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings; ++ ++ move-result-object v0 ++ ++ invoke-virtual {v0}, Lcom/discord/stores/StoreUserSettings;->getStoredToken()Ljava/lang/String; ++ ++ move-result-object p0 + + return-object p0 + + :cond_1 -+ const-string p0, "CTC: No known command supplied. (Under ideal conditions this should only be visible to you, but the world isn't always that fair, is it now?)" ++ const-string p0, "CTC: No known command supplied. (available: token, showtyping or channelleak. everything except specified token needs to be lowercase)" + + return-object p0 + .end method @@ -2652,7 +2696,7 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. .annotation system Ldalvik/annotation/Signature; *************** *** 977,982 **** ---- 3584,3593 ---- +--- 3630,3639 ---- invoke-static {p4, v0}, Lkotlin/jvm/internal/k;->h(Ljava/lang/Object;Ljava/lang/String;)V @@ -2665,17 +2709,16 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreMessages.smali com. if-eqz p6, :cond_0 diff -crB com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali com.discord-903/smali/com/discord/stores/StoreUserSettings.smali *** com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali 2019-05-24 23:40:49.700803146 +0300 ---- com.discord-903/smali/com/discord/stores/StoreUserSettings.smali 2019-05-26 16:28:45.931787947 +0300 +--- com.discord-903/smali/com/discord/stores/StoreUserSettings.smali 2019-05-26 18:03:13.643331588 +0300 *************** *** 1272,1277 **** ---- 1272,1353 ---- +--- 1272,1387 ---- return v0 .end method + .method public getLeakChannels()Z + .locals 3 + -+ .line 179 + iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; + + const-string v1, "CACHE_KEY_CTC_LEAK_CHANNELS" @@ -2692,7 +2735,6 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali + .method public setLeakChannels(Z)V + .locals 2 + -+ .line 331 + iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; @@ -2713,7 +2755,6 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali + .method public getShowTyping()Z + .locals 3 + -+ .line 179 + iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; + + const-string v1, "CACHE_KEY_CTC_SHOW_TYPING" @@ -2730,7 +2771,6 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali + .method public setShowTyping(Z)V + .locals 2 + -+ .line 331 + iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences; + + invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; @@ -2747,6 +2787,44 @@ diff -crB com.discord-903-base/smali/com/discord/stores/StoreUserSettings.smali + + return-void + .end method ++ ++ ++ .method public getStoredToken()Ljava/lang/String; ++ .locals 3 ++ ++ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ ++ const-string v1, "none" ++ ++ const-string v2, "STORE_AUTHED_TOKEN" ++ ++ invoke-interface {v0, v2, v1}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ++ ++ move-result-object v0 ++ ++ return-object v0 ++ .end method ++ ++ ++ .method public setStoredToken(Ljava/lang/String;)V ++ .locals 2 ++ ++ iget-object v0, p0, Lcom/discord/stores/StoreAuthentication;->prefs:Landroid/content/SharedPreferences; ++ ++ invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor; ++ ++ move-result-object v0 ++ ++ const-string v1, "STORE_AUTHED_TOKEN" ++ ++ invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor; ++ ++ move-result-object p1 ++ ++ invoke-interface {p1}, Landroid/content/SharedPreferences$Editor;->apply()V ++ ++ return-void ++ .end method + .method handleConnectionOpen(Lcom/discord/models/domain/ModelPayload;)V .locals 0 @@ -2775,7 +2853,7 @@ diff -crB com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatIn diff -crB com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali com.discord-903/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali *** com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-05-24 23:40:49.907470826 +0300 ---- com.discord-903/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-05-26 17:12:27.753183346 +0300 +--- com.discord-903/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-05-26 17:40:46.959503995 +0300 *************** *** 355,360 **** --- 355,362 ---- @@ -2789,7 +2867,7 @@ diff -crB com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatIn .line 63 *************** *** 399,404 **** ---- 401,436 ---- +--- 401,444 ---- move-result-object v8 @@ -2819,10 +2897,54 @@ diff -crB com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatIn + + # invoke-virtual {v9}, Landroid/widget/Toast;->show()V + -+ goto :goto_2 ++ sget-object p1, Lcom/discord/widgets/chat/input/WidgetChatInputSend;->INSTANCE:Lcom/discord/widgets/chat/input/WidgetChatInputSend; ++ ++ iget-object v0, p0, Lcom/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1;->$chatInput:Lcom/discord/widgets/chat/input/WidgetChatInputEditText; ++ ++ invoke-static {p1, v0, v8}, Lcom/discord/widgets/chat/input/WidgetChatInputSend;->access$SetInput(Lcom/discord/widgets/chat/input/WidgetChatInputSend;Lcom/discord/widgets/chat/input/WidgetChatInputEditText;Ljava/lang/CharSequence;)Z ++ ++ move-result p1 ++ ++ return p1 + + :cond_6 + invoke-static {v8, v3}, Lkotlin/jvm/internal/k;->g(Ljava/lang/Object;Ljava/lang/String;)V .line 79 +diff -crB com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali com.discord-903/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali +*** com.discord-903-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-05-24 23:40:49.907470826 +0300 +--- com.discord-903/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-05-26 17:40:34.489430375 +0300 +*************** +*** 50,55 **** +--- 50,79 ---- + return p0 + .end method + ++ .method public static final access$SetInput(Lcom/discord/widgets/chat/input/WidgetChatInputSend;Lcom/discord/widgets/chat/input/WidgetChatInputEditText;Ljava/lang/CharSequence;)Z ++ .locals 1 ++ ++ .line 147 ++ invoke-virtual {p1, p2}, Lcom/discord/widgets/chat/input/WidgetChatInputEditText;->setText(Ljava/lang/CharSequence;)V ++ ++ .line 148 ++ invoke-virtual {p1}, Lcom/discord/widgets/chat/input/WidgetChatInputEditText;->clearLastTypingEmission()V ++ ++ .line 151 ++ invoke-static {}, Lcom/discord/stores/StoreStream;->getChat()Lcom/discord/stores/StoreChat; ++ ++ move-result-object p1 ++ ++ const/4 v0, 0x0 ++ ++ .line 152 ++ invoke-virtual {p1, v0}, Lcom/discord/stores/StoreChat;->setEditingMessage(Lcom/discord/stores/StoreChat$EditingMessage;)V ++ ++ const/4 p1, 0x1 ++ ++ return p1 ++ .end method ++ + .method private final clearInput(Lcom/discord/widgets/chat/input/WidgetChatInputEditText;)Z + .locals 1 + diff --git a/patches/slashcommands/README.md b/patches/slashcommands/README.md index 42faac0..45d95c3 100644 --- a/patches/slashcommands/README.md +++ b/patches/slashcommands/README.md @@ -24,7 +24,9 @@ Following commands are supported, but create less accessible text (so you should CutTheCord has a couple features that can be enabled or disabled with slash commands as well: - /ctc channelleak true/false -> Shows all channels, even those you don't have permissions to view (might mess with channel editing or editing while it's enabled) -- /ctc notyping true/false -> Disables typing event so that it's not visible when you type +- /ctc notyping true/false -> Disables typing event so that it's not visible when you type (true = typing is shown, false = not shown) +- /ctc token -> Gives your token +- /ctc token $token -> Sets your token to the one specified, allowing switching between accounts Commands like fw can be generated by `textreplacegen.py` or `textreplacegen-array.py` provided in this folder.