Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/events/listener_part3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ func TestTelegramListener_DoWithBotSoftBan(t *testing.T) {
assert.Len(t, mockLogger.SaveCalls(), 1)
assert.Equal(t, "text 123", mockLogger.SaveCalls()[0].Msg.Text)
assert.Equal(t, "user", mockLogger.SaveCalls()[0].Msg.From.Username)
assert.Empty(t, mockAPI.SendCalls())
assert.Len(t, mockAPI.SendCalls(), 1, "restriction group message should be sent after a soft-ban")
assert.Equal(t, restrictGroupMessageText, mockAPI.SendCalls()[0].C.(tbapi.MessageConfig).Text)
assert.Len(t, mockAPI.RequestCalls(), 1)
assert.Equal(t, int64(123), mockAPI.RequestCalls()[0].C.(tbapi.RestrictChatMemberConfig).ChatID)
assert.Equal(t, int64(1), mockAPI.RequestCalls()[0].C.(tbapi.RestrictChatMemberConfig).UserID)
Expand Down
19 changes: 13 additions & 6 deletions app/events/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,18 +475,25 @@ func (l *TelegramListener) processWarn(ctx context.Context, pc pipelineContext)
return l.cleanupAfterAction(ctx, pc, errs)
}

const banGroupMessageText = "🚫 Пользователь забанен за спам"
const (
banGroupMessageText = "🚫 Пользователь забанен за спам"
restrictGroupMessageText = "🔇 Пользователь ограничен за спам"
)

// postBanGroupMessage posts the self-deleting ban notice with the appeal
// button to the group chat. It is skipped for channel bans, restrictions
// (mutes), and dry/training runs where no real ban happened.
// postBanGroupMessage posts the self-deleting ban or restriction notice with
// the appeal button to the group chat. It is skipped for channel bans and
// dry/training runs where no real enforcement happened.
func (l *TelegramListener) postBanGroupMessage(ctx context.Context, pc pipelineContext, incidentID int64) {
if l.Dry || l.TrainingMode || pc.outcome.Restrict || pc.resp.ChannelID != 0 {
if l.Dry || l.TrainingMode || pc.resp.ChannelID != 0 {
return
}
text := banGroupMessageText
if pc.outcome.Restrict {
text = restrictGroupMessageText
}
if err := l.ActionExecutor.PostBanMessage(ctx, banMessageRequest{
chatID: pc.fromChat,
text: banGroupMessageText,
text: text,
incidentID: incidentID,
botUsername: l.BotUsername,
delTime: l.ModerationConfig.WarnDeleteDuration,
Expand Down
1 change: 1 addition & 0 deletions app/runtime_assembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func assembleRuntime(ctx context.Context, opts options) (*runtimeAssembly, error
ApprovedUsersService: approvedUsersSvc,
DictionaryService: dictSvc,
DetectedSpamService: detectedSpamSvc,
AuditService: auditSvc,
AppealService: appealSvc,
FeedbackService: feedbackSvc,
ReviewService: reviewSvc,
Expand Down