在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kotlin-telegram-bot/kotlin-telegram-bot开源软件地址(OpenSource Url):https://github.com/kotlin-telegram-bot/kotlin-telegram-bot开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Kotlin Telegram BotA wrapper for the Telegram Bot API written in Kotlin. UsageCreating a bot instance is really simple: fun main() {
val bot = bot {
token = "YOUR_API_KEY"
}
} Now lets poll telegram API and route all text updates: fun main() {
val bot = bot {
token = "YOUR_API_KEY"
dispatch {
text {
bot.sendMessage(ChatId.fromId(message.chat.id), text = text)
}
}
}
bot.startPolling()
} Want to route commands?: fun main() {
val bot = bot {
token = "YOUR_API_KEY"
dispatch {
command("start") {
val result = bot.sendMessage(chatId = ChatId.fromId(message.chat.id), text = "Hi there!")
result.fold({
// do something here with the response
},{
// do something with the error
})
}
}
}
bot.startPolling()
} ExamplesTake a look at the examples folder. There are several samples:
Download
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'io.github.kotlin-telegram-bot.kotlin-telegram-bot:telegram:x.y.z'
} Detailed documentationContributing
Thanks
LicenseKotlin Telegram Bot is under the Apache 2.0 license. See the LICENSE for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论