Skip to content

Commit

Permalink
ban confirmation in soft mode performs full ban for the uses
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Apr 24, 2024
1 parent 197116a commit 8f6edd0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/events/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,20 @@ func (a *admin) callbackBanConfirmed(query *tbapi.CallbackQuery) error {
}
}

// for soft ban we need to ba user for real on confirmation
if a.softBan && !a.trainingMode {
userName, err := a.extractUsername(query.Message.Text) // try to extract username from the message
if err != nil {
log.Printf("[DEBUG] failed to extract username from %q: %v", query.Message.Text, err)
userName = ""
}
banReq := banRequest{duration: bot.PermanentBanDuration, userID: userID, chatID: a.primChatID,
tbAPI: a.tbAPI, dry: a.dry, training: a.trainingMode, userName: userName, restrict: false}
if err := banUserOrChannel(banReq); err != nil {
return fmt.Errorf("failed to ban user %d: %w", userID, err)
}
}

return nil
}

Expand Down

0 comments on commit 8f6edd0

Please sign in to comment.