mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-12-22 00:27:19 +00:00
commit
2c5da5da9f
@ -3,12 +3,17 @@ import dev.inmo.kslog.common.LogLevel
|
|||||||
import dev.inmo.kslog.common.defaultMessageFormatter
|
import dev.inmo.kslog.common.defaultMessageFormatter
|
||||||
import dev.inmo.kslog.common.setDefaultKSLog
|
import dev.inmo.kslog.common.setDefaultKSLog
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
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.get.getBusinessConnection
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
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.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.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -50,6 +55,18 @@ suspend fun main(args: Array<String>) {
|
|||||||
|
|
||||||
onContentMessage {
|
onContentMessage {
|
||||||
it.ifBusinessContentMessage { businessContentMessage ->
|
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))
|
val sent = execute(it.content.createResend(businessContentMessage.from.id))
|
||||||
if (businessContentMessage.sentByBusinessConnectionOwner) {
|
if (businessContentMessage.sentByBusinessConnectionOwner) {
|
||||||
reply(sent, "You have sent this message to the ${businessContentMessage.businessConnectionId.string} related chat")
|
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
|
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
|
micro_utils_version=0.21.2
|
||||||
serialization_version=1.6.3
|
serialization_version=1.6.3
|
||||||
ktor_version=2.3.11
|
ktor_version=2.3.11
|
||||||
|
Loading…
Reference in New Issue
Block a user