Implement /me

This commit is contained in:
Simon Ser 2020-06-28 09:29:39 +02:00
parent 15c51d9ec7
commit 59b98d38ac
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -441,6 +441,16 @@ export default class App extends Component {
var text = args.slice(1).join(" "); var text = args.slice(1).join(" ");
this.client.send({ command: "PRIVMSG", params: [target, text] }); this.client.send({ command: "PRIVMSG", params: [target, text] });
break; break;
case "me":
var action = args.join(" ");
var target = this.state.activeBuffer;
if (!target) {
console.error("Not in a buffer");
return;
}
var text = `\x01ACTION ${action}\x01`;
this.privmsg(target, text);
break;
case "nick": case "nick":
var newNick = args[0]; var newNick = args[0];
this.client.send({ command: "NICK", params: [newNick] }); this.client.send({ command: "NICK", params: [newNick] });
@ -458,6 +468,21 @@ export default class App extends Component {
} }
} }
privmsg(target, text) {
if (target == SERVER_BUFFER) {
console.error("Cannot send message in server buffer");
return;
}
var msg = { command: "PRIVMSG", params: [target, text] };
this.client.send(msg);
if (!this.client.enabledCaps["echo-message"]) {
msg.prefix = { name: this.client.nick };
this.addMessage(target, msg);
}
}
handleComposerSubmit(text) { handleComposerSubmit(text) {
if (!text) { if (!text) {
return; return;
@ -471,17 +496,11 @@ export default class App extends Component {
} }
var target = this.state.activeBuffer; var target = this.state.activeBuffer;
if (!target || target == SERVER_BUFFER) { if (!target) {
return; return;
} }
var msg = { command: "PRIVMSG", params: [target, text] }; this.privmsg(target, text);
this.client.send(msg);
if (!this.client.enabledCaps["echo-message"]) {
msg.prefix = { name: this.client.nick };
this.addMessage(target, msg);
}
} }
handleBufferListClick(name) { handleBufferListClick(name) {