mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Corrected some syntax dismiss
This commit is contained in:
parent
faa8cae532
commit
fb58d9c9ef
@ -200,71 +200,72 @@ export class RoomViewModel extends ViewModel {
|
|||||||
async _getMessageInformations (message) {
|
async _getMessageInformations (message) {
|
||||||
let msgtype = "m.text";
|
let msgtype = "m.text";
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
let command=message.substring(1).split(" ");
|
const [commandName, ...args] = message.substring(1).split(" ");
|
||||||
switch (command[0]) {
|
switch (commandName) {
|
||||||
case "me":
|
case "me":
|
||||||
message = message.substring(4).trim();
|
message = message.substring(4).trim();
|
||||||
msgtype = "m.emote";
|
msgtype = "m.emote";
|
||||||
break;
|
break;
|
||||||
case "join":
|
case "join":
|
||||||
if (command.length==2) {
|
if (args.length == 1) {
|
||||||
let roomname = message.substring(5).trim();
|
let roomName = args[0];
|
||||||
try {
|
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) {
|
} catch (exc) {
|
||||||
if (exc.statusCode??exc.status==400) {
|
if (exc.statusCode ?? exc.status === 400) {
|
||||||
this._sendError=new Error("/join : '"+roomname+"' was not legal room ID or room alias");
|
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")) {
|
} else if ((exc.statusCode ?? exc.status === 404) || (exc.statusCode ?? exc.status === 502) || (exc.message == "Internal Server Error")) {
|
||||||
this._sendError=new Error("/join : room not found");
|
this._sendError = new Error(`/join : room '${roomName}' not found`);
|
||||||
} else {
|
} else {
|
||||||
this._sendError=new Error("join syntax: /join <room-id>");
|
this._sendError = new Error("join syntax: /join <room-id>");
|
||||||
}
|
}
|
||||||
this._timelineError = null;
|
this._timelineError = null;
|
||||||
this.emitChange("error");
|
this.emitChange("error");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._sendError=new Error("join syntax: /join <room-id>");
|
this._sendError = new Error("join syntax: /join <room-id>");
|
||||||
this._timelineError = null;
|
this._timelineError = null;
|
||||||
this.emitChange("error");
|
this.emitChange("error");
|
||||||
}
|
}
|
||||||
msgtype=undefined;
|
msgtype = undefined;
|
||||||
message=undefined;
|
message = undefined;
|
||||||
break;
|
break;
|
||||||
case "shrug":
|
case "shrug":
|
||||||
message="¯\\_(ツ)_/¯ "+message.substring(7);
|
message = "¯\\_(ツ)_/¯ " + message.substring(7);
|
||||||
break;
|
break;
|
||||||
case "tableflip":
|
case "tableflip":
|
||||||
message="(╯°□°)╯︵ ┻━┻ "+message.substring(11);
|
message="(╯°□°)╯︵ ┻━┻ " + message.substring(11);
|
||||||
break;
|
break;
|
||||||
case "unflip":
|
case "unflip":
|
||||||
message="┬──┬ ノ( ゜-゜ノ) "+message.substring(8);
|
message="┬──┬ ノ( ゜-゜ノ) " + message.substring(8);
|
||||||
break;
|
break;
|
||||||
case "lenny":
|
case "lenny":
|
||||||
message="( ͡° ͜ʖ ͡°) "+message.substring(7);
|
message="( ͡° ͜ʖ ͡°) " + message.substring(7);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (command[0][0]=="/") {
|
if (commandName[0] == "/") {
|
||||||
message = message.substring(1).trim();
|
message = message.substring(1).trim();
|
||||||
break;
|
break;
|
||||||
} else {
|
} 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._timelineError = null;
|
||||||
this.emitChange("error");
|
this.emitChange("error");
|
||||||
msgtype=undefined;
|
msgtype = undefined;
|
||||||
message=undefined;
|
message = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [msgtype, message];
|
return {type: msgtype, message: message};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _sendMessage(message, replyingTo) {
|
async _sendMessage(message, replyingTo) {
|
||||||
if (!this._room.isArchived && message) {
|
if (!this._room.isArchived && message) {
|
||||||
let messinfo = await this._getMessageInformations(message);
|
let messinfo = await this._getMessageInformations(message);
|
||||||
try {
|
try {
|
||||||
let msgtype = messinfo[0];
|
let msgtype = messinfo.type;
|
||||||
let message = messinfo[1];
|
let message = messinfo.message;
|
||||||
console.log("messinfo :",messinfo);
|
|
||||||
if (msgtype && message) {
|
if (msgtype && message) {
|
||||||
if (replyingTo) {
|
if (replyingTo) {
|
||||||
await replyingTo.reply(msgtype, message);
|
await replyingTo.reply(msgtype, message);
|
||||||
|
Loading…
Reference in New Issue
Block a user