Add /help, make /part take an optional channel param

This commit is contained in:
khlieng 2015-02-21 14:11:29 +01:00
parent ccb0149b3d
commit b83efcbb9e
3 changed files with 45 additions and 13 deletions

View File

@ -1,3 +1,5 @@
var _ = require('lodash');
var channelStore = require('./stores/channel'); var channelStore = require('./stores/channel');
var channelActions = require('./actions/channel'); var channelActions = require('./actions/channel');
var messageActions = require('./actions/message'); var messageActions = require('./actions/message');
@ -27,7 +29,9 @@ messageActions.command.listen(function(line, channel, server) {
break; break;
case 'part': case 'part':
if (channel) { if (params[1]) {
channelActions.part([params[1]], server);
} else if (channel) {
channelActions.part([channel], server); channelActions.part([channel], server);
} }
break; break;
@ -88,5 +92,19 @@ messageActions.command.listen(function(line, channel, server) {
case 'away': case 'away':
serverActions.away(params[1], server); serverActions.away(params[1], server);
break; break;
case 'help':
messageActions.inform([
_.escape('/join <channel> - Join a channel'),
'/part [channel] - Leave the current or entered channel',
_.escape('/nick <nick> - Change nick'),
'/quit - Disconnect from the current server',
_.escape('/me <message> - Send action message'),
'/topic - Show topic for the current channel',
_.escape('/msg <target> <message> - Send message to the entered channel or user'),
_.escape('/say <message> - Send message to the current chat'),
'/away [message] - Set or clear away message'
], server, channel);
break;
} }
}); });

View File

@ -59,12 +59,14 @@ socket.on('mode', function(data) {
socket.on('whois', function(data) { socket.on('whois', function(data) {
var tab = selectedTabStore.getState(); var tab = selectedTabStore.getState();
messageActions.inform('Nick: ' + data.nick, tab.server, tab.channel); messageActions.inform([
messageActions.inform('Username: ' + data.username, tab.server, tab.channel); 'Nick: ' + data.nick,
messageActions.inform('Realname: ' + data.realname, tab.server, tab.channel); 'Username: ' + data.username,
messageActions.inform('Host: ' + data.host, tab.server, tab.channel); 'Realname: ' + data.realname,
messageActions.inform('Server: ' + data.server, tab.server, tab.channel); 'Host: ' + data.host,
messageActions.inform('Channels: ' + data.channels, tab.server, tab.channel); 'Server: ' + data.server,
'Channels: ' + data.channels
], tab.server, tab.channel);
}); });
socket.on('servers', function(data) { socket.on('servers', function(data) {

View File

@ -72,12 +72,24 @@ var messageStore = Reflux.createStore({
}, },
inform: function(message, server, channel) { inform: function(message, server, channel) {
addMessage({ if (_.isArray(message)) {
server: server, _.each(message, (msg) => {
to: channel, addMessage({
message: message, server: server,
type: 'info' to: channel,
}, channel || server); message: msg,
type: 'info'
}, channel || server);
});
} else {
addMessage({
server: server,
to: channel,
message: message,
type: 'info'
}, channel || server);
}
this.trigger(messages); this.trigger(messages);
}, },