Compare commits

..

No commits in common. "6a203863c75994480b1f89659612d6ec6f0d0e4e" and "7c2115739ad0504bf05cde820fc17a50c4590a39" have entirely different histories.

6 changed files with 7 additions and 24 deletions

3
.gitignore vendored
View File

@ -9,6 +9,5 @@ settings.xml
build/
out/
local.*
local.*/
local.properties
secret.gradle

View File

@ -2,7 +2,6 @@ FROM adoptopenjdk/openjdk11
USER 1000
ENTRYPOINT ["/telegram_bot/bin/telegram_bot", "/telegram_bot/local.config.json"]
ENTRYPOINT ["/telegram_bot/bin/telegram_bot", "TOKEN"]
ADD ./build/distributions/telegram_bot.tar /
ADD ./local.config.json /telegram_bot/

View File

@ -9,7 +9,9 @@ it was described [here](https://github.com/InsanusMokrassar/TelegramBotAPI#ok-wh
## Default
Since you have used this repo as a template you can copy file `example.config.json` as `local.config.json`, put there your bot token and simply run command `./gradlew run --args="local.config.json"`. As an output you will get your bot information like:
Since you have used this repo as a template you can simply run command `./gradlew run --args="BOT_TOKEN"` (of course,
replace here `BOT_TOKEN` with your telegram bot token like `1234567890:ABCDEFGHIJKLM_OPqrstuvwxyz012345678`). As an
output you will get your bot information like:
```bash
ExtendedBot(id=ChatId(chatId=1234567890), username=Username(username=@username_of_your_bot), firstName=Name of bot, lastName=, canJoinGroups=(some boolean), canReadAllGroupMessages=(some boolean), supportsInlineQueries=(some boolean))

View File

@ -1,3 +0,0 @@
{
"token": "your bot token"
}

View File

@ -5,20 +5,14 @@ import dev.inmo.tgbotapi.extensions.api.bot.getMe
import dev.inmo.tgbotapi.extensions.api.send.reply
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
import java.io.File
import kotlinx.coroutines.*
import kotlinx.serialization.json.Json
/**
* This method by default expects one argument in [args] field: telegram bot condiguration
* This method by default expects one argument in [args] field: telegram bot token
*/
suspend fun main(args: Array<String>) {
// create json to decode config
val json = Json { ignoreUnknownKeys = true }
// decode config
val config: Config = json.decodeFromString(Config.serializer(), File(args.first()).readText())
// that is your bot
val bot = telegramBot(config.token)
val bot = telegramBot(args.first())
// that is kotlin coroutine scope which will be used in requests and parallel works under the hood
val scope = CoroutineScope(Dispatchers.Default)

View File

@ -1,8 +0,0 @@
package telegram_bot
import kotlinx.serialization.Serializable
@Serializable
data class Config(
val token: String
)