From eb34adf387304f6fa318cc57042b4112ce89b0f9 Mon Sep 17 00:00:00 2001 From: cuiko Date: Wed, 3 Jun 2026 23:46:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(msg):=20Add=20`msg=20gif`=20=E2=80=94=20li?= =?UTF-8?q?st=20and=20send=20saved=20GIFs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tg msg gif list` lists saved GIFs (messages.getSavedGifs), each with a self-contained `gif_` ref handle. `msg send --gif ` sends a gif by that handle or by a of an existing gif; it's mutually exclusive with text, --file, and --sticker, and refreshes an expired ref from the saved-gifs list. The ref-token codec is shared with stickers via a prefix. Also fix document media-kind detection to prefer Animated over Video, so an mp4 gif (which carries both attributes) reads as "gif", not "video" (in msg list / msg info, regardless of attribute order). Verified real-env: gif list; send by ref lands as type "gif" with detail; a non-gif message ref is rejected. --- README.md | 3 +- internal/action/message/gif.go | 77 ++++++++++++++++++ internal/action/message/gif_test.go | 76 +++++++++++++++++ internal/action/message/ops.go | 14 +++- internal/action/message/sticker.go | 27 ++++--- internal/cli/msg/gif/gif.go | 83 +++++++++++++++++++ internal/cli/msg/msg.go | 2 + internal/cli/msg/send/send.go | 7 +- internal/telegram/gif.go | 117 +++++++++++++++++++++++++++ internal/telegram/message_ops.go | 2 + internal/telegram/search_messages.go | 27 +++++-- 11 files changed, 412 insertions(+), 23 deletions(-) create mode 100644 internal/action/message/gif.go create mode 100644 internal/action/message/gif_test.go create mode 100644 internal/cli/msg/gif/gif.go create mode 100644 internal/telegram/gif.go diff --git a/README.md b/README.md index 356c3d8..30d6cd7 100644 --- a/README.md +++ b/README.md @@ -130,9 +130,10 @@ client commands route through when present). | `tg chat perms ` | Set the group's default member permissions with `--deny`/`--allow` (same keywords). | | `tg msg list ` | List message history. Album members (same `grouped_id`) merge into one row with an `album` array (`--limit` counts an album as one). | | `tg msg info ` | Show one message's details: media info (file name/size/mime, dimensions, duration, sticker emoji, web-page title/url), album members (each with media detail), and poll content (question, numbered options, tallies). | -| `tg msg send [text...]` | Send text. Repeat `--file ` to attach one or more files; text becomes the first media caption. Use `--name` to override upload filenames. `--sticker ` sends a sticker — either a `msg sticker list` ref or a `` of an existing sticker (no text/`--file`). | +| `tg msg send [text...]` | Send text. Repeat `--file ` to attach one or more files; text becomes the first media caption. Use `--name` to override upload filenames. `--sticker ` / `--gif ` send a sticker/gif — either a `msg sticker list`/`msg gif list` ref or a `` of an existing one (no text/`--file`). | | `tg msg sticker list` | List your stickers to get a sendable `ref`. `--recent` (default), `--faved`, `--installed` (sets), `--all` (recent+faved+all sets expanded; slow). | | `tg msg sticker fave ` / `tg msg sticker unfave ` | Add or remove a sticker from favorites (`` is a list ref or ``). | +| `tg msg gif list` | List your saved GIFs, each with a sendable `ref`. | | `tg msg poll