Made IRC style command easier to handle specifically for possible arguments
This commit is contained in:
parent
8166ebd91a
commit
65c7f78e9f
|
@ -250,28 +250,40 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
||||||
|
|
||||||
$scope.state.sending = true;
|
$scope.state.sending = true;
|
||||||
|
|
||||||
// Send the text message
|
|
||||||
var promise;
|
var promise;
|
||||||
// FIXME: handle other commands too
|
|
||||||
if ($scope.textInput.indexOf("/me") === 0) {
|
// Check for IRC style commands first
|
||||||
promise = matrixService.sendEmoteMessage($scope.room_id, $scope.textInput.substr(4));
|
if ($scope.textInput.indexOf("/") === 0) {
|
||||||
}
|
var args = $scope.textInput.split(' ');
|
||||||
else if ($scope.textInput.indexOf("/nick ") === 0) {
|
var cmd = args[0];
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case "/me":
|
||||||
|
var emoteMsg = args.slice(1).join(' ');
|
||||||
|
promise = matrixService.sendEmoteMessage($scope.room_id, emoteMsg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "/nick":
|
||||||
// Change user display name
|
// Change user display name
|
||||||
promise = matrixService.setDisplayName($scope.textInput.substr(6));
|
if (2 === args.length) {
|
||||||
|
promise = matrixService.setDisplayName(args[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Send the text message
|
||||||
promise = matrixService.sendTextMessage($scope.room_id, $scope.textInput);
|
promise = matrixService.sendTextMessage($scope.room_id, $scope.textInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
promise.then(
|
promise.then(
|
||||||
function() {
|
function() {
|
||||||
console.log("Sent message");
|
console.log("Request successfully sent");
|
||||||
$scope.textInput = "";
|
$scope.textInput = "";
|
||||||
$scope.state.sending = false;
|
$scope.state.sending = false;
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
$scope.feedback = "Failed to send: " + error.data.error;
|
$scope.feedback = "Request failed: " + error.data.error;
|
||||||
$scope.state.sending = false;
|
$scope.state.sending = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue