Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - ruslanys/telegraff: Kotlin DSL для разработки Telegram ботов
Kotlin DSL для разработки Telegram ботов. Contribute to ruslanys/telegraff development by creating an account on GitHub.
Visit SiteGitHub - ruslanys/telegraff: Kotlin DSL для разработки Telegram ботов
Kotlin DSL для разработки Telegram ботов. Contribute to ruslanys/telegraff development by creating an account on GitHub.
Powered by 0x5a.live 💗
Подключение
repositories {
maven {
url "https://dl.bintray.com/ruslanys/maven"
}
}
Gradle:
compile("me.ruslanys.telegraff:telegraff-starter:1.0.0")
Maven:
<dependency>
<groupId>me.ruslanys.telegraff</groupId>
<artifactId>telegraff-starter</artifactId>
<version>1.0.0</version>
</dependency>
Настройка
telegram.access-key= # api key
telegram.mode= # polling (default), webhook
telegram.webhook-base-url= # required for webhook mode
telegram.webhook-endpoint-url= # optional
Использование
Положите файл с расширением .kts
в папку c ресурсами handlers
:
resources/handlers/ExampleHandler.kts
.
enum class PaymentMethod {
CARD, CASH
}
handler("/taxi", "такси") {
step<String>("locationFrom") {
question {
MarkdownMessage("Откуда поедем?")
}
}
step<String>("locationTo") {
question {
MarkdownMessage("Куда поедем?")
}
}
step<PaymentMethod>("paymentMethod") {
question {
MarkdownMessage("Оплата картой или наличкой?", "Картой", "Наличкой")
}
validation {
when (it.toLowerCase()) {
"картой" -> PaymentMethod.CARD
"наличкой" -> PaymentMethod.CASH
else -> throw ValidationException("Пожалуйста, выбери один из вариантов")
}
}
}
process { state, answers ->
val from = answers["locationFrom"] as String
val to = answers["locationTo"] as String
val paymentMethod = answers["paymentMethod"] as PaymentMethod
// Business logic
MarkdownMessage("Заказ принят. Поедем из $from в $to. Оплата $paymentMethod.")
}
}
Устройство
Kotlin Resources
are all listed below.
GitHub - BenWoodworth/knbt: Kotlin NBT library for kotlinx.serialization
resource
~/github.com
resource
GitHub - brianmadden/krawler: A web crawling framework written in Kotlin
resource
~/github.com
resource
GitHub - OxygenCobalt/Auxio: A simple, rational music player for android
resource
~/github.com
resource
GitHub - eriksencosta/math-percentage: Percentage calculations made easy
resource
~/github.com
resource
GitHub - ctripcorp/mmkv-kotlin: A Kotlin Multiplatform porting for MMKV.
resource
~/github.com
resource
GitHub - Litote/kmongo: [deprecated] KMongo - a Kotlin toolkit for Mongo
resource
~/github.com
resource
Test-Driven Development Tutorial for Android: Getting Started
resource
~/www.raywenderlich.com
resource
GitHub - jacinpoz/rxaerospike: RxJava2 wrapper for aerospike-client-java
resource
~/github.com
resource
GitHub - pedrovgs/KotlinSnapshot: Snapshot Testing framework for Kotlin.
resource
~/github.com
resource
GitHub - hankdavidson/ktime: kotlin extensions to the java8 time library
resource
~/github.com
resource
GitHub - ziggy42/Blum: A simple android Twitter client written in Kotlin
resource
~/github.com
resource
Made with ❤️
to provide different kinds of informations and resources.