https://github.com/dacrol/telegraf-anycase-commands
Makes Telegraf bot commands case insensitive
https://github.com/dacrol/telegraf-anycase-commands
javascript middleware telegraf telegram telegram-bot
Last synced: 20 days ago
JSON representation
Makes Telegraf bot commands case insensitive
- Host: GitHub
- URL: https://github.com/dacrol/telegraf-anycase-commands
- Owner: Dacrol
- License: mit
- Created: 2018-01-06T22:44:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-08T15:17:45.000Z (over 8 years ago)
- Last Synced: 2024-04-26T14:45:51.490Z (about 2 years ago)
- Topics: javascript, middleware, telegraf, telegram, telegram-bot
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/telegraf-anycase-commands
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Anycase commands for Telegraf
Makes [Telegraf](http://telegraf.js.org/) bot commands case insensitive. For example /Command will be recognized as the same as /command.
### [Installation](https://www.npmjs.com/package/telegraf-anycase-commands):
```
$ npm install telegraf-anycase-commands
or
$ yarn add telegraf-anycase-commands
```
### Usage:
```javascript
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:
```javascript
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.