2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +00:00

Added support for plugins

This commit is contained in:
GingerPlusPlus
2017-10-27 18:43:33 +02:00
parent f08de28edd
commit d98ba68cb7
4 changed files with 17 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
{ {
"master": 123456789, // master admin ID as a number or username as astring. "master": 123456789, // master admin ID as a number or username as astring.
"token": "", // bot token. "token": "", // bot token.
"plugins": [], // list of plugin names to be loaded
"numberOfWarnsToBan": 3, // Number of warns that will get someone banned. "numberOfWarnsToBan": 3, // Number of warns that will get someone banned.
"groupsInlineKeyboard": [], // [[inlineButton]] -> inline keyboard to be added to reply to /groups "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. "excludedChannels": [], // [String] -> list of channels usernames to be excluded from warnings, use "*" to disable this feature.

View File

@@ -16,6 +16,7 @@ bot.telegram.getMe().then((botInfo) => {
bot.use( bot.use(
require('./handlers/middlewares'), require('./handlers/middlewares'),
require('./handlers/messages'), require('./handlers/messages'),
require('./plugins'),
require('./handlers/commands'), require('./handlers/commands'),
); );

5
plugins/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
# Ignore everything...
*
# except this file and index
!.gitignore
!index.js

10
plugins/index.js Normal file
View File

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