Skip to content

Commit

Permalink
add permissions plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Shemesh authored Mar 15, 2018
1 parent ccd3217 commit 66b8c19
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions plugins/permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var startDate;

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;
});

bot.on('start', () => {
startDate = Date.now();
});

bot.mod('message', (data) => {
if (data.message.date*1000 < startDate) {
data.message = {};
}

return data;
});

}
};

0 comments on commit 66b8c19

Please sign in to comment.