Skip to content

Commit

Permalink
Merge pull request #7231 from pt2121/pt/12-flip-table
Browse files Browse the repository at this point in the history
Add support for `/tableflip` command (#12)
  • Loading branch information
bmarty authored Sep 27, 2022
2 parents df0ce31 + 3f9b982 commit 4d09f08
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.misc
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 4d09f08

Please sign in to comment.