2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +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
data/
config.json
config.js
.env
.idea/

View File

@@ -1,7 +1,7 @@
'use strict';
const Telegraf = require('telegraf');
const config = require('../config.json');
const config = require('../config');
const bot = new Telegraf(config.token);

View File

@@ -6,7 +6,7 @@ const { escapeHtml, scheduleDeletion } = require('../../utils/tg');
// DB
const { listGroups } = require('../../stores/group');
const config = require('../../config.json');
const config = require('../../config');
const inline_keyboard = config.groupsInlineKeyboard;

View File

@@ -22,7 +22,7 @@ const addCommandHandler = require('./addCommand');
const removeCommandHandler = require('./removeCommand');
const helpHandler = require('./help');
let { deleteCommands } = require('../../config.json');
let { deleteCommands } = require('../../config');
if (typeof deleteCommands === 'undefined') {
deleteCommands = 'own';

View File

@@ -4,7 +4,7 @@
const { link, scheduleDeletion } = require('../../utils/tg');
// Config
const { numberOfWarnsToBan } = require('../../config.json');
const { numberOfWarnsToBan } = require('../../config');
// Bot
const { replyOptions } = require('../../bot/options');

View File

@@ -8,7 +8,7 @@ const { logError } = require('../../utils/log');
const {
numberOfWarnsToBan,
warnInlineKeyboard,
} = require('../../config.json');
} = require('../../config');
const reply_markup = { inline_keyboard: warnInlineKeyboard };
// Bot

View File

@@ -1,7 +1,7 @@
'use strict';
// Config
const { master } = require('../../config.json');
const { master } = require('../../config');
// DB
const { addUser, isUser } = require('../../stores/user');

View File

@@ -9,7 +9,7 @@ const {
excludeLinks,
numberOfWarnsToBan,
warnInlineKeyboard,
} = require('../../config.json');
} = require('../../config');
const reply_markup = { inline_keyboard: warnInlineKeyboard };

View File

@@ -5,7 +5,7 @@ const { replyOptions } = require('../../bot/options');
const { admin } = require('../../stores/user');
const { addGroup, managesGroup } = require('../../stores/group');
const { master } = require('../../config.json');
const { master } = require('../../config');
const addedToGroupHandler = async (ctx, next) => {
const msg = ctx.message;

View File

@@ -1,6 +1,6 @@
'use strict';
const { deleteCommands } = require('../../config.json');
const { deleteCommands } = require('../../config');
const noop = Function.prototype;

View File

@@ -2,7 +2,7 @@
const { compose } = require('telegraf');
const config = require('../config.json');
const config = require('../config');
const names = config.plugins || [];
const plugins = names.map(name => `./${name}`).map(require);