Corrected some syntax dismiss

This commit is contained in:
Kaki In 2022-07-22 16:08:53 +02:00
parent faa8cae532
commit fb58d9c9ef

View file

@ -200,71 +200,72 @@ export class RoomViewModel extends ViewModel {
async _getMessageInformations (message) {
let msgtype = "m.text";
if (message.startsWith("/")) {
let command=message.substring(1).split(" ");
switch (command[0]) {
const [commandName, ...args] = message.substring(1).split(" ");
switch (commandName) {
case "me":
message = message.substring(4).trim();
msgtype = "m.emote";
break;
case "join":
if (command.length==2) {
let roomname = message.substring(5).trim();
if (args.length == 1) {
let roomName = args[0];
try {
await this._options.client.session.joinRoom(roomname);
await this._options.client.session.joinRoom(roomName);
const internalId = await this._options.client.session.joinRoom(roomName);
this.navigation.push("room", internalId);
} catch (exc) {
if (exc.statusCode??exc.status==400) {
this._sendError=new Error("/join : '"+roomname+"' was not legal room ID or room alias");
} else if ((exc.statusCode??exc.status==502) || (exc.message="Internal Server Error")) {
this._sendError=new Error("/join : room not found");
if (exc.statusCode ?? exc.status === 400) {
this._sendError = new Error(`/join : '${roomName}' was not legal room ID or room alias`);
} else if ((exc.statusCode ?? exc.status === 404) || (exc.statusCode ?? exc.status === 502) || (exc.message == "Internal Server Error")) {
this._sendError = new Error(`/join : room '${roomName}' not found`);
} else {
this._sendError=new Error("join syntax: /join <room-id>");
this._sendError = new Error("join syntax: /join <room-id>");
}
this._timelineError = null;
this.emitChange("error");
}
} else {
this._sendError=new Error("join syntax: /join <room-id>");
this._sendError = new Error("join syntax: /join <room-id>");
this._timelineError = null;
this.emitChange("error");
}
msgtype=undefined;
message=undefined;
msgtype = undefined;
message = undefined;
break;
case "shrug":
message="¯\\_(ツ)_/¯ "+message.substring(7);
message = "¯\\_(ツ)_/¯ " + message.substring(7);
break;
case "tableflip":
message="(╯°□°)╯︵ ┻━┻ "+message.substring(11);
message="(╯°□°)╯︵ ┻━┻ " + message.substring(11);
break;
case "unflip":
message="┬──┬ ( ゜-゜ノ) "+message.substring(8);
message="┬──┬ ( ゜-゜ノ) " + message.substring(8);
break;
case "lenny":
message="( ͡° ͜ʖ ͡°) "+message.substring(7);
message="( ͡° ͜ʖ ͡°) " + message.substring(7);
break;
default:
if (command[0][0]=="/") {
if (commandName[0] == "/") {
message = message.substring(1).trim();
break;
} else {
this._sendError=new Error("no command name '"+command[0]+"'");
this._sendError = new Error(`no command name "${commandName}". To send the message instead of executing, please type "/${message}"`);
this._timelineError = null;
this.emitChange("error");
msgtype=undefined;
message=undefined;
msgtype = undefined;
message = undefined;
}
}
}
return [msgtype, message];
return {type: msgtype, message: message};
}
async _sendMessage(message, replyingTo) {
if (!this._room.isArchived && message) {
let messinfo = await this._getMessageInformations(message);
try {
let msgtype = messinfo[0];
let message = messinfo[1];
console.log("messinfo :",messinfo);
let msgtype = messinfo.type;
let message = messinfo.message;
if (msgtype && message) {
if (replyingTo) {
await replyingTo.reply(msgtype, message);