Don't explicitly trigger the hook parseMessageForCommands

inside `parseMessageForMUCCommands`.

If the function doesn't find any core MUC commands, it calls
`parseMessageForCommands` which will trigger the hook.

I think it's appropriate to give built-in commands preference above
commands by 3rd party plugins and this also solves the issue of the hook
being triggered twice (once in `parseMessageForMUCCommands` and
then again in `parseMessageForCommands`).
This commit is contained in:
JC Brand 2022-01-27 14:34:52 +01:00
parent d06761e2a8
commit 003a90c71c

View File

@ -298,7 +298,7 @@ export function showOccupantModal (ev, occupant) {
} }
export async function parseMessageForMUCCommands (muc, text) { export function parseMessageForMUCCommands (muc, text) {
if ( if (
api.settings.get('muc_disable_slash_commands') && api.settings.get('muc_disable_slash_commands') &&
!Array.isArray(api.settings.get('muc_disable_slash_commands')) !Array.isArray(api.settings.get('muc_disable_slash_commands'))
@ -311,11 +311,6 @@ export async function parseMessageForMUCCommands (muc, text) {
return false; return false;
} }
const handled = await api.hook('parseMessageForCommands', {model: muc, text}, false);
if (handled) {
return true;
}
const args = text.slice(('/' + command).length + 1).trim(); const args = text.slice(('/' + command).length + 1).trim();
if (!muc.getAllowedCommands().includes(command)) { if (!muc.getAllowedCommands().includes(command)) {
return false; return false;