From 610ada505f16635e7285128ae123ca67c702dc56 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 9 Jul 2024 17:35:10 +0600 Subject: [PATCH] add notice about privacy handling --- .../behaviour_builder/BehaviourBuilders.kt | 5 +++++ .../kotlin/dev/inmo/tgbotapi/utils/DefaultKSLog.kt | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt index 1990b89eba..2681cbbe06 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourBuilders.kt @@ -1,5 +1,6 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder +import dev.inmo.kslog.common.e import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler import dev.inmo.micro_utils.coroutines.ExceptionHandler import dev.inmo.tgbotapi.bot.TelegramBot @@ -8,6 +9,7 @@ import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdat import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation import dev.inmo.tgbotapi.types.Seconds import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter +import dev.inmo.tgbotapi.utils.DefaultKTgBotAPIKSLog import kotlinx.coroutines.* /** @@ -70,6 +72,9 @@ suspend fun TelegramBot.buildBehaviourWithLongPolling( defaultExceptionsHandler = defaultExceptionsHandler, block = block ) + if (!behaviourContext.triggersHolder.handleableCommandsHolder.isHandled("privacy")) { + DefaultKTgBotAPIKSLog.e { "For some or bots there is no handling \"privacy\" command. According to https://telegram.org/tos/bot-developers#4-privacy it may lead to bot deactivation or removing" } + } return longPolling( behaviourContext, scope = behaviourContext, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/DefaultKSLog.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/DefaultKSLog.kt index a7736691f3..8ac4a4baa7 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/DefaultKSLog.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/DefaultKSLog.kt @@ -1,11 +1,19 @@ package dev.inmo.tgbotapi.utils import dev.inmo.kslog.common.KSLog +import dev.inmo.kslog.common.LogLevel import dev.inmo.kslog.common.TagLogger +/** + * Default tag for [DefaultKTgBotAPIKSLog]. You may change it and tag will be changed since the near logging + */ +var DefaultKTgBotAPIKSLogSystemTag: String = "KTgBot" /** * Default realization of [KSLog] which will be used everywhere where there is no some custom variant of [KSLog] * - * By default, uses [TagLogger] with tag `KTgBot` (which in fact falling back to [KSLog.default] with `KTgBot` default tag) + * By default, uses [KSLog] factory with lambda and tag [DefaultKTgBotAPIKSLogSystemTag] (which in fact falling back to + * [KSLog.default] with `KTgBot` default tag) */ -var DefaultKTgBotAPIKSLog: KSLog = TagLogger("KTgBot") +var DefaultKTgBotAPIKSLog: KSLog = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? -> + TagLogger(DefaultKTgBotAPIKSLogSystemTag).performLog(level, tag, message, throwable) +}