mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-22 00:03:54 +00:00
add pin/unpin in business connection
This commit is contained in:
parent
b70b6d1e2b
commit
f5a9efa3e7
@ -3,12 +3,16 @@ import dev.inmo.kslog.common.LogLevel
|
||||
import dev.inmo.kslog.common.defaultMessageFormatter
|
||||
import dev.inmo.kslog.common.setDefaultKSLog
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.chat.modify.pinChatMessage
|
||||
import dev.inmo.tgbotapi.extensions.api.chat.modify.unpinChatMessage
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getBusinessConnection
|
||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||
import dev.inmo.tgbotapi.extensions.utils.accessibleMessageOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.ifBusinessContentMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.textContentOrNull
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -50,6 +54,14 @@ suspend fun main(args: Array<String>) {
|
||||
|
||||
onContentMessage {
|
||||
it.ifBusinessContentMessage { businessContentMessage ->
|
||||
if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/pin") == true) {
|
||||
pinChatMessage(businessContentMessage)
|
||||
return@ifBusinessContentMessage
|
||||
}
|
||||
if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/unpin") == true) {
|
||||
unpinChatMessage(businessContentMessage)
|
||||
return@ifBusinessContentMessage
|
||||
}
|
||||
val sent = execute(it.content.createResend(businessContentMessage.from.id))
|
||||
if (businessContentMessage.sentByBusinessConnectionOwner) {
|
||||
reply(sent, "You have sent this message to the ${businessContentMessage.businessConnectionId.string} related chat")
|
||||
|
@ -6,7 +6,7 @@ kotlin.daemon.jvmargs=-Xmx2g -Xms500m
|
||||
|
||||
|
||||
kotlin_version=1.9.23
|
||||
telegram_bot_api_version=15.2.0
|
||||
telegram_bot_api_version=15.3.0
|
||||
micro_utils_version=0.21.2
|
||||
serialization_version=1.6.3
|
||||
ktor_version=2.3.11
|
||||
|
Loading…
Reference in New Issue
Block a user