telebot icon indicating copy to clipboard operation
telebot copied to clipboard

permissions authorization plugin

Open Shemesh opened this issue 8 years ago • 0 comments

i have written a permissions (authorization) plugin, can you plz add it to the next release:

module.exports = {

id: 'permissions',
defaultConfig: {
    allowedUserNames: [],
    message: '⛔ you are not authorized'
},

plugin(bot, pluginConfig) {

    bot.mod('message', (data) => {
        const userId = data.message.from.id;
        if (pluginConfig.allowedUserNames.indexOf(data.message.from.username) < 0) {
            data.message = {};
            bot.sendMessage(userId, pluginConfig.message);
        }

        return data;
    });

}
};

Shemesh avatar Mar 06 '18 22:03 Shemesh