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

rubigraf

v1.3.0

Published

A Powerful and Modern Rubika Bot Framework

Readme


✨ Overview

Rubigraf is designed to simplify Rubika bot development using a clean, event-driven, and type-safe structure inspired by Telegraf.

📘 Full Documentation → (coming soon)

🚀 Installation

npm install rubigraf
# or
yarn add rubigraf
# or
pnpm add rubigraf

🧩 Example Usage

Below are a few examples demonstrating Rubigraf's event-based structure.

  • NewMessage Event Example:
const { Rubigraf, RubigrafEvents } = require("rubigraf");

const bot = new Rubigraf(process.env.BOT_TOKEN, { polling: true });

bot.launch();

bot.on(RubigrafEvents.NewMessage, async (ctx, payload, next) => {
  await ctx.reply("Hello! 👋 This is a Rubigraf bot.");

  return next();
});
  • Command Event Example with Event Hooks:
const { Rubigraf, RubigrafEvents } = require("rubigraf");

const bot = new Rubigraf(process.env.BOT_TOKEN, { polling: true });

bot.launch();

// onBefore: inspect the ctx and attach shared data to payload
// If user not registered, set payload.registered = false so main handler & after hook see it.
bot.onBefore(RubigrafEvents.Command, async (ctx, payload, next) => {
  const userId = ctx.senderId;

  // lightweight DB check (example)
  const isRegistered = await db.users.exists(userId);
  payload.registered = isRegistered; // shared with later hooks
  payload.userId = userId;

  // allow main handler to continue
  return next();
});

// main handler: do work and augment payload if needed
bot.on(RubigrafEvents.Command, async (ctx, payload, next) => {
  const { command } = ctx;

  if (command === "start") {
    if (!payload.registered) {
      // register user and record result for after-hook
      await db.users.create(payload.userId);
      payload.registered = true;
      payload.justRegistered = true;
    }
  }

  // continue to after hook
  return next();
});

// onAfter: run follow-up tasks using the same payload object
bot.onAfter(RubigrafEvents.Command, async (ctx, payload) => {
  // payload.registered / payload.justRegistered are available here
  if (ctx.command === "start" && payload.justRegistered) {
    await ctx.reply("Welcome to Rubigraf!");
  } else if (ctx.command === "start") {
    await ctx.reply("Welcome back!");
  }

  // you can also use payload for telemetry/logging
  globalMetrics.increment("commands_handled", { cmd: ctx.command, registered: !!payload.registered });
});

// You can also get Rubigraf errors from version 1.2.8 onwards
bot.on(RubigrafEvents.Error, (err, logger) => logger.error(err));

🧩 TypeScript Usage

Rubigraf includes full type definitions, so you can use it seamlessly with TypeScript.

📦 Features

  • ⚡ Fast and modular event system
  • 💬 Supports messages, files, stickers, polls, and more
  • 🧠 Middleware-based architecture
  • 🧱 TypeScript support out of the box
  • 🔁 Command and context handling similar to Telegraf
  • 🧍 User-friendly API design

🧠 Concepts

Rubigraf provides contexts to interact with updates. Each context gives you access to specific update data and helper methods such as ctx.reply(), ctx.forwardMessage(), and ctx.editMessageText().

Example:

bot.on(RubigrafEvents.Command, async (ctx) => {
  if (ctx.command === "start") {
    await ctx.reply("Welcome to Rubigraf!");
  }
});

📜 License

Rubigraf is licensed under the MIT License.

💬 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.