Kotlin Telegram Bot alternatives and similar libraries
Based on the "Tools" category.
Alternatively, view telegram-bot alternatives based on common mentions on social networks and blogs.
-
kotlin-android-template
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = ❤️ -
jtransc
DISCONTINUED. Bytecode to source converting Java & Kotlin code into JavaScript, C++, D, C#, PHP, AS3, Dart and Haxe and run it everywhere. Also use JVM code in your favourite language as a library. -
Ostara
Ostara is a cross-platform desktop app for managing and monitoring Spring Boot applications using the Actuator API, providing comprehensive insights and effortless control. -
MpApt
DISCONTINUED. (Deprecated) :wrench: Kotlin Native/JS/JVM Annotation Processor library for Kotlin compiler plugins -
ktfmt-gradle
A Gradle plugin to apply ktfmt to your builds, and reformat you Kotlin source code like a glimpse 🧹🐘 -
ComposeRecyclerView
Seamlessly integrate Jetpack Compose composables in RecyclerView with ComposeRecyclerView🔥. This library enhances performance⚡, tackles LazyList issues🔨, and offers built-in drag-and-drop👨🏽💻 support for dynamic UIs. -
LiveStream-Kt (Android) 📱
DISCONTINUED. LiveStream is a simple class which makes communication easy among different modules of your application. -
ARFaceDetection
AR-based library for Android which is capable of detecting faces and overlaying images above the user’s head -
Kotlin Bootstrap
This set of libraries is designed to help developers accomplish various tasks easier and faster -
EasyDokkaPlugin
Gradle Script plugin to generate documentation by Dokka documentation engine in Javadoc or other formats for Java, Kotlin, Android and non-Android projects. It's very easy, you don't need to add to dependencies section additional classpath or think about compatibility issues, you don't need additional repositories also. -
GradleMavenPush
Helper to upload Gradle Android Artifacts, Gradle Java Artifacts and Gradle Kotlin Artifacts to Maven repositories (JCenter, Maven Central, Corporate staging/snapshot servers and local Maven repositories). -
buildSrcVersions
Better Gradle dependencies management inside the IDE. Search for available updates.
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of Kotlin Telegram Bot or a related project?
README
Telegram Bot
Kotlin based wrapper over Telegram API.
Installation
Add the MavenCentral repository to your root build.gradle.kts file:
repositories {
mavenCentral()
}
Now add the library itself to the dependencies' module that you need it.
dependencies {
implementation("eu.vendeli:telegram-bot:2.3.2")
}
Samples
You can see the samples in the telegram-bot_template repository. In the basic branch itself there is an empty draft that can be used to create any bot you want.
there you can find in the appropriate branches:
- Conversation - An example of using Inputs and storing data in UserData.
- Echo - Echo bot :)
- Exception-handling - Simple example of exception handling
- Ktor-webhook - An example of using webhook with Ktor
- Poll - An example of how to build a bot questionnaire.
- Spring Boot usage - An example of using the bot organically in the Spring ecosystem, using its built-in DI.
- Heroku ready example - An example of a bot working via Heroku
Usage
fun main() = runBlocking {
val bot = TelegramBot("BOT_TOKEN", "com.example.controllers")
/**
* Second parameter is the package in which commands/inputs will be searched.
*/
bot.handleUpdates()
// start long-polling listener
}
@CommandHandler(["/start"])
suspend fun start(user: User, bot: TelegramBot) {
message { "Hello, what's your name?" }.send(user, bot)
bot.inputListener.set(user.id, "conversation")
}
@InputHandler(["conversation"])
suspend fun startConversation(user: User, bot: TelegramBot) {
message { "Nice to meet you, ${message.text}" }.send(user, bot)
message { "What is your favorite food?" }.send(user, bot)
bot.inputListener.set(user.id, "conversation-2step")
}
//..
It is also possible to process updates manually:
fun main() = runBlocking {
val bot = TelegramBot("BOT_TOKEN")
bot.handleUpdates { update ->
onCommand("/start") {
message { "Hello, what's your name?" }.send(user, bot)
bot.inputListener.set(user.id, "conversation")
}
inputChain("conversation") {
message { "Nice to meet you, ${message.text}" }.send(user, bot)
message { "What is your favorite food?" }.send(user, bot)
}.breakIf({ message.text == "peanut butter" }) { // chain break condition
message { "Oh, too bad, I'm allergic to it." }.send(user, bot)
// action that will be applied when match
}.andThen {
// ...
}
}
}
You can also change additional parameters of the bot:
// ...
val bot = TelegramBot("BOT_TOKEN") {
inputListener = RedisInputListenerImpl()
classManager = KoinClassManagerImpl()
logging {
botLogLevel = Level.DEBUG
}
}
// ...
A more complete list of settings can be found in BotConfiguration class.
It is also possible to do more advanced processing with a manual listener setting
with bot.update.setListener {}
function.
for webhook handling you can use any server
and bot.update.handle()
function (or use this function if you're directly setting listener), \
and for set webhook you can use this method:
setWebhook("https://site.com").send(bot)
if you want to operate with response you can
use sendAsync()
instead of send()
method, which
returns Response
:
message { "test" }.sendAsync(user, bot).await().onFailure {
println("code: ${it.errorCode} description: ${it.description}")
}
Any async request returns
a Response
on which you can also use
methods getOrNull()
, isSuccess()
, onFailure()
.
More about
You can also read more information in the wiki, and you're always welcome in chat.