TelegramBotAPI-examples/GetMeBot/src/main/kotlin/GetMeBot.kt

32 lines
991 B
Kotlin
Raw Normal View History

2023-11-25 06:44:05 +00:00
import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.LogLevel
import dev.inmo.kslog.common.defaultMessageFormatter
import dev.inmo.kslog.common.filter.filtered
2023-11-25 06:57:11 +00:00
import dev.inmo.kslog.common.setDefaultKSLog
2022-05-10 18:23:14 +00:00
import dev.inmo.tgbotapi.bot.ktor.telegramBot
2020-10-04 11:32:50 +00:00
import dev.inmo.tgbotapi.extensions.api.bot.getMe
2024-01-08 09:46:23 +00:00
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
2023-11-25 06:44:05 +00:00
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
2020-06-02 15:48:07 +00:00
/**
* This is one of the most easiest bot - it will just print information about itself
*/
suspend fun main(vararg args: String) {
val botToken = args.first()
2024-01-08 09:46:23 +00:00
val isDebug = args.getOrNull(1) == "debug"
if (isDebug) {
setDefaultKSLog(
KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
println(defaultMessageFormatter(level, tag, message, throwable))
}
)
}
2020-06-02 15:48:07 +00:00
val bot = telegramBot(botToken)
2024-01-08 09:46:23 +00:00
val me = bot.getMe()
println(me)
println(bot.getChat(me))
2022-05-10 18:23:14 +00:00
}