mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 06:35:23 +00:00
Don't assume config file extension
Even if we want to enforce one extension, doing it in requires scattered across the whole project doesn't sound like a good idea (don't repeat yourself). This commit also enables .js configs, so I added that to .gitignore. I'll document it when we settle on default config format. Why was .json everywhere in the first place? I thought it was neccessary in some older versions of Node to be able to require a .json file.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
data/
|
data/
|
||||||
config.json
|
config.json
|
||||||
|
config.js
|
||||||
.env
|
.env
|
||||||
.idea/
|
.idea/
|
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Telegraf = require('telegraf');
|
const Telegraf = require('telegraf');
|
||||||
const config = require('../config.json');
|
const config = require('../config');
|
||||||
|
|
||||||
const bot = new Telegraf(config.token);
|
const bot = new Telegraf(config.token);
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ const { escapeHtml, scheduleDeletion } = require('../../utils/tg');
|
|||||||
// DB
|
// DB
|
||||||
const { listGroups } = require('../../stores/group');
|
const { listGroups } = require('../../stores/group');
|
||||||
|
|
||||||
const config = require('../../config.json');
|
const config = require('../../config');
|
||||||
|
|
||||||
const inline_keyboard = config.groupsInlineKeyboard;
|
const inline_keyboard = config.groupsInlineKeyboard;
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ const addCommandHandler = require('./addCommand');
|
|||||||
const removeCommandHandler = require('./removeCommand');
|
const removeCommandHandler = require('./removeCommand');
|
||||||
const helpHandler = require('./help');
|
const helpHandler = require('./help');
|
||||||
|
|
||||||
let { deleteCommands } = require('../../config.json');
|
let { deleteCommands } = require('../../config');
|
||||||
|
|
||||||
if (typeof deleteCommands === 'undefined') {
|
if (typeof deleteCommands === 'undefined') {
|
||||||
deleteCommands = 'own';
|
deleteCommands = 'own';
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
const { link, scheduleDeletion } = require('../../utils/tg');
|
const { link, scheduleDeletion } = require('../../utils/tg');
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
const { numberOfWarnsToBan } = require('../../config.json');
|
const { numberOfWarnsToBan } = require('../../config');
|
||||||
|
|
||||||
// Bot
|
// Bot
|
||||||
const { replyOptions } = require('../../bot/options');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
@@ -8,7 +8,7 @@ const { logError } = require('../../utils/log');
|
|||||||
const {
|
const {
|
||||||
numberOfWarnsToBan,
|
numberOfWarnsToBan,
|
||||||
warnInlineKeyboard,
|
warnInlineKeyboard,
|
||||||
} = require('../../config.json');
|
} = require('../../config');
|
||||||
const reply_markup = { inline_keyboard: warnInlineKeyboard };
|
const reply_markup = { inline_keyboard: warnInlineKeyboard };
|
||||||
|
|
||||||
// Bot
|
// Bot
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
const { master } = require('../../config.json');
|
const { master } = require('../../config');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const { addUser, isUser } = require('../../stores/user');
|
const { addUser, isUser } = require('../../stores/user');
|
||||||
|
@@ -9,7 +9,7 @@ const {
|
|||||||
excludeLinks,
|
excludeLinks,
|
||||||
numberOfWarnsToBan,
|
numberOfWarnsToBan,
|
||||||
warnInlineKeyboard,
|
warnInlineKeyboard,
|
||||||
} = require('../../config.json');
|
} = require('../../config');
|
||||||
const reply_markup = { inline_keyboard: warnInlineKeyboard };
|
const reply_markup = { inline_keyboard: warnInlineKeyboard };
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ const { replyOptions } = require('../../bot/options');
|
|||||||
|
|
||||||
const { admin } = require('../../stores/user');
|
const { admin } = require('../../stores/user');
|
||||||
const { addGroup, managesGroup } = require('../../stores/group');
|
const { addGroup, managesGroup } = require('../../stores/group');
|
||||||
const { master } = require('../../config.json');
|
const { master } = require('../../config');
|
||||||
|
|
||||||
const addedToGroupHandler = async (ctx, next) => {
|
const addedToGroupHandler = async (ctx, next) => {
|
||||||
const msg = ctx.message;
|
const msg = ctx.message;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { deleteCommands } = require('../../config.json');
|
const { deleteCommands } = require('../../config');
|
||||||
|
|
||||||
const noop = Function.prototype;
|
const noop = Function.prototype;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const { compose } = require('telegraf');
|
const { compose } = require('telegraf');
|
||||||
|
|
||||||
const config = require('../config.json');
|
const config = require('../config');
|
||||||
const names = config.plugins || [];
|
const names = config.plugins || [];
|
||||||
|
|
||||||
const plugins = names.map(name => `./${name}`).map(require);
|
const plugins = names.map(name => `./${name}`).map(require);
|
||||||
|
Reference in New Issue
Block a user