-
Notifications
You must be signed in to change notification settings - Fork 269
/
permissions.js
32 lines (28 loc) · 981 Bytes
/
permissions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module.exports = {
id: 'permissions',
defaultConfig: {
allowedUserIds: [],
allowedChannels: [],
message: '⛔ you are not authorized'
},
plugin(bot, pluginConfig) {
bot.mod('message', (data) => {
if (data.message.chat) {
if (data.message.chat.type === 'channel') {
const chatId = data.message.chat.id;
if (!pluginConfig.allowedChannels.includes(chatId)) {
data.message = {};
bot.sendMessage(chatId, pluginConfig.message);
}
} else {
const userId = data.message.from.id;
if (!pluginConfig.allowedUserIds.includes(userId)) {
data.message = {};
bot.sendMessage(userId, pluginConfig.message);
}
}
}
return data;
});
}
};