From e34a6fa1c6151aa5d7f021dec3668bbf778d9469 Mon Sep 17 00:00:00 2001
From: InsanusMokrassar <ovsyannikov.alexey95@gmail.com>
Date: Fri, 29 Jan 2021 16:51:08 +0600
Subject: [PATCH] update up to 0.32.0

---
 build.gradle                        |  2 --
 gradle.properties                   |  4 +---
 src/main/kotlin/telegram_bot/App.kt | 22 +++++++++++++++++++++-
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/build.gradle b/build.gradle
index 170836c..a2ab10d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,8 +22,6 @@ repositories {
 
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
-    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
 
     implementation "dev.inmo:tgbotapi:$tgbotapi_version"
 }
diff --git a/gradle.properties b/gradle.properties
index 12b34f6..822dee8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,6 +5,4 @@ kotlin.js.generate.externals=true
 kotlin.incremental=true
 
 kotlin_version=1.4.21
-kotlin_coroutines_version=1.4.2
-kotlin_serialisation_runtime_version=1.0.1
-tgbotapi_version=0.30.10
+tgbotapi_version=0.32.0
diff --git a/src/main/kotlin/telegram_bot/App.kt b/src/main/kotlin/telegram_bot/App.kt
index e6e4724..1b365f4 100644
--- a/src/main/kotlin/telegram_bot/App.kt
+++ b/src/main/kotlin/telegram_bot/App.kt
@@ -2,12 +2,32 @@ package telegram_bot
 
 import dev.inmo.tgbotapi.bot.Ktor.telegramBot
 import dev.inmo.tgbotapi.extensions.api.bot.getMe
+import dev.inmo.tgbotapi.extensions.api.send.reply
+import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour
+import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
+import kotlinx.coroutines.*
 
 /**
  * This method by default expects one argument in [args] field: telegram bot token
  */
 suspend fun main(args: Array<String>) {
+    // that is your bot
     val bot = telegramBot(args.first())
 
-    println(bot.getMe())
+    // that is kotlin coroutine scope which will be used in requests and parallel works under the hood
+    val scope = CoroutineScope(Dispatchers.Default)
+
+    // here should be main logic of your bot
+    bot.buildBehaviour(scope) {
+        // in this lambda you will be able to call methods without "bot." prefix
+        val me = getMe()
+
+        // this method will create point to react on each /start command
+        onCommand("/start", requireOnlyCommandInMessage = true) {
+            // simply reply :)
+            reply(it, "Hello, I am ${me.firstName}")
+        }
+    }
+
+    scope.coroutineContext.job.join()
 }