Simple authentication middleware for https://github.com/idchlife/node-telegram-bot-api-middleware
So, what's the case for this middleware?
Imagine, that you have telegram bot. And you want it to become bot for you company, your friends and also somebody else.
So... You have some private data and just answering to commands for you is not enough. You want some kind of 'registration' of users in your system.
So, with this middleware you will get it! Beware, this is called SIMPLEauth
for a reason. It uses sqlite3 and limited functionality.
As you know (if not yet, visit mentioned above repository node-telegram-bot-api-middleware), middleware is used to extend context of your next processed function callback for message/another middleware. This one does extend your list of middlewares with useful methods, properties for authentication and registration.
Installation
npm i node-telegram-bot-api-middleware-simpleauth --save
Usage
// By default, simpleauth will create `simpleauth.sqlite3` file in your folder, // for purpose of saving your authentication data. If you want to reset it, // just delete the file. You can also define your own filename. If you don't // want custom file, just omit passing arguments to .createMiddleware() const simpleauth = ; const use = ; // When you use this middleware, your context will be populated with // object simpleauth. So you can use it via this.simpleauth const response = ; // Your configured bot const bot = ; bot
Check example, it will show middleware in action
For working example you can see examples/working-auth-bot.js To test it you need to start it like this:
node examples/working-auth-bot.js YOUR_BOT_TOKEN
You can help with code, ideas and bugs by creating issues and pull requests.
Yes, this middleware may have some bugs and unexpected behaviour and you can help me to improve it!