Add morse

This commit is contained in:
ave 2019-05-21 19:36:08 +03:00
parent cdc9b03ebf
commit 8fc56562f3
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
2 changed files with 539 additions and 84 deletions

View file

@ -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

View file

@ -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 ["\\", "\""]: