Home / Docs / API Reference
On this page

API Reference

Constructor

JavaScript
new Zerogram(apiId, apiHash, botToken, options)
Param Tipo Descripcion
apiId number Tu API ID de Telegram
apiHash string Tu API Hash
botToken string Token del bot de @BotFather
options object Opciones adicionales

Opciones

Option Tipo Default Descripcion
debug boolean false Activar logs de debug
sessionsDir string './sessions' Directorio para sesiones
maxRetries number 3 Reintentos de conexion
retryDelay number 2000 Delay entre reintentos (ms)

Metodos del Bot

bot.init()

Inicializa la conexion con Telegram.

JavaScript
await bot.init();

bot.command(name, handler)

Registra un comando.

bot.onCallback(action, handler)

Registra un callback para botones inline.

bot.use(middleware)

Registra un middleware.

bot.stop()

Detiene el bot de forma segura.

bot.on(event, handler)

Registra un evento.

Eventos disponibles
ready, error, unhandled, stopped