diff --git a/app/events/admin.go b/app/events/admin.go index 067e79b..5db19d9 100644 --- a/app/events/admin.go +++ b/app/events/admin.go @@ -41,7 +41,11 @@ const ( func (a *admin) ReportBan(banUserStr string, msg *bot.Message) { log.Printf("[DEBUG] report to admin chat, ban msgsData for %s, group: %d", banUserStr, a.adminChatID) text := strings.ReplaceAll(escapeMarkDownV1Text(msg.Text), "\n", " ") - forwardMsg := fmt.Sprintf("**permanently banned [%s](tg://user?id=%d)**\n\n%s\n\n", banUserStr, msg.From.ID, text) + would := "" + if a.dry { + would = "would have " + } + forwardMsg := fmt.Sprintf("**%spermanently banned [%s](tg://user?id=%d)**\n\n%s\n\n", would, banUserStr, msg.From.ID, text) if err := a.sendWithUnbanMarkup(forwardMsg, "change ban", msg.From, msg.ID, a.adminChatID); err != nil { log.Printf("[WARN] failed to send admin message, %v", err) } diff --git a/app/events/admin_test.go b/app/events/admin_test.go index cdc852d..f2d23c5 100644 --- a/app/events/admin_test.go +++ b/app/events/admin_test.go @@ -189,3 +189,20 @@ func TestAdmin_extractUsername(t *testing.T) { }) } } + +func TestAdmin_dryModeForwardMessage(t *testing.T) { + mockAPI := &mocks.TbAPIMock{ + SendFunc: func(c tbapi.Chattable) (tbapi.Message, error) { + return tbapi.Message{}, nil + }, + } + adm := admin{ + tbAPI: mockAPI, + dry: true, + } + msg := &bot.Message{} + + adm.ReportBan("testUser", msg) + assert.Contains(t, mockAPI.SendCalls()[0].C.(tbapi.MessageConfig).Text, "would have permanently banned [testUser]") + +}