diff --git a/src/VahterBanBot/Bot.fs b/src/VahterBanBot/Bot.fs index 90f0261..a60c1b5 100644 --- a/src/VahterBanBot/Bot.fs +++ b/src/VahterBanBot/Bot.fs @@ -509,7 +509,7 @@ let autoBan let calculateCustomEmojiProportion (message: Message) : float option = - let textLen = message.Text |> Seq.where(fun c -> not (" :.,\n\r".Contains c)) |> Seq.length + let textLen = message.TextOrCaption |> Seq.where(fun c -> not (" :.,\n\r".Contains c)) |> Seq.length let customEmojiCount = message.Entities |> Array.where(fun e -> e.Type = MessageEntityType.CustomEmoji) |> Array.length if customEmojiCount = 0 || textLen = 0 then @@ -518,6 +518,7 @@ let calculateCustomEmojiProportion let proportion = float customEmojiCount / float textLen Some proportion + let justMessage (botUser: DbUser) (botClient: ITelegramBotClient) @@ -591,7 +592,7 @@ let justMessage if not messageIsDeleted && botConfig.BanCustomEmojiEnabled && message.TextOrCaption <> null - && botUser.created_at > DateTime.Now.AddDays(-botConfig.BanCustomEmojiRegisteredInDbDaysToDontBan) + && botUser.created_at <= DateTime.Now.AddDays(-botConfig.BanCustomEmojiRegisteredInDbDaysToDontBan) && message.TextOrCaption.Length >= botConfig.BanCustomEmojiTextMinLen then let! usrMsgCount = DB.countUniqueUserMsg message.From.Id diff --git a/src/VahterBanBot/Program.fs b/src/VahterBanBot/Program.fs index 4dea216..2e7bf08 100644 --- a/src/VahterBanBot/Program.fs +++ b/src/VahterBanBot/Program.fs @@ -82,7 +82,7 @@ let botConf = BanCustomEmojiProportionToBan = getEnvOr "BAN_CUSTOM_EMOJI_PROPORTION_TO_BAN" "0.3" |> float BanCustomEmojiPreviousMessagesCountToDontBan = getEnvOr "BAN_CUSTOM_EMOJI_PREVIOUS_MESSAGES_COUNT_TO_DONT_BAN" "5" |> int32 BanCustomEmojiRegisteredInDbDaysToDontBan = getEnvOr "BAN_CUSTOM_EMOJI_REGISTERED_IN_DB_DAYS_TO_DONT_BAN" "80" |> int32 - BanCustomEmojiTextMinLen = getEnvOr "BAN_CUSTOM_TEXT_MIN_LEN" "10" |> int32} + BanCustomEmojiTextMinLen = getEnvOr "BAN_CUSTOM_EMOJI_TEXT_MIN_LEN" "10" |> int32} let validateApiKey (ctx : HttpContext) = match ctx.TryGetRequestHeader "X-Telegram-Bot-Api-Secret-Token" with