From 8fc56562f39e2d5c8e98114ca7b0f0526d7c22de Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Tue, 21 May 2019 19:36:08 +0300 Subject: [PATCH] Add morse --- patches/slashcommands/900.patch | 416 +++++++++++++++++- patches/slashcommands/textreplacegen-array.py | 207 +++++---- 2 files changed, 539 insertions(+), 84 deletions(-) diff --git a/patches/slashcommands/900.patch b/patches/slashcommands/900.patch index dac462210b..701845d138 100644 --- a/patches/slashcommands/900.patch +++ b/patches/slashcommands/900.patch @@ -2,7 +2,7 @@ Only in com.discord-900: build Only in com.discord-900: dist diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com.discord-900/smali/com/discord/stores/StoreMessages.smali *** com.discord-900-base/smali/com/discord/stores/StoreMessages.smali 2019-05-19 21:52:46.439797252 +0300 ---- com.discord-900/smali/com/discord/stores/StoreMessages.smali 2019-05-21 17:51:10.909682423 +0300 +--- com.discord-900/smali/com/discord/stores/StoreMessages.smali 2019-05-21 19:28:27.037730466 +0300 *************** *** 432,437 **** --- 432,441 ---- @@ -18,7 +18,7 @@ diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com. *************** *** 948,953 **** ---- 952,3059 ---- +--- 952,3465 ---- return-void .end method @@ -1808,12 +1808,402 @@ diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com. + return-object p0 + .end method + ++ .method public static final slashMorse(Ljava/lang/String;)Ljava/lang/String; ++ .locals 2 ++ ++ # Length of command + space ++ const/16 v0, 0x7 ++ ++ invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ invoke-virtual {p0}, Ljava/lang/String;->toUpperCase()Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ # Start of automatically generated code with textreplacegen.py ++ ++ const-string v0, " " ++ ++ const-string v1, "/ " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "." ++ ++ const-string v1, ".-.-.- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "," ++ ++ const-string v1, "--..-- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, ":" ++ ++ const-string v1, "---... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "?" ++ ++ const-string v1, "..--.. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "'" ++ ++ const-string v1, ".----. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "-" ++ ++ const-string v1, "-....- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "/" ++ ++ const-string v1, "-..-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "@" ++ ++ const-string v1, ".--.-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "=" ++ ++ const-string v1, "-...- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "A" ++ ++ const-string v1, ".- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "B" ++ ++ const-string v1, "-... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "C" ++ ++ const-string v1, "-.-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "D" ++ ++ const-string v1, "-.. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "E" ++ ++ const-string v1, ". " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "F" ++ ++ const-string v1, "..-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "G" ++ ++ const-string v1, "--. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "H" ++ ++ const-string v1, ".... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "I" ++ ++ const-string v1, ".. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "J" ++ ++ const-string v1, ".--- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "K" ++ ++ const-string v1, "-.- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "L" ++ ++ const-string v1, ".-.. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "M" ++ ++ const-string v1, "-- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "N" ++ ++ const-string v1, "-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "O" ++ ++ const-string v1, "--- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "P" ++ ++ const-string v1, ".--. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "Q" ++ ++ const-string v1, "--.- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "R" ++ ++ const-string v1, ".-. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "S" ++ ++ const-string v1, "... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "T" ++ ++ const-string v1, "- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "U" ++ ++ const-string v1, "..- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "V" ++ ++ const-string v1, "...- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "W" ++ ++ const-string v1, ".-- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "X" ++ ++ const-string v1, "-..- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "Y" ++ ++ const-string v1, "-.-- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "Z" ++ ++ const-string v1, "--.. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "0" ++ ++ const-string v1, "----- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "1" ++ ++ const-string v1, ".---- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "2" ++ ++ const-string v1, "..--- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "3" ++ ++ const-string v1, "...-- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "4" ++ ++ const-string v1, "....- " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "5" ++ ++ const-string v1, "..... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "6" ++ ++ const-string v1, "-.... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "7" ++ ++ const-string v1, "--... " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "8" ++ ++ const-string v1, "---.. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ const-string v0, "9" ++ ++ const-string v1, "----. " ++ ++ invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ # End of automatically generated code by textreplacegen.py ++ ++ return-object p0 ++ .end method ++ + .method public static final slashCommands(Ljava/lang/String;)Ljava/lang/String; + .locals 1 + + # Ideas for commands (by luna): lower [done], upper [done], fw [done], bold [done], shrug [done] -+ # Ideas for commands (by bela): small, smaller ++ # Ideas for commands (by bela): small [done], smaller [done] + # Discord's defaults: me [done], tableflip [done], unflip [done], spoiler [done] ++ # More ideas: morse [done], mock, help + + # Trim input before anything + invoke-virtual {p0}, Ljava/lang/String;->trim()Ljava/lang/String; @@ -2068,7 +2458,7 @@ diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com. + + move-result v0 + -+ if-eqz v0, :cond_0 ++ if-eqz v0, :cond_16 + + invoke-static {p0}, Lcom/discord/stores/StoreMessages;->slashOwo(Ljava/lang/String;)Ljava/lang/String; + @@ -2076,6 +2466,22 @@ diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com. + + goto :goto_0 + ++ # Morse command ++ :cond_16 ++ const-string v0, "/morse " ++ ++ 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;->slashMorse(Ljava/lang/String;)Ljava/lang/String; ++ ++ move-result-object p0 ++ ++ goto :goto_0 ++ + :cond_0 + :goto_0 + # And finally, trim output before sending it back @@ -2129,7 +2535,7 @@ diff -crB com.discord-900-base/smali/com/discord/stores/StoreMessages.smali com. .annotation system Ldalvik/annotation/Signature; *************** *** 977,982 **** ---- 3083,3092 ---- +--- 3489,3498 ---- invoke-static {p4, v0}, Lkotlin/jvm/internal/j;->h(Ljava/lang/Object;Ljava/lang/String;)V diff --git a/patches/slashcommands/textreplacegen-array.py b/patches/slashcommands/textreplacegen-array.py index ff9ac48a5c..29db0dbf25 100644 --- a/patches/slashcommands/textreplacegen-array.py +++ b/patches/slashcommands/textreplacegen-array.py @@ -1,88 +1,137 @@ smol = { - "a": "ᴀ", - "b": "ʙ", - "c": "ᴄ", - "d": "ᴅ", - "e": "ᴇ", - "f": "ꜰ", - "g": "ɢ", - "h": "ʜ", - "i": "ɪ", - "j": "ᴊ", - "k": "ᴋ", - "l": "ʟ", - "m": "ᴍ", - "n": "ɴ", - "o": "ᴏ", - "p": "ᴘ", - "q": "ǫ", - "r": "ʀ", - "s": "s", - "t": "ᴛ", - "u": "ᴜ", - "v": "ᴠ", - "w": "ᴡ", - "x": "x", - "y": "ʏ", - "z": "ᴢ" + "a": "ᴀ", + "b": "ʙ", + "c": "ᴄ", + "d": "ᴅ", + "e": "ᴇ", + "f": "ꜰ", + "g": "ɢ", + "h": "ʜ", + "i": "ɪ", + "j": "ᴊ", + "k": "ᴋ", + "l": "ʟ", + "m": "ᴍ", + "n": "ɴ", + "o": "ᴏ", + "p": "ᴘ", + "q": "ǫ", + "r": "ʀ", + "s": "s", + "t": "ᴛ", + "u": "ᴜ", + "v": "ᴠ", + "w": "ᴡ", + "x": "x", + "y": "ʏ", + "z": "ᴢ" } smoller = { - "a": "ᵃ", - "b": "ᵇ", - "c": "ᶜ", - "d": "ᵈ", - "e": "ᵉ", - "f": "ᶠ", - "g": "ᵍ", - "h": "ʰ", - "i": "ᶦ", - "j": "ʲ", - "k": "ᵏ", - "l": "ˡ", - "m": "ᵐ", - "n": "ⁿ", - "o": "ᵒ", - "p": "ᵖ", - "q": "ᑫ", - "r": "ʳ", - "s": "ˢ", - "t": "ᵗ", - "u": "ᵘ", - "v": "ᵛ", - "w": "ʷ", - "x": "ˣ", - "y": "ʸ", - "z": "ᶻ" + "a": "ᵃ", + "b": "ᵇ", + "c": "ᶜ", + "d": "ᵈ", + "e": "ᵉ", + "f": "ᶠ", + "g": "ᵍ", + "h": "ʰ", + "i": "ᶦ", + "j": "ʲ", + "k": "ᵏ", + "l": "ˡ", + "m": "ᵐ", + "n": "ⁿ", + "o": "ᵒ", + "p": "ᵖ", + "q": "ᑫ", + "r": "ʳ", + "s": "ˢ", + "t": "ᵗ", + "u": "ᵘ", + "v": "ᵛ", + "w": "ʷ", + "x": "ˣ", + "y": "ʸ", + "z": "ᶻ" } flipped = { - "a": "ɐ", - "b": "q", - "c": "ɔ", - "d": "p", - "e": "ǝ", - "f": "ɟ", - "g": "ƃ", - "h": "ɥ", - "i": "ı", - "j": "ɾ", - "k": "ʞ", - "l": "ן", - "m": "ɯ", - "n": "u", - "o": "o", - "p": "d", - "q": "b", - "r": "ɹ", - "s": "s", - "t": "ʇ", - "u": "n", - "v": "ʌ", - "w": "ʍ", - "x": "x", - "y": "ʎ", - "z": "z" + "a": "ɐ", + "b": "q", + "c": "ɔ", + "d": "p", + "e": "ǝ", + "f": "ɟ", + "g": "ƃ", + "h": "ɥ", + "i": "ı", + "j": "ɾ", + "k": "ʞ", + "l": "ן", + "m": "ɯ", + "n": "u", + "o": "o", + "p": "d", + "q": "b", + "r": "ɹ", + "s": "s", + "t": "ʇ", + "u": "n", + "v": "ʌ", + "w": "ʍ", + "x": "x", + "y": "ʎ", + "z": "z" +} + +morse = { + " ": "/ ", + ".": ".-.-.- ", + ",": "--..-- ", + ":": "---... ", + "?": "..--.. ", + "'": ".----. ", + "-": "-....- ", + "/": "-..-. ", + "@": ".--.-. ", + "=": "-...- ", + "A": ".- ", + "B": "-... ", + "C": "-.-. ", + "D": "-.. ", + "E": ". ", + "F": "..-. ", + "G": "--. ", + "H": ".... ", + "I": ".. ", + "J": ".--- ", + "K": "-.- ", + "L": ".-.. ", + "M": "-- ", + "N": "-. ", + "O": "--- ", + "P": ".--. ", + "Q": "--.- ", + "R": ".-. ", + "S": "... ", + "T": "- ", + "U": "..- ", + "V": "...- ", + "W": ".-- ", + "X": "-..- ", + "Y": "-.-- ", + "Z": "--.. ", + "0": "----- ", + "1": ".---- ", + "2": "..--- ", + "3": "...-- ", + "4": "....- ", + "5": "..... ", + "6": "-.... ", + "7": "--... ", + "8": "---.. ", + "9": "----. " } code = """ @@ -94,7 +143,7 @@ code = """ move-result-object p0""" -fw = flipped +fw = morse for entry in fw: if entry in ["\\", "\""]: