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

@manihateu/nestjs-maximus

v1.0.2

Published

NestJS adapter for MAX messenger bot API

Readme

nestjs-maximus

NestJS adapter for MAX messenger bot API — полный аналог nestjs-telegraf: декораторы @Update(), @Start(), @Help(), @On(), @Hears(), @Context(), инжект бота через @InjectBot().

Установка

npm install @manihateu/nestjs-maximus @maxhub/max-bot-api

Быстрый старт (декораторы, как в nestjs-telegraf)

1. Модуль и обработчик

app.module.ts

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { MaximusModule } from 'nestjs-maximus';
import { MaximusUpdate } from './maximus.update';

@Module({
  imports: [
    ConfigModule,
    MaximusModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        token: config.getOrThrow<string>('MAX_BOT_TOKEN'),
        commands: [
          { name: 'start', description: 'Запуск' },
          { name: 'help', description: 'Помощь' },
        ],
        include: [MaximusUpdate], // классы с @Update()
      }),
    }),
  ],
  providers: [MaximusUpdate],
})
export class AppModule {}

maximus.update.ts

import { Injectable } from '@nestjs/common';
import {
  Update,
  Start,
  Help,
  On,
  Hears,
  Context,
  InjectBot,
  Keyboard,
  type MaximusContext,
} from 'nestjs-maximus';
import type { Bot } from '@maxhub/max-bot-api';

@Update()
@Injectable()
export class MaximusUpdate {
  constructor(@InjectBot() private readonly bot: Bot) {}

  @Start()
  async onStart(@Context() ctx: MaximusContext) {
    await ctx.reply('Привет! Напиши что-нибудь.', {
      keyboard: Keyboard.inlineKeyboard([
        [Keyboard.button.callback('Кнопка', 'btn_1')],
      ]),
    });
  }

  @Help()
  async onHelp(@Context() ctx: MaximusContext) {
    await ctx.reply('Команды: /start, /help');
  }

  @On('message_created')
  async onMessage(@Context() ctx: MaximusContext) {
    await ctx.reply(`Ты написал: ${ctx.text ?? '(пусто)'}`);
  }

  @On('message_callback')
  async onCallback(@Context() ctx: MaximusContext) {
    await ctx.reply(`Нажата кнопка: ${ctx.callbackPayload}`);
  }

  @Hears(/привет/i)
  async onHears(@Context() ctx: MaximusContext) {
    await ctx.reply('И тебе привет!');
  }
}

2. Переменные окружения

MAX_BOT_TOKEN=ваш_токен_от_Master_Bot

Токен: Master Bot.


API (как в nestjs-telegraf)

Декораторы

| Декоратор | Описание | |-----------|----------| | @Update() | Класс-обработчик апдейтов (аналог @Controller()) | | @Start() | Команда /start и событие bot_started | | @Help() | Команда /help | | @On(event) | Событие: 'bot_started', 'message_created', 'message_callback' | | @Hears(trigger) | Текст или RegExp по сообщению | | @Context() | Внедрить MaximusContext в параметр метода | | @Message() | Внедрить текст сообщения (или свойство) | | @InjectBot(name?) | Внедрить экземпляр Bot из @maxhub/max-bot-api |

MaximusModule

  • forRoot(options) / forRootAsync(options)
    • token: string — токен бота
    • commands?: Array<{ name, description }>
    • include: Function[] — классы с @Update() (обязательно для декораторов)

MaximusContext

  • userId, chatId, text?, callbackPayload?, raw
  • reply(message, options?) — ответ в чат (options.format, options.keyboard)

Альтернатива: IMaximusUpdateHandler

Можно не использовать декораторы, а реализовать интерфейс IMaximusUpdateHandler (метод handle(ctx: MaximusContext): Promise<void>) и зарегистрировать провайдер с токеном MAXIMUS_UPDATE_HANDLER

Keyboard

Реэкспорт из @maxhub/max-bot-api:

import { Keyboard } from 'nestjs-maximus';
Keyboard.inlineKeyboard([[Keyboard.button.callback('Текст', 'payload')]]);

Лицензия

MIT