Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@gramio/broadcast

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gramio/broadcast

Broadcast for GramIO

latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

@gramio/broadcast

npm npm downloads JSR JSR Score

Simple wrapper for jobify (BullMQ) to make broadcast easier. Automatically handles rate limits and ignore user blocks. Provide simple API for pre-defined broadcasts.

This implementation is ready for production use because, thanks to Redis, it won't lose planned users during reloads and will send notifications to all of them.

import { Bot, InlineKeyboard } from "gramio";
import Redis from "ioredis";
import { initJobify } from "jobify";
import { Broadcast } from "@gramio/broadcast";

const redis = new Redis({
    maxRetriesPerRequest: null,
});

const bot = new Bot(process.env.BOT_TOKEN as string);

const broadcast = new Broadcast(redis).type("test", (chatId: number) =>
    bot.api.sendMessage({
        chat_id: chatId,
        text: "test",
    })
);

console.log("prepared to start");

const chatIds = [617580375];

await broadcast.start(
    "test",
    chatIds.map((x) => [x])
);

// graceful shutdown
async function gracefulShutdown() {
    console.log(`Process ${process.pid} go to sleep`);

    await broadcast.job.queue.close();

    console.log("closed");
    process.exit(0);
}

process.on("SIGTERM", gracefulShutdown);

process.on("SIGINT", gracefulShutdown);

Keywords

gramio

FAQs

Package last updated on 25 Apr 2025

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