
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
grammy-media-group
Advanced tools
Middleware and utilities for handling and grouping media messages (photos, videos) in grammY bots, enabling easy processing of media groups.
A lightweight middleware for grammY Telegram bots that collects and groups media messages (like photos and videos) into a single media_group
context property. This makes it easier to handle albums using a simple timeout-based strategy.
mediaGroup
filter for a clean handler with bot.filter()
copyMediaGroup
function to copy media groupsnpm install grammy-media-group
import { Bot } from "grammy";
import { MediaGroupHandler, mediaGroup } from "grammy-media-group";
const bot = new Bot("<BOT_TOKEN>");
const mediaGroupHandler = new MediaGroupHandler(4000); // optional timeout in ms
bot.use(mediaGroupHandler.middleware());
const { Bot } = require("grammy");
const { MediaGroupHandler, mediaGroup } = require("grammy-media-group");
const bot = new Bot("<BOT_TOKEN>");
const mediaGroupHandler = new MediaGroupHandler(4000); // optional timeout in ms
bot.use(mediaGroupHandler.middleware());
This example shows how to use the mediaGroup
filter to detect incoming media groups. When a media group is detected, the handler/middleware processes the grouped media files.
bot.filter(mediaGroup, async (ctx) => {
const media = ctx.media_group;
console.log(media.length); // outputs the media group (album) length
// handle the media group...
});
You can use the copyMediaGroup
utility function to copy a received media group, or copy it directly from the context into a format ready to be sent. This is useful if you want to resend an album with a custom caption or formatting.
// Import if you don't want to copy it directly from the context
import { copyMediaGroup } from "grammy-media-group";
// Or require if you are using CommonJS
const { copyMediaGroup } = require("grammy-media-group");
bot.filter(mediaGroup, async (ctx) => {
// You can pass an optional options object to customize caption
// and formatting
const copiedMediaGroup = copyMediaGroup(ctx.media_group, {
caption: "<b>Here's the album!</b>",
parse_mode: "HTML"
});
// Or you can also copy the media group directly from the context
// and pass the optional options object there as well
const copiedMediaGroup = ctx.copyMediaGroup({
caption: "<b>Here's the album!</b>",
parse_mode: "HTML"
});
// Then you are ready to send the copied media group
await ctx.api.sendMediaGroup(ctx.chat.id, copiedMediaGroup);
});
FAQs
Middleware and utilities for handling and grouping media messages (photos, videos) in grammY bots, enabling easy processing of media groups.
The npm package grammy-media-group receives a total of 1 weekly downloads. As such, grammy-media-group popularity was classified as not popular.
We found that grammy-media-group demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.