Add isChannel

This commit is contained in:
Simon Ser 2020-06-24 15:52:33 +02:00
parent f5106f1357
commit df0981e8e0
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 8 additions and 2 deletions

View file

@ -261,6 +261,11 @@ export default class App extends Component {
this.connect(connectParams); this.connect(connectParams);
} }
isChannel(name) {
// TODO: use the ISUPPORT token if available
return irc.STD_CHANNEL_TYPES.indexOf(name[0]) >= 0;
}
executeCommand(s) { executeCommand(s) {
var parts = s.split(" "); var parts = s.split(" ");
var cmd = parts[0].toLowerCase().slice(1); var cmd = parts[0].toLowerCase().slice(1);
@ -281,9 +286,8 @@ export default class App extends Component {
this.client.send({ command: "JOIN", params: [channel] }); this.client.send({ command: "JOIN", params: [channel] });
break; break;
case "part": case "part":
// TODO: check whether the buffer is a channel with the ISUPPORT token
// TODO: part reason // TODO: part reason
if (!this.state.activeBuffer || this.state.activeBuffer == SERVER_BUFFER) { if (!this.state.activeBuffer || !this.isChannel(this.state.activeBuffer)) {
console.error("Not in a channel"); console.error("Not in a channel");
return; return;
} }

View file

@ -13,6 +13,8 @@ export const ERR_SASLTOOLONG = "905";
export const ERR_SASLABORTED = "906"; export const ERR_SASLABORTED = "906";
export const ERR_SASLALREADY = "907"; export const ERR_SASLALREADY = "907";
export const STD_CHANNEL_TYPES = "#&+!";
var tagsEscape = { var tagsEscape = {
";": "\\:", ";": "\\:",
" ": "\\s", " ": "\\s",