Skip to content

Commit 162e322

Browse files
author
cuiko
committed
ref(contact): Rename report --ban to --block for naming consistency
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.
1 parent b2ee5b5 commit 162e322

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ client commands route through when present).
123123
| `tg chat invite create <ref>` | Create an invite link. `--title`, `--expire <RFC3339\|dur>`, `--usage-limit <n>`, `--request-needed`. |
124124
| `tg chat invite list <ref>` | List invite links. `--revoked`, `--admin <user>`, `--limit`. |
125125
| `tg chat invite revoke <ref> <link>` / `delete <ref> <link>` | Revoke a link, or delete a revoked one. |
126-
| `tg chat ban <ref> <user>` / `tg chat unban <ref> <user>` | Ban (remove + block) or unban a member. Ban prompts unless `--yes`. |
126+
| `tg chat ban <ref> <user>` / `tg chat unban <ref> <user>` | Ban (remove + restrict) or unban a member of a group/channel. Ban prompts unless `--yes`. |
127127
| `tg chat admin promote <ref> <user>` / `tg chat admin demote <ref> <user>` | Grant or revoke admin rights. `--rights <keywords>` grants a specific set (`info,post,edit,delete,ban,invite,pin,add_admins,anonymous,call,topics,post_stories,edit_stories,delete_stories`); omit `--rights` for a broad default set. `--title <rank>` sets a custom admin title (≤16 chars); omit `--title` to keep the current title, pass `--title ""` to clear it. |
128128
| `tg chat member set-perms <ref> <user>` | Set a member's permissions with `--deny`/`--allow` keywords (`send,media,stickers,bots,polls,links,invite,pin,info,topics`) and optional `--until <RFC3339\|dur>` (default permanent). |
129129
| `tg chat member unset-perms <ref> <user>` | Clear all permission restrictions on a member. |
@@ -159,7 +159,7 @@ client commands route through when present).
159159
| `tg contact delete <ref>` | Delete a contact. |
160160
| `tg contact block <ref>` | Block a user, bot, or channel. |
161161
| `tg contact unblock <ref>` | Unblock a user, bot, or channel. |
162-
| `tg contact report <ref>` | Report a peer to Telegram. `--reason` (spam (default), violence, porn, child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other), `--message <comment>`, `--ban` (also block). Prompts unless `--yes`. |
162+
| `tg contact report <ref>` | Report a peer to Telegram. `--reason` (spam (default), violence, porn, child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other), `--message <comment>`, `--block` (also block the peer). Prompts unless `--yes`. |
163163
| `tg me` | Print the current Telegram identity. |
164164
| `tg profile set-name <first>` | Set first name; `--last` sets or clears last name. |
165165
| `tg profile set-username <username>` | Set or clear the public username. |

internal/action/contact/report.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type ReportRequest struct {
3131
RawRef string
3232
Reason string
3333
Message string
34-
Ban bool // also block the peer after reporting
34+
Block bool // also block the peer after reporting
3535
Yes bool
3636
Prompter ui.Prompter
3737
}
@@ -41,7 +41,7 @@ type ReportQuery struct {
4141
Ref ref.Ref
4242
Reason string
4343
Message string
44-
Ban bool
44+
Block bool
4545
}
4646

4747
// ReportFunc reports one peer after request validation.
@@ -64,11 +64,11 @@ func Report(ctx context.Context, req ReportRequest, do ReportFunc) error {
6464
return fmt.Errorf("%w: contact report called without report function", command.ErrPrecondition)
6565
}
6666
prompt := fmt.Sprintf("report %s for %s?", req.RawRef, reason)
67-
if req.Ban {
67+
if req.Block {
6868
prompt = fmt.Sprintf("report %s for %s and block them?", req.RawRef, reason)
6969
}
7070
if err := ui.ConfirmDestructive(req.Prompter, prompt, req.Yes); err != nil {
7171
return err
7272
}
73-
return do(ctx, ReportQuery{Ref: parsed, Reason: reason, Message: req.Message, Ban: req.Ban})
73+
return do(ctx, ReportQuery{Ref: parsed, Reason: reason, Message: req.Message, Block: req.Block})
7474
}

