slashcommands: add /spoilerimg

This commit is contained in:
ave 2019-10-05 19:51:31 +03:00
parent 45dc42dfee
commit 36e82810c7
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
2 changed files with 181 additions and 28 deletions

View file

@ -1,6 +1,8 @@
diff -crB com.discord-963-base/smali/com/discord/models/domain/ModelChannel.smali com.discord-963/smali/com/discord/models/domain/ModelChannel.smali Only in com.discord-967: build
*** com.discord-963-base/smali/com/discord/models/domain/ModelChannel.smali 2019-10-01 22:09:20.573988563 +0300 Only in com.discord-967: dist
--- com.discord-963/smali/com/discord/models/domain/ModelChannel.smali 2019-10-01 22:47:54.389314892 +0300 diff -crB com.discord-967-base/smali/com/discord/models/domain/ModelChannel.smali com.discord-967/smali/com/discord/models/domain/ModelChannel.smali
*** com.discord-967-base/smali/com/discord/models/domain/ModelChannel.smali 2019-10-05 16:19:00.004261125 +0300
--- com.discord-967/smali/com/discord/models/domain/ModelChannel.smali 2019-10-05 19:10:43.321011414 +0300
*************** ***************
*** 2193,2198 **** *** 2193,2198 ****
--- 2193,2208 ---- --- 2193,2208 ----
@ -20,11 +22,9 @@ diff -crB com.discord-963-base/smali/com/discord/models/domain/ModelChannel.smal
.line 270 .line 270
iget-object v0, p0, Lcom/discord/models/domain/ModelChannel;->permissionOverwrites:Ljava/util/Map; iget-object v0, p0, Lcom/discord/models/domain/ModelChannel;->permissionOverwrites:Ljava/util/Map;
Only in com.discord-963/smali/com/discord/models/domain: ModelChannel.smali.orig diff -crB com.discord-967-base/smali/com/discord/stores/StoreMessages.smali com.discord-967/smali/com/discord/stores/StoreMessages.smali
Only in com.discord-963/smali/com/discord/models/domain: ModelChannel.smali.rej *** com.discord-967-base/smali/com/discord/stores/StoreMessages.smali 2019-10-05 16:19:00.147595419 +0300
diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.discord-963/smali/com/discord/stores/StoreMessages.smali --- com.discord-967/smali/com/discord/stores/StoreMessages.smali 2019-10-05 19:46:25.046923530 +0300
*** com.discord-963-base/smali/com/discord/stores/StoreMessages.smali 2019-10-01 22:09:20.797323381 +0300
--- com.discord-963/smali/com/discord/stores/StoreMessages.smali 2019-10-01 22:47:11.022360664 +0300
*************** ***************
*** 432,437 **** *** 432,437 ****
--- 432,441 ---- --- 432,441 ----
@ -40,7 +40,7 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
*************** ***************
*** 954,959 **** *** 954,959 ****
--- 958,3739 ---- --- 958,3788 ----
return-void return-void
.end method .end method
@ -132,6 +132,29 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
+ return-object p0 + return-object p0
+ .end method + .end method
+ +
+ .method public static final slashSpoilerImg(Ljava/lang/String;)Ljava/lang/String;
+ .locals 3
+
+ # Length of command
+ const/16 v0, 0xb
+
+ invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;
+
+ move-result-object p0
+
+ # Set image spoiler thing
+
+ const/4 v1, 0x1
+
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v2
+
+ invoke-virtual {v2, v1}, Lcom/discord/stores/StoreUserSettings;->setImageSpoiler(Z)V
+
+ return-object p0
+ .end method
+
+ .method public static final slashMe(Ljava/lang/String;)Ljava/lang/String; + .method public static final slashMe(Ljava/lang/String;)Ljava/lang/String;
+ .locals 2 + .locals 2
+ +
@ -2764,7 +2787,7 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
+ +
+ move-result v0 + move-result v0
+ +
+ if-eqz v0, :cond_0 + if-eqz v0, :cond_17
+ +
+ invoke-static {p0}, Lcom/discord/stores/StoreMessages;->slashMorse(Ljava/lang/String;)Ljava/lang/String; + invoke-static {p0}, Lcom/discord/stores/StoreMessages;->slashMorse(Ljava/lang/String;)Ljava/lang/String;
+ +
@ -2772,6 +2795,22 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
+ +
+ goto :goto_0 + goto :goto_0
+ +
+ # SpoilerImg command
+ :cond_17
+ const-string v0, "/spoilerimg"
+
+ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
+
+ move-result v0
+
+ if-eqz v0, :cond_0
+
+ invoke-static {p0}, Lcom/discord/stores/StoreMessages;->slashSpoilerImg(Ljava/lang/String;)Ljava/lang/String;
+
+ move-result-object p0
+
+ goto :goto_0
+
+ :cond_0 + :cond_0
+ :goto_0 + :goto_0
+ # And finally, trim output before sending it back + # And finally, trim output before sending it back
@ -2783,8 +2822,18 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
+ .end method + .end method
+ +
+ .method public static final interceptSendMessage(Ljava/lang/String;)Ljava/lang/String; + .method public static final interceptSendMessage(Ljava/lang/String;)Ljava/lang/String;
+ .locals 2 + .locals 3
+ +
+ # Intercept all messages and set image spoiler to false
+ const/4 v1, 0x0
+
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v2
+
+ invoke-virtual {v2, v1}, Lcom/discord/stores/StoreUserSettings;->setImageSpoiler(Z)V
+
+ # Do regular intercept things
+ const-string v0, "/" + const-string v0, "/"
+ +
+ invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z + invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
@ -2825,7 +2874,7 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
.annotation system Ldalvik/annotation/Signature; .annotation system Ldalvik/annotation/Signature;
*************** ***************
*** 983,988 **** *** 983,988 ****
--- 3763,3772 ---- --- 3812,3821 ----
invoke-static {p4, v0}, Lkotlin/jvm/internal/k;->h(Ljava/lang/Object;Ljava/lang/String;)V invoke-static {p4, v0}, Lkotlin/jvm/internal/k;->h(Ljava/lang/Object;Ljava/lang/String;)V
@ -2836,12 +2885,12 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreMessages.smali com.
const/4 v0, 0x1 const/4 v0, 0x1
if-eqz p6, :cond_0 if-eqz p6, :cond_0
diff -crB com.discord-963-base/smali/com/discord/stores/StoreUserSettings.smali com.discord-963/smali/com/discord/stores/StoreUserSettings.smali diff -crB com.discord-967-base/smali/com/discord/stores/StoreUserSettings.smali com.discord-967/smali/com/discord/stores/StoreUserSettings.smali
*** com.discord-963-base/smali/com/discord/stores/StoreUserSettings.smali 2019-10-01 22:09:20.853990424 +0300 *** com.discord-967-base/smali/com/discord/stores/StoreUserSettings.smali 2019-10-05 16:19:00.170928909 +0300
--- com.discord-963/smali/com/discord/stores/StoreUserSettings.smali 2019-10-01 22:47:11.025694020 +0300 --- com.discord-967/smali/com/discord/stores/StoreUserSettings.smali 2019-10-05 19:29:35.161160111 +0300
*************** ***************
*** 1294,1299 **** *** 1294,1299 ****
--- 1294,1474 ---- --- 1294,1510 ----
return v0 return v0
.end method .end method
@ -2881,6 +2930,42 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreUserSettings.smali
+ return-void + return-void
+ .end method + .end method
+ +
+ .method public getImageSpoiler()Z
+ .locals 3
+
+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences;
+
+ const-string v1, "CACHE_KEY_CTC_IMAGE_SPOILER"
+
+ const/4 v2, 0x0
+
+ invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z
+
+ move-result v0
+
+ return v0
+ .end method
+
+ .method public setImageSpoiler(Z)V
+ .locals 2
+
+ iget-object v0, p0, Lcom/discord/stores/StoreUserSettings;->prefs:Landroid/content/SharedPreferences;
+
+ invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;
+
+ move-result-object v0
+
+ const-string v1, "CACHE_KEY_CTC_IMAGE_SPOILER"
+
+ invoke-interface {v0, v1, p1}, Landroid/content/SharedPreferences$Editor;->putBoolean(Ljava/lang/String;Z)Landroid/content/SharedPreferences$Editor;
+
+ move-result-object p1
+
+ invoke-interface {p1}, Landroid/content/SharedPreferences$Editor;->apply()V
+
+ return-void
+ .end method
+
+ .method public getShowTyping()Z + .method public getShowTyping()Z
+ .locals 3 + .locals 3
+ +
@ -3023,10 +3108,9 @@ diff -crB com.discord-963-base/smali/com/discord/stores/StoreUserSettings.smali
.method handleConnectionOpen(Lcom/discord/models/domain/ModelPayload;)V .method handleConnectionOpen(Lcom/discord/models/domain/ModelPayload;)V
.locals 0 .locals 0
Only in com.discord-963/smali/com/discord/stores: StoreUserSettings.smali.orig diff -crB com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali
diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali *** com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2019-10-05 16:19:00.327596627 +0300
*** com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2019-10-01 22:09:21.107325442 +0300 --- com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2019-10-05 19:10:43.327678122 +0300
--- com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputEditText$1.smali 2019-10-01 22:47:11.025694020 +0300
*************** ***************
*** 55,60 **** *** 55,60 ****
--- 55,70 ---- --- 55,70 ----
@ -3046,10 +3130,9 @@ diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatIn
.line 222 .line 222
invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
Only in com.discord-963/smali/com/discord/widgets/chat/input: WidgetChatInputEditText$1.smali.orig diff -crB com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali
diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali *** com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-10-05 16:19:00.330929983 +0300
*** com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-10-01 22:09:21.110658797 +0300 --- com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-10-05 19:10:43.327678122 +0300
--- com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputSend$configureSendListeners$1.smali 2019-10-01 22:47:11.025694020 +0300
*************** ***************
*** 371,376 **** *** 371,376 ****
--- 371,402 ---- --- 371,402 ----
@ -3085,10 +3168,9 @@ diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatIn
invoke-static {v10, v2}, Lkotlin/jvm/internal/k;->g(Ljava/lang/Object;Ljava/lang/String;)V invoke-static {v10, v2}, Lkotlin/jvm/internal/k;->g(Ljava/lang/Object;Ljava/lang/String;)V
.line 74 .line 74
Only in com.discord-963/smali/com/discord/widgets/chat/input: WidgetChatInputSend$configureSendListeners$1.smali.orig diff -crB com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali
diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali *** com.discord-967-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-10-05 16:19:00.330929983 +0300
*** com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-10-01 22:09:21.110658797 +0300 --- com.discord-967/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-10-05 19:10:43.327678122 +0300
--- com.discord-963/smali/com/discord/widgets/chat/input/WidgetChatInputSend.smali 2019-10-01 22:47:11.025694020 +0300
*************** ***************
*** 60,65 **** *** 60,65 ****
--- 60,89 ---- --- 60,89 ----
@ -3122,4 +3204,74 @@ diff -crB com.discord-963-base/smali/com/discord/widgets/chat/input/WidgetChatIn
.method private final clearInput(Lcom/discord/widgets/chat/input/WidgetChatInputEditText;)Z .method private final clearInput(Lcom/discord/widgets/chat/input/WidgetChatInputEditText;)Z
.locals 1 .locals 1
diff -crB com.discord-967-base/smali/okhttp3/MultipartBody$Part.smali com.discord-967/smali/okhttp3/MultipartBody$Part.smali
*** com.discord-967-base/smali/okhttp3/MultipartBody$Part.smali 2019-10-05 16:19:00.700932465 +0300
--- com.discord-967/smali/okhttp3/MultipartBody$Part.smali 2019-10-05 19:45:23.729878243 +0300
***************
*** 43,50 ****
return-void
.end method
.method public static a(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
! .locals 2
.param p1 # Ljava/lang/String;
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
--- 43,84 ----
return-void
.end method
+ .method public static final interceptFilename(Ljava/lang/String;)Ljava/lang/String;
+ .locals 3
+
+ invoke-static {}, Lcom/discord/stores/StoreStream;->getUserSettings()Lcom/discord/stores/StoreUserSettings;
+
+ move-result-object v0
+
+ invoke-virtual {v0}, Lcom/discord/stores/StoreUserSettings;->getImageSpoiler()Z
+
+ move-result v1
+
+ if-eqz v1, :cond_1
+
+ new-instance v2, Ljava/lang/StringBuilder;
+
+ const-string v1, "SPOILER_"
+
+ invoke-direct {v2, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
+
+ invoke-virtual {v2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+ invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
+
+ move-result-object p0
+
+ # I commented this out and do this in StoreMessages now as this'd only work for a single image
+ # const/4 v1, 0x0
+
+ # invoke-virtual {v0, v1}, Lcom/discord/stores/StoreUserSettings;->setImageSpoiler(Z)V
+
+ :cond_1
+ return-object p0
+ .end method
+
.method public static a(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
! .locals 5
.param p1 # Ljava/lang/String;
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
***************
*** 69,74 ****
--- 103,113 ----
.line 255
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+ invoke-static {p1}, Lokhttp3/MultipartBody$Part;->interceptFilename(Ljava/lang/String;)Ljava/lang/String;
+
+ move-result-object p1
+
+ :cond_2
.line 256
invoke-static {v0, p1}, Lokhttp3/MultipartBody;->a(Ljava/lang/StringBuilder;Ljava/lang/String;)Ljava/lang/StringBuilder;

View file

@ -7,6 +7,7 @@ The following slash commands are supported:
- /lower -> Makes text lowercase - /lower -> Makes text lowercase
- /bold -> Makes text bold - /bold -> Makes text bold
- /spoiler -> Marks your message as a spoiler (same as Discord Desktop) - /spoiler -> Marks your message as a spoiler (same as Discord Desktop)
- /spoilerimg -> Prepends SPOILER_ to names of all images attached to the message that starts with this, causing them to get marked as spoiler.
- /me -> Display text with emphasis (same as Discord Desktop) - /me -> Display text with emphasis (same as Discord Desktop)
- /st -> Puts a strikethrough the message - /st -> Puts a strikethrough the message
- /shrug -> Appends ¯\\_(ツ)_/¯ to your message (same as Discord Desktop) - /shrug -> Appends ¯\\_(ツ)_/¯ to your message (same as Discord Desktop)