All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fuchss.matrix.bots.command.QuitCommand.kt Maven / Gradle / Ivy

There is a newer version: 0.13.0
Show newest version
package org.fuchss.matrix.bots.command

import net.folivo.trixnity.client.room.message.text
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.IConfig
import org.fuchss.matrix.bots.MatrixBot

class QuitCommand(
    private val config: IConfig
) : Command() {
    override val name: String = "quit"
    override val help: String = "quits the bot without logging out"
    override val autoAcknowledge = true

    /**
     * Quit the bot.
     * @param[matrixBot] The bot to quit.
     * @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 event of the command.
     * @param[textEvent] The event of the command.
     */
    override suspend fun execute(
        matrixBot: MatrixBot,
        sender: UserId,
        roomId: RoomId,
        parameters: String,
        textEventId: EventId,
        textEvent: RoomMessageEventContent.TextBased.Text
    ) {
        if (!config.isBotAdmin(sender)) {
            matrixBot.room().sendMessage(roomId) { text("You are not an admin.") }
            return
        }
        matrixBot.quit()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy