Skip to content

Commit 3f9b982

Browse files
committed
Add support for /tableflip command (#12)
Signed-off-by: Prat T <[email protected]>
1 parent d0bff74 commit 3f9b982

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

changelog.d/12.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for `/tableflip` command

library/ui-strings/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,7 @@
22202220

22212221
<string name="command_description_shrug">Prepends ¯\\_(ツ)_/¯ to a plain-text message</string>
22222222
<string name="command_description_lenny">Prepends ( ͡° ͜ʖ ͡°) to a plain-text message</string>
2223+
<string name="command_description_table_flip">Prepends (╯°□°)╯︵ ┻━┻ to a plain-text message</string>
22232224

22242225
<string name="create_room_encryption_title">"Enable encryption"</string>
22252226
<string name="create_room_encryption_description">"Once enabled, encryption cannot be disabled."</string>

vector/src/main/java/im/vector/app/features/command/Command.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ enum class Command(
6666
ADD_TO_SPACE("/addToSpace", null, "spaceId", R.string.command_description_add_to_space, true, false),
6767
JOIN_SPACE("/joinSpace", null, "spaceId", R.string.command_description_join_space, true, false),
6868
LEAVE_ROOM("/leave", null, "<roomId?>", R.string.command_description_leave_room, true, false),
69-
UPGRADE_ROOM("/upgraderoom", null, "newVersion", R.string.command_description_upgrade_room, true, false);
69+
UPGRADE_ROOM("/upgraderoom", null, "newVersion", R.string.command_description_upgrade_room, true, false),
70+
TABLE_FLIP("/tableflip", null, "<message>", R.string.command_description_table_flip, false, true);
7071

7172
val allAliases = arrayOf(command, *aliases.orEmpty())
7273

vector/src/main/java/im/vector/app/features/command/CommandParser.kt

+3
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ class CommandParser @Inject constructor() {
344344
Command.LENNY.matches(slashCommand) -> {
345345
ParsedCommand.SendLenny(message)
346346
}
347+
Command.TABLE_FLIP.matches(slashCommand) -> {
348+
ParsedCommand.SendTableFlip(message)
349+
}
347350
Command.DISCARD_SESSION.matches(slashCommand) -> {
348351
if (messageParts.size == 1) {
349352
ParsedCommand.DiscardSession

vector/src/main/java/im/vector/app/features/command/ParsedCommand.kt

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ sealed interface ParsedCommand {
6363
object DevTools : ParsedCommand
6464
data class SendSpoiler(val message: String) : ParsedCommand
6565
data class SendShrug(val message: CharSequence) : ParsedCommand
66+
data class SendTableFlip(val message: CharSequence) : ParsedCommand
6667
data class SendLenny(val message: CharSequence) : ParsedCommand
6768
object DiscardSession : ParsedCommand
6869
data class ShowUser(val userId: String) : ParsedCommand

vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt

+5
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ class MessageComposerViewModel @AssistedInject constructor(
366366
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
367367
popDraft()
368368
}
369+
is ParsedCommand.SendTableFlip -> {
370+
sendPrefixedMessage("(╯°□°)╯︵ ┻━┻", parsedCommand.message, state.rootThreadEventId)
371+
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
372+
popDraft()
373+
}
369374
is ParsedCommand.SendChatEffect -> {
370375
sendChatEffect(parsedCommand)
371376
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))

0 commit comments

Comments
 (0)