1.1.0 • Published 6 years ago

telegraf-anycase-commands v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Anycase commands for Telegraf

Makes Telegraf bot commands case insensitive. For example /Command will be recognized as the same as /command.

Installation:

$ npm install telegraf-anycase-commands
or
$ yarn add telegraf-anycase-commands

Usage:

const AnyCase = require('telegraf-anycase-commands')

const bot = new Telegraf(process.env.BOT_TOKEN)
// Or:
const bot = new Composer()

// Then:
AnyCase.apply(bot)

// Or simply:
const bot = AnyCase.apply(new Telegraf(process.env.BOT_TOKEN))
// Or:
const bot = AnyCase.apply(new Composer())

Or if you only want to use the middleware for commands in incoming messages, without applying it on commands in your code:

bot.use(AnyCase.lowercase())

Note that this will only convert incoming commands to lowercase, and commands have to be defined in lowercase in the code to match.