Skip to content

gramiojs/media-cache

Repository files navigation

@gramio/media-cache

npm JSR JSR Score

Media cache plugin for GramIO.

This plugin caches the sent file_id's and prevents files from being uploaded again.

Currently, sendMediaGroup is not cached.

Usage

import { Bot } from "gramio";
import { mediaCache } from "@gramio/media-cache";

const bot = new Bot(process.env.token!)
    .extend(mediaCache())
    .command("start", async (context) => {
        return context.sendDocument(
            MediaUpload.url(
                "https://raw.githubusercontent.com/gramiojs/types/main/README.md"
            )
        );
    })
    .onStart(console.log);

bot.start();