Skip to content

Commit

Permalink
Part of #3: Gather chat ids
Browse files Browse the repository at this point in the history
  • Loading branch information
IRus committed Nov 7, 2020
1 parent bee227c commit 6b53e16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions bot/src/main/kotlin/io/heapy/kotbot/bot/command/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,24 @@ class HelloWorldCommand(
)
}
}

class ChatInfoCommand(
override val info: Info = INFO
) : Command {
override fun execute(update: Update, args: List<String>): Flow<Action> {
return flowOf(ReplyAction(
chatId = update.message.chatId,
message = """
Chat id: ${update.message.chatId}
""".trimIndent()
))
}

companion object {
private val INFO = CommandInfo(
name = "!chat-info",
context = Context.GROUP_CHAT,
access = Access.ADMIN
)
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/io/heapy/kotbot/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.typesafe.config.ConfigFactory
import io.github.config4k.extract
import io.heapy.kotbot.bot.KotBot
import io.heapy.kotbot.bot.command.HelloWorldCommand
import io.heapy.kotbot.bot.command.ChatInfoCommand
import io.heapy.kotbot.bot.rule.CombotCasRule
import io.heapy.kotbot.bot.rule.DeleteHelloRule
import io.heapy.kotbot.bot.rule.DeleteJoinRule
Expand Down Expand Up @@ -48,7 +49,8 @@ object Application {
CombotCasRule(client, configuration.cas)
)
val commands = listOf(
HelloWorldCommand()
HelloWorldCommand(),
ChatInfoCommand()
)

startServer(
Expand Down

0 comments on commit 6b53e16

Please sign in to comment.