From 9019063fa78405234d1d07e6abb1155e9294d04f Mon Sep 17 00:00:00 2001 From: Miikka Virtanen <2606411+Dragory@users.noreply.github.com> Date: Mon, 17 Jun 2019 10:22:01 +0300 Subject: [PATCH 1/6] Update README/CHANGELOG for 2.25.0 --- CHANGELOG.md | 6 ++++++ README.md | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c22f131..3f128b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v2.25.0 +* Fix regression introduced in v2.24.0 where line breaks would get turned to spaces in replies and snippets ([https://github.com/Dragory/modmailbot/issues/304](#304)) +* Replace the internal command handler with a new one. This should be fairly thoroughly tested, but please report any issues you encounter! +* Plugins are now called with a fourth parameter that allows you to easily add specific types of commands + * Due to the command handler change, any calls to `bot.registerCommand` should be replaced with the new system + ## v2.24.0 * Switch to the new stable version of Eris (0.10.0) instead of the dev version diff --git a/README.md b/README.md index e2e8a7b..31d22d6 100644 --- a/README.md +++ b/README.md @@ -126,18 +126,23 @@ The path is relative to the bot's folder. ### Creating a plugin Create a `.js` file that exports a function. -This function will be called when the plugin is loaded with the following arguments: `(bot, knex, config)` +This function will be called when the plugin is loaded with the following arguments: `(bot, knex, config, commands)` where `bot` is the [Eris Client object](https://abal.moe/Eris/docs/Client), `knex` is the [Knex database object](https://knexjs.org/#Builder), -and `config` is the loaded config object. +`config` is the loaded config object, +and `commands` is an object with functions to add and manage commands (see bottom of [src/commands.js](src/commands.js)) #### Example plugin file ```js -module.exports = function(bot, knex, config) { - console.log('Plugin loaded!'); +module.exports = function(bot, knex, config, commands) { + commands.addInboxThreadCommand('mycommand', [], (msg, args, thread) => { + thread.replyToUser(msg.author, 'Reply from my custom plugin!'); + }); } ``` ### Work in progress The current plugin API is fairly rudimentary and will be expanded in the future. +The API can change in non-major releases during this early stage. Keep an eye on [CHANGELOG.md](CHANGELOG.md) for any changes. + Please send any feature suggestions to the [issue tracker](https://github.com/Dragory/modmailbot/issues)! From fbcbdd90858786a43bfce95ed2052fb990f2afb9 Mon Sep 17 00:00:00 2001 From: Miikka Virtanen <2606411+Dragory@users.noreply.github.com> Date: Mon, 17 Jun 2019 10:23:15 +0300 Subject: [PATCH 2/6] 2.25.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c9175c..8c0a37d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "modmailbot", - "version": "2.24.0", + "version": "2.25.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ee670fc..f83e92c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "modmailbot", - "version": "2.24.0", + "version": "2.25.0", "description": "", "license": "MIT", "main": "src/index.js", From 3bec7ba6421afedb4494e48d6fac85e297d61b7b Mon Sep 17 00:00:00 2001 From: Miikka Virtanen <2606411+Dragory@users.noreply.github.com> Date: Mon, 17 Jun 2019 10:24:17 +0300 Subject: [PATCH 3/6] Fix link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f128b3..b5bd270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## v2.25.0 -* Fix regression introduced in v2.24.0 where line breaks would get turned to spaces in replies and snippets ([https://github.com/Dragory/modmailbot/issues/304](#304)) +* Fix regression introduced in v2.24.0 where line breaks would get turned to spaces in replies and snippets ([#304](https://github.com/Dragory/modmailbot/issues/304)) * Replace the internal command handler with a new one. This should be fairly thoroughly tested, but please report any issues you encounter! * Plugins are now called with a fourth parameter that allows you to easily add specific types of commands * Due to the command handler change, any calls to `bot.registerCommand` should be replaced with the new system From 0595f0a4f585eb67bcb6dd3c3dc8c65e5d0e68d1 Mon Sep 17 00:00:00 2001 From: Robert Klebes Date: Tue, 25 Jun 2019 06:27:40 -0400 Subject: [PATCH 4/6] Add pm2 support Add json file to launch and monitor in pm2 and allow automatic restarts if the bot crashes --- modmailbot-pm2.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modmailbot-pm2.json diff --git a/modmailbot-pm2.json b/modmailbot-pm2.json new file mode 100644 index 0000000..6322645 --- /dev/null +++ b/modmailbot-pm2.json @@ -0,0 +1,8 @@ +{ + "apps": [{ + "name": "ModMailBot", + "cwd": "./", + "script": "npm", + "args": "start" + }] +} From 7a099b30b80faec83999ef5e495d0b9bbc95f77c Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Mon, 5 Aug 2019 22:29:19 -0400 Subject: [PATCH 5/6] Possible oversight `newThreadCategoryId` is not needed if my understanding of how the config file is read as `categoryAutomation.newThread` and `categoryAutomation.newThreadFromGuild` exist. If this is an intended part of the README.md for backwards compatibility (even though I don't know why it would still be here,) please correct me. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 31d22d6..36db6c3 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,6 @@ These go in `config.json`. See also `config.example.json`. |timeOnServerDeniedMessage|"You haven't been a member of the server for long enough to contact modmail."|See `requiredTimeOnServer` below| |mentionRole|"here"|Role that is mentioned when new threads are created or the bot is mentioned. Accepted values are "here", "everyone", or a role id as a string. Set to null to disable these pings entirely. Multiple values in an array are supported.| |mentionUserInThreadHeader|false|If set to true, mentions the thread's user in the thread header| -|newThreadCategoryId|None|ID of the category where new modmail thread channels should be placed| |pingOnBotMention|true|If enabled, the bot will mention staff (see mentionRole above) on the inbox server when the bot is mentioned on the main server.| |plugins|None|Array of plugins to load on startup. See [Plugins](#plugins) section below for more information.| |port|8890|Port from which to serve attachments and logs| From 92ce0b13602447638d7e6addad142e6fdbe30a57 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Tue, 6 Aug 2019 13:41:54 -0400 Subject: [PATCH 6/6] Update README.md Added `newThreadCategoryId` back in and changed description to reflect deprecation of the option. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 36db6c3..ccbb66f 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ These go in `config.json`. See also `config.example.json`. |timeOnServerDeniedMessage|"You haven't been a member of the server for long enough to contact modmail."|See `requiredTimeOnServer` below| |mentionRole|"here"|Role that is mentioned when new threads are created or the bot is mentioned. Accepted values are "here", "everyone", or a role id as a string. Set to null to disable these pings entirely. Multiple values in an array are supported.| |mentionUserInThreadHeader|false|If set to true, mentions the thread's user in the thread header| +|newThreadCategoryId|None|**Deprecated** ID of the category where new modmail thread channels should be placed| |pingOnBotMention|true|If enabled, the bot will mention staff (see mentionRole above) on the inbox server when the bot is mentioned on the main server.| |plugins|None|Array of plugins to load on startup. See [Plugins](#plugins) section below for more information.| |port|8890|Port from which to serve attachments and logs|