2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-01 14:45:27 +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:
GingerPlusPlus
2017-11-24 12:31:47 +01:00
parent 19f0a109f8
commit 5a4002e7d4
11 changed files with 12 additions and 11 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
node_modules node_modules
data/ data/
config.json config.json
config.js
.env .env
.idea/ .idea/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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