mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-12-22 00:27:19 +00:00
updates and fixes
This commit is contained in:
parent
41efe5e141
commit
262ef26239
@ -1,16 +1,14 @@
|
||||
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
|
||||
import dev.inmo.kslog.common.setDefaultKSLog
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||
import dev.inmo.tgbotapi.extensions.api.send.setMessageReaction
|
||||
import dev.inmo.tgbotapi.extensions.api.send.setMessageReactions
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatMessageReactionUpdatedByUser
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog
|
||||
import dev.inmo.tgbotapi.utils.customEmoji
|
||||
import dev.inmo.tgbotapi.utils.regular
|
||||
|
||||
@ -33,7 +31,12 @@ suspend fun main(vararg args: String) {
|
||||
|
||||
bot.buildBehaviourWithLongPolling {
|
||||
onChatMessageReactionUpdatedByUser {
|
||||
val result = reply(
|
||||
setMessageReaction(
|
||||
it.chat.id,
|
||||
it.messageId,
|
||||
"✍"
|
||||
)
|
||||
val replyResult = reply(
|
||||
it.chat.id,
|
||||
it.messageId,
|
||||
replyInChat = it.reactedUser.id
|
||||
@ -48,7 +51,10 @@ suspend fun main(vararg args: String) {
|
||||
regular("\n")
|
||||
}
|
||||
}
|
||||
println(result)
|
||||
setMessageReaction(
|
||||
it.chat.id,
|
||||
it.messageId,
|
||||
)
|
||||
}
|
||||
}.join()
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.kslog.common.LogLevel
|
||||
import dev.inmo.kslog.common.defaultMessageFormatter
|
||||
import dev.inmo.kslog.common.setDefaultKSLog
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
||||
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||
@ -14,6 +18,7 @@ import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
|
||||
import dev.inmo.tgbotapi.types.BotCommand
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
||||
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
@ -43,6 +48,16 @@ suspend fun main(vararg args: String) {
|
||||
args.first(),
|
||||
testServer = args.any { it == "testServer" }
|
||||
)
|
||||
val isDebug = args.any { it == "debug" }
|
||||
|
||||
if (isDebug) {
|
||||
setDefaultKSLog(
|
||||
KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
|
||||
println(defaultMessageFormatter(level, tag, message, throwable))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val bot = telegramBot(telegramBotAPIUrlsKeeper)
|
||||
createKtorServer(
|
||||
"0.0.0.0",
|
||||
@ -102,8 +117,11 @@ suspend fun main(vararg args: String) {
|
||||
row {
|
||||
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
linkPreviewOptions = LinkPreviewOptions.Small(
|
||||
args[1],
|
||||
showAboveText = false
|
||||
)
|
||||
)
|
||||
}
|
||||
onCommand("attachment_menu") {
|
||||
@ -114,8 +132,11 @@ suspend fun main(vararg args: String) {
|
||||
row {
|
||||
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
linkPreviewOptions = LinkPreviewOptions.Large(
|
||||
args[1],
|
||||
showAboveText = true
|
||||
)
|
||||
)
|
||||
}
|
||||
onBaseInlineQuery {
|
||||
|
@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2344m
|
||||
|
||||
|
||||
kotlin_version=1.9.22
|
||||
telegram_bot_api_version=10.0.0-branch_10.0.0-build2034
|
||||
telegram_bot_api_version=10.0.0-branch_10.0.0-build2039
|
||||
micro_utils_version=0.20.25
|
||||
serialization_version=1.6.2
|
||||
ktor_version=2.3.7
|
||||
|
Loading…
Reference in New Issue
Block a user