Activites And Processors
Introduction¶
Activity in the terms of this library is the abstract entity that is a generalization of entities such as @CommandHandler, @InputHandler, @UnprocessedHandler, and @CommonHandler.
Also take a look at handlers article.
Collecting activities¶
Activities are collected and prepared all context in compile time (except for those defined through functional dsl).
If you want to limit the area in which the package will be searched, you can pass a parameter to plugin:
or without plugin through ksp:
note in such a case, in order for the collected actions to be processed correctly, you must also specify the package in the instance itself.
fun main() = runBlocking {
val bot = TelegramBot("BOT_TOKEN", "com.example.mybot")
bot.handleUpdates()
// start long-polling listener
}
this option is added to be able to run multiple bot instances:
or if you're not using plugin to specify different packages you need to specify them with ; separator:
Processing¶
Webhooks¶
In your controller (or another place where the webhook is processed), you call: bot.update.parseAndHandle(webhookString)
Long polling¶
Call: bot.handleUpdates() or through bot.update.setListener { handle(it) }