feat(contact): Add contact report to report a peer, with optional ban#31
Merged
Conversation
added 3 commits
June 5, 2026 16:35
`tg contact report <ref>` reports a user/bot/group/channel to Telegram via account.reportPeer. --reason picks the category (spam default; violence, porn, child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other), --message attaches a moderation comment, and --ban also blocks the peer after a successful report. Confirmation prompts unless --yes, mirroring block/ban. Routes through the daemon (contact.report) like the other contact mutations.
The accepted --reason keywords live in both ReportReasons (action, validation) and reportReason (telegram, mapping); the layers can't share a source. Add sync notes so adding a reason to one without the other doesn't silently report as spam.
The flag invokes contacts.block, not channels.editBanned, so call it --block. This keeps the terminology unambiguous: "ban" is group/channel scope (chat ban/unban), "block" is account scope (contact block/unblock, report --block). Also reword the chat ban help so "block" isn't used for a group ban.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tg contact report <ref>reports a user/bot/group/channel to Telegram viaaccount.reportPeer.--reasonselects the category:spam(default),violence,porn,child-abuse,copyright,fake,drugs,personal-details,geo-irrelevant,other.--messageattaches an optional moderation comment;--blockalso blocks the peer (contacts.block) after a successful report.--yes, mirroringblock/ban. Routes through the daemon (contact.report) like the other contact mutations.Naming
--block(not--ban): it callscontacts.block. Terminology is kept consistent across the CLI — "ban" = group/channel scope (chat ban/unban,channels.editBanned), "block" = account scope (contact block/unblock,report --block,contacts.block).Notes
account.reportPeerreturns only a bool and Telegram exposes no way to list submitted reports. Success = the call returns without error. The--blockside effect is verifiable viacontact list --blocked.Test plan
go build ./...,go vet,golangci-lint run,go test ./...spam, unknown-reason rejection,--message/--blockpass-through, decline-skips-dispatch;contact.reportadded to the daemon registered-methods test.contact report <peer> --reason spam --block --yes(then run as--banpre-rename) against a real spam DM succeeded; the peer then appeared incontact list --blocked(blocked count 12 → 13), confirming the report call succeeded and the block took effect.