Add SlashCommands to functionally process /commands.
This commit is contained in:
parent
6b81022e28
commit
9aa66c1d8b
2 changed files with 212 additions and 0 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
'use strict';
|
||||
|
||||
var MatrixClientPeg = require("../../MatrixClientPeg");
|
||||
var SlashCommands = require("../../SlashCommands");
|
||||
|
||||
var dis = require("../../dispatcher");
|
||||
var KeyCode = {
|
||||
|
@ -171,6 +172,25 @@ module.exports = {
|
|||
|
||||
onEnter: function(ev) {
|
||||
var contentText = this.refs.textarea.getDOMNode().value;
|
||||
|
||||
var cmd = SlashCommands.processInput(this.props.room.roomId, contentText);
|
||||
if (cmd) {
|
||||
ev.preventDefault();
|
||||
if (cmd.promise) {
|
||||
cmd.promise.done(function() {
|
||||
console.log("Command success.");
|
||||
}, function(err) {
|
||||
console.error("Command failure: %s", err);
|
||||
});
|
||||
this.refs.textarea.getDOMNode().value = '';
|
||||
}
|
||||
else if (cmd.error) {
|
||||
console.error(cmd.error);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var content = null;
|
||||
if (/^\/me /i.test(contentText)) {
|
||||
content = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue