diff --git a/BusinessConnectionsBot/src/main/kotlin/BusinessConnectionsBot.kt b/BusinessConnectionsBot/src/main/kotlin/BusinessConnectionsBot.kt index bc16ee1..2623cfc 100644 --- a/BusinessConnectionsBot/src/main/kotlin/BusinessConnectionsBot.kt +++ b/BusinessConnectionsBot/src/main/kotlin/BusinessConnectionsBot.kt @@ -3,12 +3,17 @@ 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.ifAccessibleMessage 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 +55,18 @@ suspend fun main(args: Array) { onContentMessage { it.ifBusinessContentMessage { businessContentMessage -> + if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/pin") == true) { + businessContentMessage.replyTo ?.ifAccessibleMessage { + pinChatMessage(it) + return@ifBusinessContentMessage + } + } + if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/unpin") == true) { + businessContentMessage.replyTo ?.ifAccessibleMessage { + unpinChatMessage(it) + 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") diff --git a/gradle.properties b/gradle.properties index ec213ca..fd6383f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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