diff --git a/app/events/listener_part3_test.go b/app/events/listener_part3_test.go index 0400546b..ef23aba0 100644 --- a/app/events/listener_part3_test.go +++ b/app/events/listener_part3_test.go @@ -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) diff --git a/app/events/pipeline.go b/app/events/pipeline.go index 3a636c7c..5bd2a4f5 100644 --- a/app/events/pipeline.go +++ b/app/events/pipeline.go @@ -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, diff --git a/app/runtime_assembly.go b/app/runtime_assembly.go index 69adff23..26813b66 100644 --- a/app/runtime_assembly.go +++ b/app/runtime_assembly.go @@ -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,