Skip to content

Commit

Permalink
Add support for /tableflip command (element-hq#12)
Browse files Browse the repository at this point in the history
Signed-off-by: Prat T <[email protected]>
  • Loading branch information
pt2121 committed Sep 24, 2022
1 parent d0bff74 commit 08c9e49
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/12.wip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for `/tableflip` command
1 change: 1 addition & 0 deletions library/ui-strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 08c9e49

Please sign in to comment.