Skip to Content
Nextra 2 Alpha

Media

A buy post carries either one fixed picture or a fresh pick from a linked gallery site on every buy. The imageMode field ("fixed" / "random") decides which.

The two imageMode values

SettingValue
fixed (default)Every buy carries the same imageUrl / mediaType.
randomEvery buy carries a fresh picture pulled from the bot’s linked gallery site(s).

Set from the dashboard’s Layout settings (buttons Fixed image / Random gallery image — a draft-state change, applied on the next Save & Push, like every other layout field) or from an admin-only gallery-site panel (buttons fixed image / random image, same field, written immediately on click). Every in-chat media write that follows a confirmed switch also sets it — see Which paths can drop random mode, below.

A gallery is linked to the bot when one of its characters’ loraName points at a deployed gallery site (/var/www/<slug>.memescale.ai). Its images are whatever that site lists — the site’s images directory walked recursively, 4 levels deep, dot-entries skipped, extensions .jpg .jpeg .png .gif .webp .avif. A bot with more than one linked gallery draws from all of them. A generation that lands in a linked site’s collection becomes eligible the moment the pool next refills.

Note

No gallery linked while random mode is on: the settings card reads Buy media: random gallery image is on, but no gallery site is linked to this bot — the fixed <image/GIF/video> is used, or ends — posts go without media instead, when there’s no fixed media either. Buys still post; they fall back to the fixed slot.

The ready pool

Telegram can’t take AVIF, and every gallery collection is AVIF, so pictures are converted to JPEG ahead of time — never on the buy’s own critical path. Each bot keeps a pool of already-converted JPEGs at <bot dir>/buybot-gallery/ready/.

Pool parameters

SettingValue
Target size16 ready files
Refill triggerA background refill starts whenever the pool drops below 8
JPEG quality95
Ready-file TTL3600 seconds (1 hour) — an older file is discarded unsent, so a quiet bot still picks up new generations within the hour
Gallery walk depth4 directory levels

A buy takes one file by moving it out of ready/ into sending/ — a rename, so two buys can never end up with the same picture — and the file is deleted once it has been sent to every target group.

An empty pool on a buy (a burst that outran the refill) converts one image inline instead, so the buy still ships with a gallery picture. If that also fails, the buy falls back to the fixed image, or to text alone — a buy is never dropped for a media failure.

The pool is deleted whole the moment the mode goes off. Owner-facing previews (the settings card, the wizard cards, View Layout) draw from the same ready pool when the mode is live; when the bot is off or has no gallery wired yet, one image is converted on the spot into a separate preview/ folder instead, so a preview still shows what the mode will post.

Which paths can drop random mode

A media write that replaces imageUrl / mediaType while imageMode is "random" is treated as switching the bot back to fixed media. services/buyBot.ts enforces this server-side: such a patch is refused with HTTP 409 and Random gallery image mode is on for this bot — confirm switching to a fixed image first. unless the same patch also sets imageMode to "fixed".

Every in-chat media-write path — the post-fork wizard’s Edit Media, the settings card’s Buy Media, and /buybotimage whether attached to the command or sent as the next message, in a DM or a group — asks first and writes nothing until the owner confirms.

The dashboard’s own media upload does not ask

The dashboard’s media-upload control posts the file straight to /api/bots/buybot (multipart). That write path (saveBuyBotMedia) sets imageUrl, mediaType and, for mp4/webm, a generated posterUrl — and never reads or writes imageMode at all. Uploading new media from the dashboard while imageMode is "random" writes over the fixed-media fields immediately, with no confirmation shown, and leaves imageMode exactly as it was — the newly uploaded file becomes the fixed-media fallback without the bot ever leaving random mode. The upload takes effect immediately; it doesn’t wait for a separate Save & Push.

Dashboard upload limits

SettingValue
Acceptedjpg, jpeg, png, webp, gif, mp4, webm
jpg / jpeg / png / webp5 MB max
gif / mp4 / webm20 MB max
Silent mp4Stored as animation (Telegram loops it like a GIF); an mp4 with an audio track is stored as video.