MUC: Register handler to parse for commands in the plugin index.js
This commit is contained in:
parent
e1a919749f
commit
7c7b667745
@ -8,7 +8,7 @@ import 'plugins/modal/index.js';
|
|||||||
import './adhoc-commands.js';
|
import './adhoc-commands.js';
|
||||||
import MUCView from './muc.js';
|
import MUCView from './muc.js';
|
||||||
import { api, converse } from '@converse/headless/core';
|
import { api, converse } from '@converse/headless/core';
|
||||||
import { clearHistory, fetchAndSetMUCDomain } from './utils.js';
|
import { clearHistory, fetchAndSetMUCDomain, parseMessageForMUCCommands } from './utils.js';
|
||||||
|
|
||||||
import './styles/index.scss';
|
import './styles/index.scss';
|
||||||
|
|
||||||
@ -80,5 +80,7 @@ converse.plugins.add('converse-muc-views', {
|
|||||||
clearHistory(model.get('jid'));
|
clearHistory(model.get('jid'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.listen.on('parseMessageForCommands', parseMessageForMUCCommands);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import MessageForm from 'plugins/chatview/message-form.js';
|
import MessageForm from 'plugins/chatview/message-form.js';
|
||||||
import tpl_muc_message_form from './templates/message-form.js';
|
import tpl_muc_message_form from './templates/message-form.js';
|
||||||
import { _converse, api, converse } from "@converse/headless/core";
|
import { _converse, api, converse } from "@converse/headless/core";
|
||||||
import { getAutoCompleteListItem, parseMessageForMUCCommands } from './utils.js';
|
import { getAutoCompleteListItem } from './utils.js';
|
||||||
|
|
||||||
|
|
||||||
export default class MUCMessageForm extends MessageForm {
|
export default class MUCMessageForm extends MessageForm {
|
||||||
@ -9,7 +9,6 @@ export default class MUCMessageForm extends MessageForm {
|
|||||||
async connectedCallback () {
|
async connectedCallback () {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
await this.model.initialized;
|
await this.model.initialized;
|
||||||
api.listen.on('parseMessageForCommands', parseMessageForMUCCommands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toHTML () {
|
toHTML () {
|
||||||
|
@ -296,7 +296,9 @@ export function showOccupantModal (ev, occupant) {
|
|||||||
|
|
||||||
|
|
||||||
export function parseMessageForMUCCommands (data, handled) {
|
export function parseMessageForMUCCommands (data, handled) {
|
||||||
if (handled || (
|
const model = data.model;
|
||||||
|
if (handled ||
|
||||||
|
model.get('type') !== _converse.CHATROOMS_TYPE || (
|
||||||
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'))
|
||||||
)) {
|
)) {
|
||||||
@ -310,7 +312,6 @@ export function parseMessageForMUCCommands (data, handled) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const model = data.model;
|
|
||||||
const args = text.slice(('/' + command).length + 1).trim();
|
const args = text.slice(('/' + command).length + 1).trim();
|
||||||
const allowed_commands = model.getAllowedCommands() ?? [];
|
const allowed_commands = model.getAllowedCommands() ?? [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user