feat(random): send /gachabeta clips as 360x640 portrait animations

Each gacha style now carries the frame size it renders, so Telegram receives the beta wish's portrait size while /gacha stays 640x360.
This commit is contained in:
tiennm99 committed 2026-10-01 18:45:08 +07:00
1 parent fc3c7ae0c0
commit 6f7fff5aab
3 files changed
+15 -9

No files matched your search

+2 -2
View File
@@ -94,8 +94,8 @@ animation and reply show. Options are 5★ by default; prefix `4*` or `3*` to
lower one, e.g. `/gacha Pizza, 4* Pho, 3* Rice`. lower one, e.g. `/gacha Pizza, 4* Pho, 3* Rice`.
The unlisted `/gachabeta` takes the same input and renders the beta version The unlisted `/gachabeta` takes the same input and renders the beta version
of the wish from `.../api/gachabeta` on the same service, with the same text of the wish from `.../api/gachabeta` on the same service as a `360x640`
fallback. portrait MP4, with the same text fallback.
## 1. MongoDB Atlas (M0) ## 1. MongoDB Atlas (M0)
+9 -5
View File
@@ -16,15 +16,19 @@ const (
) )
// gachaStyle is one wish animation the renderer serves: its path next to // gachaStyle is one wish animation the renderer serves: its path next to
// /api/gif and the clip length in seconds. // /api/gif, the clip length in seconds, and the frame size it renders for a
// gachaRemoteWidth request.
type gachaStyle struct { type gachaStyle struct {
Path string Path string
Duration int Duration int
Width int
Height int
} }
var ( var (
gachaStyleWish = gachaStyle{Path: "gacha", Duration: 7} gachaStyleWish = gachaStyle{Path: "gacha", Duration: 7, Width: gachaRemoteWidth, Height: gachaRemoteHeight}
gachaStyleBeta = gachaStyle{Path: "gachabeta", Duration: 6} // The beta wish is portrait: the requested width is its long edge.
gachaStyleBeta = gachaStyle{Path: "gachabeta", Duration: 6, Width: gachaRemoteHeight, Height: gachaRemoteWidth}
) )
type gachaAPIRequest struct { type gachaAPIRequest struct {
@@ -87,7 +91,7 @@ func renderGachaAnimation(ctx context.Context, style gachaStyle, label string, r
return wheelAnimation{ return wheelAnimation{
Data: data, Data: data,
Duration: style.Duration, Duration: style.Duration,
Width: gachaRemoteWidth, Width: style.Width,
Height: gachaRemoteHeight, Height: style.Height,
}, nil }, nil
} }
@@ -208,8 +208,10 @@ func TestGachaBeta_UsesBetaRendererAndAnyoneCanRunIt(t *testing.T) {
if animation == nil { if animation == nil {
t.Fatalf("calls = %+v, want a sendAnimation", rb.Sent()) t.Fatalf("calls = %+v, want a sendAnimation", rb.Sent())
} }
if got := animation.Form["duration"]; got != "6" { for field, want := range map[string]string{"duration": "6", "width": "360", "height": "640"} {
t.Fatalf("duration = %q, want 6", got) if got := animation.Form[field]; got != want {
t.Fatalf("%s = %q, want %s", field, got, want)
}
} }
} }