From 317088ae929b4ce150fd2dde8b5105ece284ce4a Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 2 Sep 2026 16:03:20 +0700 Subject: [PATCH] =?UTF-8?q?feat(misc):=20add=20/xlt1=20=C4=91=C6=A1n=20xin?= =?UTF-8?q?=20l=E1=BB=97i=20T1=20petition=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sequel to /ff: the same fan who panicked and surrendered mid-series now files an administrative petition because the team came back. Punchlines are quoted back as the sender's own words and retracted rather than asserted fresh. Shaped as a Vietnamese đơn từ parody — quốc hiệu, Kính gửi, Nội dung sự việc, Tôi xin cam kết, signature block — since the joke is the bureaucratic form, not the wording. Carries no scoreline or title count so it does not go stale next split. Reuses senderMention for the Tôi tên là field and the signature, which made the trongTruongHopUpdate test helper name wrong; renamed it messageFrom now that two command families share it. --- README.md | 2 +- internal/modules/misc/handlers_test.go | 56 ++++++++++++++---- internal/modules/misc/misc.go | 12 ++-- internal/modules/misc/misc_test.go | 1 + internal/modules/misc/xlt1_command.go | 80 ++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 16 deletions(-) create mode 100644 internal/modules/misc/xlt1_command.go diff --git a/README.md b/README.md index 4824cec..d83eee1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Atlas via long polling and an in-process cron scheduler. | Module | What it does | |---|---| | `util` | `/help`, `/info`, `/stickerid` | -| `misc` | `/ping`, `/ping_stats`, `/random`, `/wheelofnames`, `/ff`, `/the_answer`, `/trongtruonghop` + `/tth`, `/trongtruonghopvng` + `/tthvng` disclaimers | +| `misc` | `/ping`, `/ping_stats`, `/random`, `/wheelofnames`, `/ff`, `/xlt1`, `/the_answer`, `/trongtruonghop` + `/tth`, `/trongtruonghopvng` + `/tthvng` disclaimers | | `amlich` | Vietnamese lunar calendar: `/amlich` (dương lịch → âm lịch, defaults to today), `/duonglich` (âm lịch → dương lịch, `nhuan` flag for leap months); dates accept `d`, `d/m`, or `d/m/yyyy` — missing parts fill from today in the input's calendar. Years 1800–2199 only | | `wordle` | Daily Wordle game | | `loldle` | League-of-Legends "guess the champion" | diff --git a/internal/modules/misc/handlers_test.go b/internal/modules/misc/handlers_test.go index f552de4..75d7c49 100644 --- a/internal/modules/misc/handlers_test.go +++ b/internal/modules/misc/handlers_test.go @@ -368,11 +368,11 @@ func TestWheelOfNames_ForwardsMessageThreadID(t *testing.T) { } } -// trongTruongHopUpdate is the inline counterpart of testutil.NewPrivateMessage +// messageFrom is the inline counterpart of testutil.NewPrivateMessage // for cases that need control over From (username, names). The dispatcher // requires a bot_command entity, so we lift that from the helper API by reusing // NewPrivateMessage and overwriting From. -func trongTruongHopUpdate(t *testing.T, text string, from *models.User) *models.Update { +func messageFrom(t *testing.T, text string, from *models.User) *models.Update { t.Helper() u := testutil.NewPrivateMessage(from.ID, text) u.Message.From = from @@ -381,7 +381,7 @@ func trongTruongHopUpdate(t *testing.T, text string, from *models.User) *models. func TestTrongTruongHop_DefaultText(t *testing.T) { rb, _ := installMisc(t, 999) - rb.Bot.ProcessUpdate(context.Background(), trongTruongHopUpdate(t, "/trongtruonghop", + rb.Bot.ProcessUpdate(context.Background(), messageFrom(t, "/trongtruonghop", &models.User{ID: 7, Username: "boss", FirstName: "Boss"})) got := rb.LastSent().Text() @@ -393,7 +393,7 @@ func TestTrongTruongHop_DefaultText(t *testing.T) { func TestTrongTruongHop_CustomArg(t *testing.T) { rb, _ := installMisc(t, 999) - rb.Bot.ProcessUpdate(context.Background(), trongTruongHopUpdate(t, "/trongtruonghop Acme Corp", + rb.Bot.ProcessUpdate(context.Background(), messageFrom(t, "/trongtruonghop Acme Corp", &models.User{ID: 7, Username: "boss", FirstName: "Boss"})) got := rb.LastSent().Text() @@ -410,7 +410,7 @@ func TestTrongTruongHop_CustomArg(t *testing.T) { func TestTTHAlias_CustomArg(t *testing.T) { rb, _ := installMisc(t, 999) - rb.Bot.ProcessUpdate(context.Background(), trongTruongHopUpdate(t, "/tth Acme Corp", + rb.Bot.ProcessUpdate(context.Background(), messageFrom(t, "/tth Acme Corp", &models.User{ID: 7, Username: "boss", FirstName: "Boss"})) got := rb.LastSent().Text() @@ -424,7 +424,7 @@ func TestTTHAlias_CustomArg(t *testing.T) { func TestTrongTruongHop_HTMLEscapesArg(t *testing.T) { rb, _ := installMisc(t, 999) - rb.Bot.ProcessUpdate(context.Background(), trongTruongHopUpdate(t, "/trongtruonghop