From d8c90ef377edfe61c1574f23513820fb4c81e12c Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Feb 2023 22:38:05 +0600 Subject: [PATCH] check and a little update --- .../src/main/kotlin/ForwardInfoSenderBot.kt | 13 +++++++++++-- RightsChangerBot/src/main/kotlin/RightsChanger.kt | 6 +++++- gradle.properties | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt index 5723b0f..c03ed3d 100644 --- a/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt +++ b/ForwardInfoSenderBot/src/main/kotlin/ForwardInfoSenderBot.kt @@ -1,12 +1,14 @@ import dev.inmo.tgbotapi.extensions.api.send.reply import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage -import dev.inmo.tgbotapi.extensions.utils.formatting.* +import dev.inmo.tgbotapi.extensions.utils.formatting.makeLink import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.ExtendedBot import dev.inmo.tgbotapi.types.message.* +import dev.inmo.tgbotapi.utils.buildEntities import dev.inmo.tgbotapi.utils.code +import dev.inmo.tgbotapi.utils.link import dev.inmo.tgbotapi.utils.regular import kotlinx.coroutines.* @@ -40,7 +42,14 @@ suspend fun main(vararg args: String) { is ExtendedBot -> regular("Bot ") } + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username?.username ?: "Without username"})" } - is ForwardInfo.PublicChat.FromChannel -> regular("Channel (") + code(forwardInfo.channelChat.title) + ")" + is ForwardInfo.PublicChat.FromChannel -> { + regular("Channel (") + (forwardInfo.channelChat.username ?.let { + link( + forwardInfo.channelChat.title, + makeLink(it) + ) + } ?: code(forwardInfo.channelChat.title)) + ")" + } is ForwardInfo.PublicChat.FromSupergroup -> regular("Supergroup (") + code(forwardInfo.group.title) + ")" is ForwardInfo.PublicChat.SentByChannel -> regular("Sent by channel (") + code(forwardInfo.channelChat.title) + ")" } diff --git a/RightsChangerBot/src/main/kotlin/RightsChanger.kt b/RightsChangerBot/src/main/kotlin/RightsChanger.kt index aa172c9..72cedc7 100644 --- a/RightsChangerBot/src/main/kotlin/RightsChanger.kt +++ b/RightsChangerBot/src/main/kotlin/RightsChanger.kt @@ -109,7 +109,11 @@ suspend fun main(args: Array) { } } - bot.buildBehaviourWithLongPolling { + bot.buildBehaviourWithLongPolling( + defaultExceptionsHandler = { + println(it) + } + ) { onCommand("simple", initialFilter = { it.chat is PublicChat && it.fromUserMessageOrNull() ?.user ?.id == allowedAdmin }) { val replyMessage = it.replyTo val userInReply = replyMessage ?.fromUserMessageOrNull() ?.user ?.id ?: return@onCommand diff --git a/gradle.properties b/gradle.properties index 3e82a14..5abe299 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ kotlin.code.style=official org.gradle.parallel=true # Due to parallel compilation project require next amount of memory on full build -org.gradle.jvmargs=-Xmx768m +org.gradle.jvmargs=-Xmx1g kotlin_version=1.8.10