Merge pull request #7231 from pt2121/pt/12-flip-table

Add support for `/tableflip` command (#12)
This commit is contained in:
Benoit Marty 2022-09-27 11:11:08 +02:00 committed by GitHub
commit 4d09f0888d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 1 deletions

1
changelog.d/12.misc Normal file
View File

@ -0,0 +1 @@
Add support for `/tableflip` command

View File

@ -2220,6 +2220,7 @@
<string name="command_description_shrug">Prepends ¯\\_(ツ)_/¯ to a plain-text message</string>
<string name="command_description_lenny">Prepends ( ͡° ͜ʖ ͡°) to a plain-text message</string>
<string name="command_description_table_flip">Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message</string>
<string name="create_room_encryption_title">"Enable encryption"</string>
<string name="create_room_encryption_description">"Once enabled, encryption cannot be disabled."</string>

View File

@ -66,7 +66,8 @@ enum class Command(
ADD_TO_SPACE("/addToSpace", null, "spaceId", R.string.command_description_add_to_space, true, false),
JOIN_SPACE("/joinSpace", null, "spaceId", R.string.command_description_join_space, true, false),
LEAVE_ROOM("/leave", null, "<roomId?>", R.string.command_description_leave_room, true, false),
UPGRADE_ROOM("/upgraderoom", null, "newVersion", R.string.command_description_upgrade_room, true, false);
UPGRADE_ROOM("/upgraderoom", null, "newVersion", R.string.command_description_upgrade_room, true, false),
TABLE_FLIP("/tableflip", null, "<message>", R.string.command_description_table_flip, false, true);
val allAliases = arrayOf(command, *aliases.orEmpty())

View File

@ -344,6 +344,9 @@ class CommandParser @Inject constructor() {
Command.LENNY.matches(slashCommand) -> {
ParsedCommand.SendLenny(message)
}
Command.TABLE_FLIP.matches(slashCommand) -> {
ParsedCommand.SendTableFlip(message)
}
Command.DISCARD_SESSION.matches(slashCommand) -> {
if (messageParts.size == 1) {
ParsedCommand.DiscardSession

View File

@ -63,6 +63,7 @@ sealed interface ParsedCommand {
object DevTools : ParsedCommand
data class SendSpoiler(val message: String) : ParsedCommand
data class SendShrug(val message: CharSequence) : ParsedCommand
data class SendTableFlip(val message: CharSequence) : ParsedCommand
data class SendLenny(val message: CharSequence) : ParsedCommand
object DiscardSession : ParsedCommand
data class ShowUser(val userId: String) : ParsedCommand

View File

@ -366,6 +366,11 @@ class MessageComposerViewModel @AssistedInject constructor(
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
popDraft()
}
is ParsedCommand.SendTableFlip -> {
sendPrefixedMessage("(╯°□°)╯︵ ┻━┻", parsedCommand.message, state.rootThreadEventId)
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
popDraft()
}
is ParsedCommand.SendChatEffect -> {
sendChatEffect(parsedCommand)
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))