Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
adjust logging, remove stacktraces and less verbose on users banning
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Oct 28, 2022
1 parent ccb8948 commit e5b1c71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func banAndKickUsers(ctx context.Context, api *tg.Client, channel *tg.Channel, f
return
}

for _, userID := range userIDs {
log.Printf("[INFO] Banning and kicking user %d forever", userID)
for i, userID := range userIDs {
log.Printf("[DEBUG] Banning and kicking user %d forever", userID)
_, err = api.ChannelsEditBanned(ctx, &tg.ChannelsEditBannedRequest{
Channel: channel.AsInput(),
Participant: &tg.InputPeerUser{UserID: userID},
Expand All @@ -45,14 +45,15 @@ func banAndKickUsers(ctx context.Context, api *tg.Client, channel *tg.Channel, f
if err != nil {
log.Printf("[ERROR] error banning user %d: %v", userID, err)
}
log.Printf("[INFO] Deleting messages by the user %d", userID)
log.Printf("[DEBUG] Deleting messages by the user %d", userID)
_, err = api.ChannelsDeleteParticipantHistory(ctx, &tg.ChannelsDeleteParticipantHistoryRequest{
Channel: channel.AsInput(),
Participant: &tg.InputPeerUser{UserID: userID},
})
if err != nil {
log.Printf("[ERROR] error deleting messages by the user %d: %v", userID, err)
}
log.Printf("[INFO] Done processing user #%d out of %d", i+1, len(userIDs))
}
}

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func getChannel(ctx context.Context, api *tg.Client, channelID int64) (*tg.Chann

func setupLog(dbg bool) {
if dbg {
log.Setup(log.Debug, log.CallerFile, log.CallerFunc, log.Msec, log.LevelBraces, log.StackTraceOnError)
log.Setup(log.Debug, log.CallerFile, log.CallerFunc, log.Msec, log.LevelBraces)
return
}
log.Setup(log.Msec, log.LevelBraces, log.StackTraceOnError)
log.Setup(log.Msec, log.LevelBraces)
}

0 comments on commit e5b1c71

Please sign in to comment.