mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template.git
synced 2024-12-05 00:10:12 +00:00
Compare commits
No commits in common. "6a203863c75994480b1f89659612d6ec6f0d0e4e" and "7c2115739ad0504bf05cde820fc17a50c4590a39" have entirely different histories.
6a203863c7
...
7c2115739a
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,5 @@ settings.xml
|
||||
build/
|
||||
out/
|
||||
|
||||
local.*
|
||||
local.*/
|
||||
local.properties
|
||||
secret.gradle
|
||||
|
@ -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/
|
||||
|
@ -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))
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"token": "your bot token"
|
||||
}
|
@ -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)
|
||||
|
@ -1,8 +0,0 @@
|
||||
package telegram_bot
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Config(
|
||||
val token: String
|
||||
)
|
Loading…
Reference in New Issue
Block a user