mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Rewrite ping-based commands to avoid space parsing problems
This commit is contained in:
parent
d89c21d41e
commit
82ae8d7062
@ -42,7 +42,11 @@ export class Mjolnir {
|
||||
const content = event['content'];
|
||||
if (content['msgtype'] === "m.text" && content['body']) {
|
||||
const prefixes = [COMMAND_PREFIX, this.localpart + ":", this.displayName + ":", await client.getUserId() + ":"];
|
||||
if (!prefixes.find(p => content['body'].startsWith(p))) return;
|
||||
const prefixUsed = prefixes.find(p => content['body'].startsWith(p));
|
||||
if (!prefixUsed) return;
|
||||
|
||||
// rewrite the event body to make the prefix uniform (in case the bot has spaces in its display name)
|
||||
event['content']['body'] = COMMAND_PREFIX + content['body'].substring(prefixUsed.length);
|
||||
|
||||
await client.sendReadReceipt(roomId, event['event_id']);
|
||||
return handleCommand(roomId, event, this);
|
||||
|
Loading…
Reference in New Issue
Block a user