Add /snow command
This commit is contained in:
parent
6957768567
commit
487ef870f9
@ -45,7 +45,8 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
|
|||||||
SHRUG("/shrug", "<message>", R.string.command_description_shrug),
|
SHRUG("/shrug", "<message>", R.string.command_description_shrug),
|
||||||
PLAIN("/plain", "<message>", R.string.command_description_plain),
|
PLAIN("/plain", "<message>", R.string.command_description_plain),
|
||||||
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session),
|
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session),
|
||||||
CONFETTI("/confetti", "<message>", R.string.command_confetti);
|
CONFETTI("/confetti", "<message>", R.string.command_confetti),
|
||||||
|
SNOW("/snow", "<message>", R.string.command_snow);
|
||||||
|
|
||||||
val length
|
val length
|
||||||
get() = command.length + 1
|
get() = command.length + 1
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.app.features.command
|
|||||||
|
|
||||||
import im.vector.app.core.extensions.isEmail
|
import im.vector.app.core.extensions.isEmail
|
||||||
import im.vector.app.core.extensions.isMsisdn
|
import im.vector.app.core.extensions.isMsisdn
|
||||||
|
import im.vector.app.features.home.room.detail.ChatEffect
|
||||||
import org.matrix.android.sdk.api.MatrixPatterns
|
import org.matrix.android.sdk.api.MatrixPatterns
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -293,7 +294,11 @@ object CommandParser {
|
|||||||
}
|
}
|
||||||
Command.CONFETTI.command -> {
|
Command.CONFETTI.command -> {
|
||||||
val message = textMessage.substring(Command.CONFETTI.command.length).trim()
|
val message = textMessage.substring(Command.CONFETTI.command.length).trim()
|
||||||
ParsedCommand.Confetti(message)
|
ParsedCommand.SendChatEffect(ChatEffect.CONFETTI, message)
|
||||||
|
}
|
||||||
|
Command.SNOW.command -> {
|
||||||
|
val message = textMessage.substring(Command.SNOW.command.length).trim()
|
||||||
|
ParsedCommand.SendChatEffect(ChatEffect.SNOW, message)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// Unknown command
|
// Unknown command
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package im.vector.app.features.command
|
package im.vector.app.features.command
|
||||||
|
|
||||||
|
import im.vector.app.features.home.room.detail.ChatEffect
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,5 +56,5 @@ sealed class ParsedCommand {
|
|||||||
class SendShrug(val message: CharSequence) : ParsedCommand()
|
class SendShrug(val message: CharSequence) : ParsedCommand()
|
||||||
class SendPoll(val question: String, val options: List<String>) : ParsedCommand()
|
class SendPoll(val question: String, val options: List<String>) : ParsedCommand()
|
||||||
object DiscardSession : ParsedCommand()
|
object DiscardSession : ParsedCommand()
|
||||||
class Confetti(val message: String) : ParsedCommand()
|
class SendChatEffect(val chatEffect: ChatEffect, val message: String) : ParsedCommand()
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,13 @@ enum class ChatEffect {
|
|||||||
SNOW
|
SNOW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ChatEffect.toMessageType(): String {
|
||||||
|
return when (this) {
|
||||||
|
ChatEffect.CONFETTI -> MessageType.MSGTYPE_CONFETTI
|
||||||
|
ChatEffect.SNOW -> MessageType.MSGTYPE_SNOW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple chat effect manager helper class
|
* A simple chat effect manager helper class
|
||||||
* Used by the view model to know if an event that become visible should trigger a chat effect.
|
* Used by the view model to know if an event that become visible should trigger a chat effect.
|
||||||
|
@ -56,7 +56,6 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
import butterknife.BindView
|
|
||||||
import com.airbnb.epoxy.EpoxyModel
|
import com.airbnb.epoxy.EpoxyModel
|
||||||
import com.airbnb.epoxy.OnModelBuildFinishedListener
|
import com.airbnb.epoxy.OnModelBuildFinishedListener
|
||||||
import com.airbnb.epoxy.addGlidePreloader
|
import com.airbnb.epoxy.addGlidePreloader
|
||||||
|
@ -715,8 +715,8 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
||||||
popDraft()
|
popDraft()
|
||||||
}
|
}
|
||||||
is ParsedCommand.Confetti -> {
|
is ParsedCommand.SendChatEffect -> {
|
||||||
room.sendTextMessage(slashCommandResult.message, MessageType.MSGTYPE_CONFETTI)
|
room.sendTextMessage(slashCommandResult.message, slashCommandResult.chatEffect.toMessageType())
|
||||||
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
|
||||||
popDraft()
|
popDraft()
|
||||||
}
|
}
|
||||||
|
@ -2571,6 +2571,7 @@
|
|||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
<string name="command_confetti">Sends the given message with confetti</string>
|
<string name="command_confetti">Sends the given message with confetti</string>
|
||||||
|
<string name="command_snow">Sends the given message with snow</string>
|
||||||
|
|
||||||
<string name="unencrypted">Unencrypted</string>
|
<string name="unencrypted">Unencrypted</string>
|
||||||
<string name="encrypted_unverified">Encrypted by an unverified device</string>
|
<string name="encrypted_unverified">Encrypted by an unverified device</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user