npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

telegram_bot_network

v1.0.10

Published

powerful Node.js package designed for bot network administration. It provides seamless integration between multiple bots, enabling advanced features like multi-posting and centralized user management. Built with scalability in mind, it leverages RabbitMQ

Readme

Telegram Bot Functionality

This README provides an overview of the functionality implemented in the Telegram bot. The bot is designed to manage users, broadcast messages, and provide admin-specific commands for monitoring user data.


Features

1. Middleware for Updating Users

A middleware is implemented to automatically update or create user records in the database during interactions with the bot.

  • Key Features:
    • Updates or creates user information such as telegramId, username, firstName, lastName, isActive, and lastInteraction.
    • Ensures that the lastInteraction field is updated with the current timestamp to track user activity.
    • Uses MongoDB's findOneAndUpdate method with the upsert: true option to handle both updates and new user creation.

2. RabbitMQ Integration for Broadcasting Messages

The bot integrates with RabbitMQ to consume messages from a queue and broadcast them to all registered users.

  • Key Features:
    • Listens for messages with the action "broadcast".
    • Retrieves all active users from the database and sends the broadcast message to each user's telegramId using the Telegram Bot API.
    • Logs a message if no users are found in the database.

3. Admin Commands

/users

This command allows the bot administrator to retrieve statistics about the total number of users and the number of new users registered today.

  • Key Features:
    • Accessible only by the admin (verified via ADMIN_ID).
    • Provides:
      • Total number of users in the database.
      • Number of new users registered since the start of the current day.
    • Sends the results as a formatted message to the admin.

/get_users

This command allows the bot administrator to retrieve a detailed list of all registered users.

  • Key Features:
    • Accessible only by the admin (verified via ADMIN_ID).
    • Retrieves all users from the database and formats their details into a readable list.
    • Each user entry includes their name (or username if the name is unavailable) and their chat_id (telegramId).
    • If no users are found, it informs the admin that there are no registered users.

4. Error Handling

The bot includes robust error handling to ensure smooth operation:

  • Logs errors for debugging purposes.
  • Sends appropriate error messages to the admin in case of failures (e.g., database errors, message sending errors).

Usage

Prerequisites

  • Node.js installed on your machine.
  • MongoDB database for storing user information.
  • RabbitMQ server for message broadcasting.

Installation

Install the package via npm:

npm install telegram_bot_network

Quick Start

  1. Set up RabbitMQ: Ensure RabbitMQ is running and configure the connection settings.
  2. Configure MongoDB: Connect to your MongoDB instance to store user data.
  3. Initialize the Package:
const { Telegraf } = require("telegraf");
const { initBot } = require("telegram_bot_network");

const bot = new Telegraf(process.env.BOT_TOKEN);

initBot({
  bot,
  admin_id: /* Telegram admin id */,
  mongodb_uri: /* mongodb_uri */,
  rabbitmq_queue: "bot-events" /* can use custom */,
});

bot.launch();

Contributing

Contributions are welcome! Please read the contribution guidelines before submitting a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.