add pin/unpin in business connection

This commit is contained in:
InsanusMokrassar 2024-08-02 00:39:37 +06:00
parent b70b6d1e2b
commit f5a9efa3e7
2 changed files with 13 additions and 1 deletions

View File

@ -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")

View File

@ -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