Skip to content

Commit

Permalink
Use username or display name for spam logging to db
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jan 8, 2025
1 parent fd96788 commit b5bb83e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ func makeSpamLogger(ctx context.Context, gid string, wr io.Writer, dataDB *stora
}

logWr := events.SpamLoggerFunc(func(msg *bot.Message, response *bot.Response) {
userName := msg.From.Username
if userName == "" {
userName = msg.From.DisplayName
}
// write to log file
text := strings.ReplaceAll(msg.Text, "\n", " ")
text = strings.TrimSpace(text)
Expand Down Expand Up @@ -621,7 +625,7 @@ func makeSpamLogger(ctx context.Context, gid string, wr io.Writer, dataDB *stora
rec := storage.DetectedSpamInfo{
Text: text,
UserID: msg.From.ID,
UserName: msg.From.Username,
UserName: userName,
Timestamp: time.Now().In(time.Local),
GID: gid,
}
Expand Down

0 comments on commit b5bb83e

Please sign in to comment.