internal/action/contact/report_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ func TestReportDefaultsToSpam(t *testing.T) {
2020
func(_ context.Context, q contact.ReportQuery) error {
2121
require.Equal(t, "bob", q.Ref.Value)
2222
require.Equal(t, "spam", q.Reason)
23-
require.False(t, q.Ban)
23+
require.False(t, q.Block)
2424
return nil
2525
})
2626
require.NoError(t, err)
2727
}
2828

29-
func TestReportPassesReasonMessageAndBan(t *testing.T) {
29+
func TestReportPassesReasonMessageAndBlock(t *testing.T) {
3030
err := contact.Report(context.Background(), contact.ReportRequest{
31-
RawRef: "@bob", Reason: "fake", Message: "scam", Ban: true, Yes: true,
31+
RawRef: "@bob", Reason: "fake", Message: "scam", Block: true, Yes: true,
3232
}, func(_ context.Context, q contact.ReportQuery) error {
3333
require.Equal(t, "fake", q.Reason)
3434
require.Equal(t, "scam", q.Message)
35-
require.True(t, q.Ban)
35+
require.True(t, q.Block)
3636
return nil
3737
})
3838
require.NoError(t, err)

internal/cli/contact/report/report.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Options struct {
2222
RawRef string
2323
Reason string
2424
Message string
25-
Ban bool
25+
Block bool
2626
Yes bool
2727

2828
IOStreams *ui.IOStreams
@@ -53,7 +53,7 @@ func New(f *runtime.Invocation, runF func(*Options) error) *cobra.Command {
5353
}
5454
cmd.Flags().StringVar(&opts.Reason, "reason", "spam", "Report reason: spam, violence, porn, child-abuse, copyright, fake, drugs, personal-details, geo-irrelevant, other")
5555
cmd.Flags().StringVar(&opts.Message, "message", "", "Optional comment for report moderation")
56-
cmd.Flags().BoolVar(&opts.Ban, "ban", false, "Also block the peer after reporting")
56+
cmd.Flags().BoolVar(&opts.Block, "block", false, "Also block the peer after reporting")
5757
cmd.Flags().BoolVarP(&opts.Yes, "yes", "y", false, "Skip confirmation prompt")
5858
command.SetMeta(cmd, command.Meta{NeedsAccount: true, NeedsClient: true})
5959
return cmd
@@ -65,14 +65,14 @@ func Run(ctx context.Context, opts *Options) error {
6565
RawRef: opts.RawRef,
6666
Reason: opts.Reason,
6767
Message: opts.Message,
68-
Ban: opts.Ban,
68+
Block: opts.Block,
6969
Yes: opts.Yes,
7070
Prompter: opts.Prompter,
7171
}, opts.Report); err != nil {
7272
return err
7373
}
7474
verb := "reported"
75-
if opts.Ban {
75+
if opts.Block {
7676
verb = "reported+blocked"
7777
}
7878
_, _ = fmt.Fprintf(opts.IOStreams.Out, "%s\t%s\n", verb, opts.RawRef)

internal/telegram/contacts.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ func UnblockContact(ctx context.Context, api *tg.Client, resolver *peer.Resolver
116116
}
117117

118118
// ReportPeer reports one resolved peer to Telegram moderation via
119-
// account.reportPeer with the given reason and optional comment. When q.Ban is
120-
// set it also blocks the peer (contacts.block) after a successful report.
119+
// account.reportPeer with the given reason and optional comment. When q.Block
120+
// is set it also blocks the peer (contacts.block) after a successful report.
121121
func ReportPeer(ctx context.Context, api *tg.Client, resolver *peer.Resolver, q actioncontact.ReportQuery) error {
122122
resolved, err := resolver.Resolve(ctx, q.Ref)
123123
if err != nil {
@@ -130,7 +130,7 @@ func ReportPeer(ctx context.Context, api *tg.Client, resolver *peer.Resolver, q
130130
}); err != nil {
131131
return err
132132
}
133-
if q.Ban {
133+
if q.Block {
134134
if _, err := api.ContactsBlock(ctx, &tg.ContactsBlockRequest{ID: resolved.InputPeer}); err != nil {
135135
return err
136136
}

0 commit comments

Comments
 (0)