diff --git a/config.example.json b/config.example.json index f625d58..cadd000 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,7 @@ { "master": 123456789, // master admin ID as a number or username as astring. "token": "", // bot token. + "plugins": [], // list of plugin names to be loaded "numberOfWarnsToBan": 3, // Number of warns that will get someone banned. "groupsInlineKeyboard": [], // [[inlineButton]] -> inline keyboard to be added to reply to /groups "excludedChannels": [], // [String] -> list of channels usernames to be excluded from warnings, use "*" to disable this feature. diff --git a/index.js b/index.js index c32176b..816a48e 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ bot.telegram.getMe().then((botInfo) => { bot.use( require('./handlers/middlewares'), require('./handlers/messages'), + require('./plugins'), require('./handlers/commands'), ); diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 0000000..24cdbf7 --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything... +* +# except this file and index +!.gitignore +!index.js diff --git a/plugins/index.js b/plugins/index.js new file mode 100644 index 0000000..623be72 --- /dev/null +++ b/plugins/index.js @@ -0,0 +1,10 @@ +'use strict'; + +const { compose } = require('telegraf'); + +const config = require('../config.json'); +const names = config.plugins || []; + +const plugins = names.map(name => `./${name}`).map(require); + +module.exports = compose(plugins);