org.fuchss.matrix.bots.command.Command.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of matrix-bot-base Show documentation
Show all versions of matrix-bot-base Show documentation
Base project for matrix bots
package org.fuchss.matrix.bots.command
import net.folivo.trixnity.core.model.EventId
import net.folivo.trixnity.core.model.RoomId
import net.folivo.trixnity.core.model.UserId
import net.folivo.trixnity.core.model.events.m.room.RoomMessageEventContent
import org.fuchss.matrix.bots.MatrixBot
import org.fuchss.matrix.bots.emoji
import org.slf4j.Logger
import org.slf4j.LoggerFactory
abstract class Command {
protected val logger: Logger = LoggerFactory.getLogger(this::class.java)
abstract val name: String
open val params: String = ""
abstract val help: String
open val autoAcknowledge: Boolean = false
companion object {
@JvmStatic
val ACK_EMOJI = ":heavy_check_mark:".emoji()
}
/**
* Execute the command.
* @param[matrixBot] The bot to execute the command.
* @param[sender] The sender of the command.
* @param[roomId] The room to execute the command in.
* @param[parameters] The parameters of the command.
* @param[textEventId] The text event id of the command.
* @param[textEvent] The text event of the command.
*/
abstract suspend fun execute(
matrixBot: MatrixBot,
sender: UserId,
roomId: RoomId,
parameters: String,
textEventId: EventId,
textEvent: RoomMessageEventContent.TextBased.Text
)
}