fixes in sample of business_connections bot

This commit is contained in:
InsanusMokrassar 2024-08-02 16:48:27 +06:00
parent f5a9efa3e7
commit f79e43364a

View File

@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.* import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
import dev.inmo.tgbotapi.extensions.utils.accessibleMessageOrNull 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.ifBusinessContentMessage
import dev.inmo.tgbotapi.extensions.utils.textContentOrNull import dev.inmo.tgbotapi.extensions.utils.textContentOrNull
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.ChatId
@ -55,12 +56,16 @@ suspend fun main(args: Array<String>) {
onContentMessage { onContentMessage {
it.ifBusinessContentMessage { businessContentMessage -> it.ifBusinessContentMessage { businessContentMessage ->
if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/pin") == true) { if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/pin") == true) {
pinChatMessage(businessContentMessage) businessContentMessage.replyTo ?.ifAccessibleMessage {
return@ifBusinessContentMessage pinChatMessage(it)
return@ifBusinessContentMessage
}
} }
if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/unpin") == true) { if (businessContentMessage.content.textContentOrNull() ?.text ?.startsWith("/unpin") == true) {
unpinChatMessage(businessContentMessage) businessContentMessage.replyTo ?.ifAccessibleMessage {
return@ifBusinessContentMessage unpinChatMessage(it)
return@ifBusinessContentMessage
}
} }
val sent = execute(it.content.createResend(businessContentMessage.from.id)) val sent = execute(it.content.createResend(businessContentMessage.from.id))
if (businessContentMessage.sentByBusinessConnectionOwner) { if (businessContentMessage.sentByBusinessConnectionOwner) {