Socket
Socket
Sign inDemoInstall

@grammyjs/files

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grammyjs/files

Files plugin for grammY


Version published
Weekly downloads
686
increased by5.21%
Maintainers
1
Weekly downloads
 
Created
Source

File handling simplified in grammY

This plugin allows you to easily download files from Telegram servers. Check out the official plugin page for further documentation.

Example

import { Bot, type Context } from "grammy";
import { type FileFlavor, hydrateFiles } from "@grammyjs/files";

// Transformative API flavor
type MyContext = FileFlavor<Context>;

// Create bot
const bot = new Bot<MyContext>("");

// Install plugin
bot.api.config.use(hydrateFiles(bot.token));

// Download videos and GIFs to temporary files
bot.on([":video", ":animation"], async (ctx) => {
    // Prepare file for download
    const file = await ctx.getFile();
    // Download file to temporary location on your disk
    const path = await file.download();
    // Print file path
    console.log("File saved at", path);
});

You can pass a string with a file path to download if you don't want to create a temporary file. Just do await file.download('/path/to/file').

Keywords

FAQs

Package last updated on 05 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc