fix(misc): make /xlt1 public

Filing the petition is the group joke, so it should not be admin-gated
the way /ff is. Its denial test becomes a non-admin allow test.
This commit is contained in:
tiennm99 committed 2026-09-02 16:16:20 +07:00
1 parent 4f4817b597
commit 5826995c31
5 files changed
+12 -9

No files matched your search

+7 -4
View File
@@ -514,12 +514,15 @@ func TestFF_UppercaseFormDispatches(t *testing.T) {
}
}
func TestXLT1_DeniedToNonAdmin(t *testing.T) {
// Public, unlike its /ff counterpart — anyone in the group can be made to
// file the paperwork.
func TestXLT1_AllowedToNonAdmin(t *testing.T) {
rb, _ := installMisc(t, 999)
rb.Bot.ProcessUpdate(context.Background(), testutil.NewPrivateMessage(7, "/xlt1"))
if calls := rb.Sent(); len(calls) != 0 {
t.Errorf("non-admin /xlt1 replied: %+v", calls)
rb.Bot.ProcessUpdate(context.Background(), messageFrom(t, "/xlt1",
&models.User{ID: 7, Username: "nobody"}))
if got := rb.LastSent().Text(); got != fmt.Sprintf(xlt1Template, "@nobody", "@nobody") {
t.Errorf("non-admin /xlt1 reply = %q, want the xlt1 petition", got)
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
// Package misc is a small stub module that proves the framework end-to-end:
// /ping (public, exercises KV write), /ping_stats (protected, exercises KV
// read), /random (public random picker), /wheelofnames (public wheel picker
// with optional GIF), /ff (protected give-up-on-T1 rant), /xlt1 (protected
// with optional GIF), /ff (protected give-up-on-T1 rant), /xlt1 (public
// apologise-to-T1 petition, the sequel to /ff), /the_answer (private easter
// egg), and small public disclaimer commands.
package misc
+1 -1
View File
@@ -26,7 +26,7 @@ func TestNew_RegistersExpectedCommands(t *testing.T) {
"random": modules.VisibilityPublic,
"wheelofnames": modules.VisibilityPublic,
"ff": modules.VisibilityProtected,
"xlt1": modules.VisibilityProtected,
"xlt1": modules.VisibilityPublic,
"the_answer": modules.VisibilityPrivate,
"trongtruonghop": modules.VisibilityPublic,
"tth": modules.VisibilityPublic,
+1 -1
View File
@@ -66,7 +66,7 @@ Tôi xin trân trọng cảm ơn! 🙏
func xlt1Command() modules.Command {
return modules.Command{
Name: "xlt1",
Visibility: modules.VisibilityProtected,
Visibility: modules.VisibilityPublic,
Description: "Văn mẫu đơn xin lỗi T1 — dành cho lúc trù xong phải quay xe",
Handler: func(ctx context.Context, b *bot.Bot, update *models.Update) error {
if update.Message == nil {
@@ -83,7 +83,7 @@ Bổ sung từ search: meme "tê liệt / ngồi xe lăn" (fan lẫn anti dùng
|---|---|---|
| Tên | `xlt1` | khớp `^[a-z0-9_]{1,32}$` (`internal/modules/validate.go:10`) |
| Module | `misc` | cùng chỗ với `/ff`, `/tth` |
| Visibility | `Protected` | soi chiếu `/ff` — cùng thể loại văn mẫu spam nhóm |
| Visibility | `Public` | user chốt: ai trong nhóm cũng phải làm được đơn; soi chiếu `/tth` chứ không phải `/ff` |
| Nội suy | mention người gửi ×2 | dùng lại `senderMention()` sẵn có (DRY); lấp ô "Tôi tên là" + "Người làm đơn" |
| Parse mode | HTML | mention cần thẻ `<a href="tg://user?id=...">`; giống `disclaimerCommand` |
| Tham số | không | như `/ff`, args bị bỏ qua |
@@ -111,5 +111,5 @@ File mới `internal/modules/misc/xlt1_command.go`, một `const` template + m
## Unresolved Questions
1. `/xlt1` nên `Protected` (soi `/ff`) hay `Public` (soi `/tth`)? Đã chọn `Protected`; đổi 1 dòng nếu muốn public.
1. ~~`Protected` hay `Public`?~~ Đã chốt `Public` (2026-09-02).
2. Có cần alias (`/xinloit1`)? Hiện chỉ làm đúng `/xlt1` như yêu cầu.