Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Szer committed Sep 26, 2023
1 parent af12f1f commit f83107f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/VahterBanBot/Bot.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ let isBanAuthorized (botConfig: BotConfiguration) (message: Message) (logger: IL
let fromUsername = message.From.Username
let targetUserId = message.ReplyToMessage.From.Id
let targetUsername = message.ReplyToMessage.From.Username
let chatId = message.Chat.Id
let chatUsername = message.Chat.Username

// check that user is allowed to ban others
if isMessageFromAdmin botConfig message && isMessageFromAllowedChats botConfig message then
if isMessageFromAdmin botConfig message then
if not(isMessageFromAllowedChats botConfig message) then
logger.LogWarning $"User {fromUsername} {fromUserId} tried to ban user {targetUsername} ({targetUserId}) from not allowed chat {chatUsername} ({chatId})"
false
// check that user is not trying to ban other admins
if isBannedPersonAdmin botConfig message then
logger.LogWarning $"User {fromUsername} {fromUserId} tried to ban admin {targetUsername} {targetUserId}"
elif isBannedPersonAdmin botConfig message then
logger.LogWarning $"User {fromUsername} ({fromUserId}) tried to ban admin {targetUsername} ({targetUserId}) in chat {chatUsername} ({chatId}"
false
else
true
else
logger.LogWarning $"User {fromUsername} ({fromUserId}) tried to ban user {targetUsername} ({targetUserId}) without being admin in chat {chatUsername} ({chatId}"
false

let banInAllChats (botConfig: BotConfiguration) (botClient: ITelegramBotClient) targetUserId = task {
Expand Down

0 comments on commit f83107f

Please sign in to comment.