From 7014390c1b368e0944355c8b22fc577fa3e85330 Mon Sep 17 00:00:00 2001 From: Quinton Lee Date: Sat, 15 Sep 2018 00:10:26 -0500 Subject: [PATCH] Add /notifyrank --- chat-commands.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/chat-commands.js b/chat-commands.js index 1c4bc8fb861f3..41501e8d08f28 100644 --- a/chat-commands.js +++ b/chat-commands.js @@ -2356,6 +2356,32 @@ const commands = { }, announcehelp: [`/announce OR /wall [message] - Makes an announcement. Requires: % @ * # & ~`], + notifyoffrank: 'notifyrank', + notifyrank: function (target, room, user, connection, cmd) { + if (!target) return this.parse(`/help notifyrank`); + if (!this.can('addhtml', null, room)) return false; + if (!this.canTalk()) return; + let [rank, notification] = this.splitOne(target); + if (!(rank in Config.groups)) return this.errorReply(`Group '${rank}' does not exist.`); + const id = `${room.id}-rank-${Config.groups[rank].id}`; + if (cmd === 'notifyoffrank') { + room.sendRankedUsers(`|tempnotifyoff|${id}`, rank); + } else { + let [title, message] = this.splitOne(notification); + if (!title) title = `${room.title} ${Config.groups[rank].name}+ message!`; + if (!user.can('addhtml')) { + title += ` (notification from ${user.name})`; + } + if (message.length > 300) return this.errorReply(`Notifications should not exceed 300 characters.`); + room.sendRankedUsers(`|tempnotify|${id}|${title}|${message}`, rank); + this.modlog(`NOTIFYRANK`, null, target); + } + }, + notifyrankhelp: [ + `/notifyrank [rank], [title], [message] - Sends a notification to everyone with the specified rank or higher. Requires: # * & ~`, + `/notifyoffrank [rank] - Closes the notification previously sent with /notifyrank [rank]. Requires: # * & ~`, + ], + fr: 'forcerename', forcerename: function (target, room, user) { if (!target) return this.parse('/help forcerename');