From c3998b6895050ca3c0f62e676a7be215b9ee3a84 Mon Sep 17 00:00:00 2001 From: Pavel DE WAVRECHIN Date: Mon, 27 May 2024 15:27:57 +0200 Subject: [PATCH 1/3] Fix typingProxy which did not work --- src/modules/typingProxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/typingProxy.js b/src/modules/typingProxy.js index e84d085ed..2a87acbcb 100644 --- a/src/modules/typingProxy.js +++ b/src/modules/typingProxy.js @@ -12,7 +12,7 @@ module.exports = ({ bot }) => { } // config.typingProxy: forward user typing in a DM to the modmail thread - if (config.typingProxy && (channel instanceof Eris.PrivateChannel)) { + if (config.typingProxy && !(channel instanceof Eris.GuildChannel)) { const thread = await threads.findOpenThreadByUserId(user.id); if (! thread) return; From 6cedf7b51c1f73a1395c31d3fa871c2466efb779 Mon Sep 17 00:00:00 2001 From: Pavel DE WAVRECHIN Date: Tue, 28 May 2024 08:31:46 +0200 Subject: [PATCH 2/3] Add blocklist command to show blocked users --- src/data/blocked.js | 17 +++++++++++++++++ src/modules/block.js | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/data/blocked.js b/src/data/blocked.js index 0d3dce7fc..60444f1ec 100644 --- a/src/data/blocked.js +++ b/src/data/blocked.js @@ -84,6 +84,22 @@ async function getExpiredBlocks() { return blocks.map(_block => _block.user_id); } +/** + * Returns the list of all blocked users + * @returns {Promise>} + */ +async function getBlockedUsers() { + const rows = await knex("blocked_users").select(); + + return rows.map(row => ({ + userId: row.user_id, + userName: row.user_name, + blockedBy: row.blocked_by, + blockedAt: row.blocked_at, + expiresAt: row.expires_at + })); +} + module.exports = { getBlockStatus, isBlocked, @@ -91,4 +107,5 @@ module.exports = { unblock, updateExpiryTime, getExpiredBlocks, + getBlockedUsers, }; diff --git a/src/modules/block.js b/src/modules/block.js index 0f6e21983..7179536f1 100644 --- a/src/modules/block.js +++ b/src/modules/block.js @@ -142,4 +142,21 @@ module.exports = ({ bot, knex, config, commands }) => { }); } }); + + commands.addInboxServerCommand("blocklist", "", async (msg, args, thread) => { + const blockedUsers = await blocked.getBlockedUsers(); + if (blockedUsers.length === 0) { + msg.channel.createMessage("No users are currently blocked."); + return; + } + + let reply = "List of blocked users:\n"; + for (const user of blockedUsers) { + const userInfo = `**<@!${user.userId}> (id \`${user.userId}\`)** - Blocked by <@${user.blockedBy}>${user.expiresAt ? ` until ${user.expiresAt} (UTC)` : " permanently"}`; + reply += userInfo + "\n"; + } + + msg.channel.createMessage(reply); + }); + }; From 9ea7cc690f3c2b5e381e50161e1c917e79b0f8f4 Mon Sep 17 00:00:00 2001 From: Pavel DE WAVRECHIN Date: Tue, 28 May 2024 11:07:52 +0200 Subject: [PATCH 3/3] Add ignoreOffensiveWords parameter + update configuration.md --- docs/configuration.md | 4 ++++ src/data/cfg.jsdoc.js | 1 + src/data/constants.js | 33 +++++++++++++++++++++++++++++++++ src/main.js | 3 +++ 4 files changed, 41 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index e53b193b1..810424e8f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -244,6 +244,10 @@ Alias for [`serverGreetings`](#serverGreetings) **Default:** `off` If enabled, the bot attempts to ignore common "accidental" messages that would start a new thread, such as "ok", "thanks", etc. +#### ignoreOffensiveThreads +**Default:** `off` +If enabled, the bot attempts to ignore common "offensive" messages that would start a new thread, such as "fuck", "idiot", etc. + #### inboxServerPermission **Default:** `manageMessages` **Accepts multiple values.** Permission name, user id, or role id required to use bot commands on the inbox server. diff --git a/src/data/cfg.jsdoc.js b/src/data/cfg.jsdoc.js index bed89b5aa..ffe25a0e9 100644 --- a/src/data/cfg.jsdoc.js +++ b/src/data/cfg.jsdoc.js @@ -26,6 +26,7 @@ * @property {boolean} [useNicknames=false] * @property {boolean} [anonymizeChannelName=false] * @property {boolean} [ignoreAccidentalThreads=false] + * @property {boolean} [ignoreOffensiveThreads=false] * @property {boolean} [threadTimestamps=false] * @property {boolean} [allowMove=false] * @property {boolean} [syncPermissionsOnMove=true] diff --git a/src/data/constants.js b/src/data/constants.js index 886313ffa..5ce4fc63d 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -74,4 +74,37 @@ module.exports = { "okey np", "cheers" ], + + OFFENSIVE_THREAD_MESSAGES: [ + "idiot", + "moron", + "stupid", + "dumb", + "fool", + "jerk", + "loser", + "imbecile", + "asshole", + "bastard", + "bitch", + "douchebag", + "scumbag", + "prick", + "cretin", + "twit", + "twat", + "git", + "wanker", + "slut", + "whore", + "dickhead", + "fuckface", + "shithead", + "cocksucker", + "asshat", + "dipshit", + "nutcase", + "bonehead", + "jackass" + ], }; diff --git a/src/main.js b/src/main.js index bce3385bc..db538e987 100644 --- a/src/main.js +++ b/src/main.js @@ -16,6 +16,7 @@ const threads = require("./data/threads"); const updates = require("./data/updates"); const { ACCIDENTAL_THREAD_MESSAGES } = require("./data/constants"); +const { OFFENSIVE_THREAD_MESSAGES } = require("./data/constants"); const {getOrFetchChannel} = require("./utils"); module.exports = { @@ -181,6 +182,8 @@ function initBaseMessageHandlers() { // Ignore messages that shouldn't usually open new threads, such as "ok", "thanks", etc. if (config.ignoreAccidentalThreads && msg.content && ACCIDENTAL_THREAD_MESSAGES.includes(msg.content.trim().toLowerCase())) return; + if (config.ignoreOffensiveThreads && msg.content && OFFENSIVE_THREAD_MESSAGES.includes(msg.content.trim().toLowerCase())) return; + thread = await threads.createNewThreadForUser(msg.author, { source: "dm", message: msg,