Skip to content

feat(msg): msg gif — list and send saved GIFs#24

Merged
cuiko merged 1 commit into
vika2603:mainfrom
cuiko:feat/msg-gif
Jun 3, 2026
Merged

feat(msg): msg gif — list and send saved GIFs#24
cuiko merged 1 commit into
vika2603:mainfrom
cuiko:feat/msg-gif

Conversation

@cuiko

@cuiko cuiko commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

tg msg gif adds GIF support, mirroring msg sticker.

  • msg gif list — lists saved GIFs (messages.getSavedGifs), each row carrying a self-contained gif_ ref handle (id + access_hash + file_reference).
  • msg send --gif <ref> — sends a GIF by a msg gif list ref or by a <msg-ref> of an existing gif. Mutually exclusive with text, --file, and --sticker. On an expired ref it refreshes from the saved-gifs list and retries once. Stays on the local send path (media isn't daemon-routed).
  • The ref-token codec is shared with stickers via distinct prefixes (stk_ / gif_), so a gif ref can't be mistaken for a sticker ref.

Incidental fix

Document media-kind detection now prefers Animated over Video. A Telegram gif is an mp4 carrying both attributes; the previous return-on-first-attribute logic could read it as video depending on attribute order. Now msg list/msg info report it as gif.

Test plan

  • gofmt -l ., go build ./..., go vet ./..., go test ./... green
  • golangci-lint run (default + GOOS=linux) — 0 issues
  • Unit tests: gif token round-trip; gif vs sticker tokens don't cross-decode; --gif resolves a ref/msg-ref; rejects text/--file/--sticker.
  • Real-env (a test account, Saved Messages): msg gif list (2 saved gifs); send --gif <ref> lands as type: gif with duration/dimensions/file_name; a non-gif <msg-ref> → usage error. Test message deleted.

`tg msg gif list` lists saved GIFs (messages.getSavedGifs), each with a
self-contained `gif_` ref handle. `msg send --gif <ref>` sends a gif by
that handle or by a <msg-ref> 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.
@cuiko
cuiko merged commit ec0df05 into vika2603:main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant