Skip to content

h1b9b/telegraf-cmd-args

Repository files navigation

telegraf-cmd-args

This is a plugin for the Telegraf Telegram Bot Framework.

It provides a middleware that splits a command in a Telegram text message.
The parsed command is stored in ctx.state.command.

For example, if your text message is /start Hello world!, the ctx.state.command will be set to:

{
  "text": "/start Hello world!",
  "command": "start",
  "args": "Hello world!",
  "splitArgs": ["Hello", "world!"],
}

installation

npm install telegraf-cmd-args

Usage

const { Telegraf } = require('telegraf');
const commandMiddleware = require('telegraf-cmd-args');

app.use(commandMiddleware);

About

Middleware to parse Telegraf commands

Resources

License

Stars

Watchers

Forks

Packages

No packages published