diff --git a/components/app.js b/components/app.js index f04451b..8edb4e5 100644 --- a/components/app.js +++ b/components/app.js @@ -261,6 +261,11 @@ export default class App extends Component { this.connect(connectParams); } + isChannel(name) { + // TODO: use the ISUPPORT token if available + return irc.STD_CHANNEL_TYPES.indexOf(name[0]) >= 0; + } + executeCommand(s) { var parts = s.split(" "); var cmd = parts[0].toLowerCase().slice(1); @@ -281,9 +286,8 @@ export default class App extends Component { this.client.send({ command: "JOIN", params: [channel] }); break; case "part": - // TODO: check whether the buffer is a channel with the ISUPPORT token // 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"); return; } diff --git a/lib/irc.js b/lib/irc.js index 6766a1b..b48f8dc 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -13,6 +13,8 @@ export const ERR_SASLTOOLONG = "905"; export const ERR_SASLABORTED = "906"; export const ERR_SASLALREADY = "907"; +export const STD_CHANNEL_TYPES = "#&+!"; + var tagsEscape = { ";": "\\:", " ": "\\s",