JSPM

max2tg

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 241
  • Score
    100M100P100Q55044F
  • License MIT

MAX to Telegram event style converter

Package Exports

  • max2tg
  • max2tg/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (max2tg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

max2tg

Конвертер событий (updates) мессенджера MAX в события Telegram Bot API.


Установка

npm install max2tg

Быстрый старт

const { convertMaxToTelegram, convertBatch } = require('max2tg');

// Одно событие → массив Telegram updates
const updates = convertMaxToTelegram(maxUpdate);

// Массив событий → плоский массив Telegram updates
const updates = convertBatch(maxUpdates);

Пример в webhook-обработчике

const express = require('express');
const { convertMaxToTelegram } = require('max2tg');

const app = express();
app.use(express.json());

// Webhook от MAX
app.post('/webhook/max', (req, res) => {
  const tgUpdates = convertMaxToTelegram(req.body);

  for (const update of tgUpdates) {
    handleTelegramUpdate(update); // ваш общий обработчик
  }

  res.sendStatus(200);
});

// Webhook от Telegram
app.post('/webhook/telegram', (req, res) => {
  handleTelegramUpdate(req.body);
  res.sendStatus(200);
});

Поддерживаемые типы событий

bot_startedmessage с командой /start

Активация бота пользователем, в том числе с start payload.

message_createdmessage

Поддержка всех видов вложений, включая геопозицию, документы, стикеры и альбомы. Ответы на сообщение, пересланные сообщения, сообщения с клавиатурой и форматированием.

message_callbackcallback_query

Нажатие пользователя на инлайн-кнопку.


Ограничения

Поле file_id всегда равен null, на замену приходит _max_url и _max_token.


Лицензия

MIT