Fix escaping commands using double-slash //, e.g //plain sends /plain
This commit is contained in:
parent
adec308529
commit
b5e902e1f2
2 changed files with 17 additions and 4 deletions
|
@ -61,18 +61,26 @@ export function textSerialize(model) {
|
|||
}
|
||||
|
||||
export function containsEmote(model) {
|
||||
return startsWith(model, "/me ");
|
||||
}
|
||||
|
||||
export function startsWith(model, prefix) {
|
||||
const firstPart = model.parts[0];
|
||||
// part type will be "plain" while editing,
|
||||
// and "command" while composing a message.
|
||||
return firstPart &&
|
||||
(firstPart.type === "plain" || firstPart.type === "command") &&
|
||||
firstPart.text.startsWith("/me ");
|
||||
firstPart.text.startsWith(prefix);
|
||||
}
|
||||
|
||||
export function stripEmoteCommand(model) {
|
||||
// trim "/me "
|
||||
return stripPrefix(model, "/me ");
|
||||
}
|
||||
|
||||
export function stripPrefix(model, prefix) {
|
||||
model = model.clone();
|
||||
model.removeText({index: 0, offset: 0}, 4);
|
||||
model.removeText({index: 0, offset: 0}, prefix.length);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue