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

@mirta/chatbot

v0.5.0

Published

Chat-based control for your automation scripts

Readme

@mirta/chatbot — Telegram-бот для Wiren Board

en ru NPM Version NPM Downloads

Управляйте вашим контроллером через Telegram — безопасно, просто, без лишнего кода.

Этот модуль позволяет:

  • Принимать команды из чата: включить свет, открыть ворота и т.д.
  • Отправлять уведомления: "Температура упала ниже 18°C"
  • Ограничивать доступ: только администраторы или участники группы
  • Использовать кнопки, меню, колбэки.

Работает внутри проектов на основе Mirta — фреймворка для автоматизаций на базе контроллеров Wiren Board.

💡 Этот пакет — дополнение экосистемы Mirta.
Он подключается к вашему проекту и работает вместе с ним.

📦 Установка

Если вы ещё не используете Mirta — начните с создания проекта.

Затем добавьте функционал бота одной командой:

pnpm add @mirta/chatbot

🛠️ Быстрый старт

  1. Создайте Telegram-бота через @BotFather → получите токен
  2. Добавьте токен в .env.local вашего проекта
# Токен доступа бота
APP_TELEGRAM_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
# Ваш ID в Telegram
APP_TELEGRAM_USER=123456789
  1. Настройте бота в модуле
// src/wb-rules-modules/bot-telegram.ts
import { defineTelegramBot, defineAuthorization } from '@mirta/chatbot'

const auth = defineAuthorization(a => a
  .addPolicy('admin', p => p
    .allow(r => r.userId(process.env.APP_TELEGRAM_USER))
  )
)

export const useTelegramBot = defineTelegramBot(auth, {
  deviceName: 'telegram',
  deviceTitle: 'Telegram Bot',
  token: process.env.APP_TELEGRAM_TOKEN,
  commands: {
    start: { policy: 'admin' }
  }
})
  1. Используйте бота в скриптах
// src/wb-rules/bot-usage.ts
import { useTelegramBot } from '#wbm/bot-telegram'

const bot = useTelegramBot()

bot.onCommand('start', (_, reply) => {
  reply('Привет! Добро пожаловать в систему.')
})
  1. Соберите и задеплойте проект — бот начнёт работать.

🔐 Политики доступа

Определите, кто может выполнять команды:

const auth = defineAuthorization(a => a
  .addPolicy('admin', p => p
    // Доступ для указанного пользователя
    .allow(r => r.userId('1234567890'))
    // Если он обращается из указанного чата
    .allow(r => r.chatId('9876543210'))
  )
  .addPolicy('subscriber', p => p
    .allow(r => r
      // Доступ для всех пользователей указанного чата
      .chatId('1009876543210')
      // Если это супергруппа
      .chatType('supergroup')
    )
  )
)

Правила:

  • allow — разрешить доступ
  • deny — запретить (имеет приоритет)

Особенности:

  • Несколько allow в одной политике работают по принципу «ИЛИ».
  • Условия внутри одного allow — по принципу «И»

🧩 Что умеет бот

  • ✅ Любые команды вроде /start, /reboot
  • ✅ Колбэк-кнопки
  • ✅ Inline-клавиатуры
  • ✅ Отправка сообщений
  • ✅ Очереди (защита от флуда)
  • ⏳ Мессенджер Макс — в разработке (ограничения API)

📚 Где посмотреть пример?

Полный рабочий пример — в репозитории:
👉 projects/chatbot-demo

Там вы найдёте:

  • Готовый модуль бота
  • Скрипт с командами
  • Образец конфигурации .env (в своих проектах используйте .env.local)

❤️ Благодарности

Спасибо, что используете Мирту!
Вместе мы делаем автоматизации проще — для всех.