diff --git a/CONFIG.md b/CONFIG.md deleted file mode 100644 index 7165def..0000000 --- a/CONFIG.md +++ /dev/null @@ -1,74 +0,0 @@ -# config.json format - -This document describes the field in config.json. - -Create config.json by running: - -`cp example.config.json config.json` - -in the project folder, then edit it. - -## "master" - -`number|string` - -Master admin ID as a number or username as a string. - -## "token" - -`string` - -Telegram Bot token obtained from [https://t.me/BotFather](@BotFather). - -## "plugins" - -`[string]` - -List of plugin names to be loaded. - -## "deleteCommands" - -`string` - -Which messages with commands should be deleted? - -Options: - -* "all" -* "own" (default) - leave commands meant for other bots -* "none" - -## "numberOfWarnsToBan" - -`number` - -Number of warns that will get someone banned. - -## "groupsInlineKeyboard" - -`[[inlineButton]]` - -inline keyboard to be added to reply to /groups. - -## "warnInlineKeyboard" - -`[[inlineButton]]` - -Inline keyboard to be added to warn message. - -## "excludedChannels" - -`[string]` - -List of channels that you want to be excluded from automatic warns. - -Use `"*"` to disable. - -## "excludedGroups" - -`[string]` - -List of groups that you want to be excluded from automatic warns. - -Use `"*"` to disable. - diff --git a/README.md b/README.md index c70bc4f..bc9ad1b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ You need [Node.js](https://nodejs.org/) (> 8.1) to run this bot. 1. Create a bot via [@BotFather](https://t.me/BotFather) and grab a **token**. 2. Clone this repository or [download zip](https://github.com/TheDevs-Network/the-guard-bot/archive/master.zip). 3. Install dependencies via `npm install`. -4. Copy `config.example.json` to `config.json`, fill it properly and remove comments. +4. Copy `example.config.js` to `config.js` and edit it. 5. Start the bot via `npm start`. Now you can add the bot as **administrator** to your groups. diff --git a/example.config.js b/example.config.js new file mode 100644 index 0000000..8dc539e --- /dev/null +++ b/example.config.js @@ -0,0 +1,71 @@ +'use strict'; + +/* + * Create `config.js` by running `cp example.config.js config.js` + * in the project folder, then edit it. + * + * Config file in JSON format (`config.json`) is also supported. + * For backwards compatibility, and because why not, it needs no extra code. + */ + +module.exports = { + + /** + * @type {!( number | string )} + * ID (number) or username (string) of master, + * the person who can promote and demote admins, + * and add the bot to groups. + */ + master: 123456789, + + /** + * @type {!string} + * Telegram Bot token obtained from https://t.me/BotFather. + */ + token: '', + + + /** + * @type {( 'all' | 'own' | 'none' )} + * Which messages with commands should be deleted? + * Defaults to 'own' -- don't delete commands meant for other bots. + */ + deleteCommands: 'own', // eslint-disable-line sort-keys + + /** + * @type {( number | string | false )} + * Timeout before removing join and leave messages. + * String to be parsed by https://npmjs.com/millisecond, + * or number of milliseconds. + * Pass 0 to remove immediately. + * Pass false to never remove. + */ + deleteJoinsAfter: '2 minutes', + + excludeLinks: [], + + /** + * @type {InlineKeyboardMarkup} + * Inline keyboard to be added to reply to /groups. + * We use it to display button opening our webpage. + */ + groupsInlineKeyboard: [], + + numberOfWarnsToBan: 3, + + /** + * @type {string[]} + * List of plugin names to be loaded. + * See Readme in plugins directory for more details. + */ + plugins: [], + + /** + * @type {InlineKeyboardMarkup} + * Inline keyboard to be added to warn message. + * We use it to display button showing our rules. + */ + warnInlineKeyboard: [], +}; + +Object.freeze(module.exports); diff --git a/example.config.json b/example.config.json deleted file mode 100644 index cc00f95..0000000 --- a/example.config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "master": 123456789, - "token": "", - "plugins": [], - "deleteCommands": "own", - "deleteJoinsAfter": "2 minutes", - "numberOfWarnsToBan": 3, - "groupsInlineKeyboard": [], - "warnInlineKeyboard": [], - "excludeLinks": [] -}