Add /raw command

This commit is contained in:
Ken-Håvard Lieng 2016-01-27 20:48:47 +01:00
parent d51b5a35fd
commit b50a4a1068
6 changed files with 46 additions and 11 deletions

View file

@ -15,6 +15,7 @@ export const JOIN = 'JOIN';
export const KICK = 'KICK';
export const OPEN_PRIVATE_CHAT = 'OPEN_PRIVATE_CHAT';
export const PART = 'PART';
export const RAW = 'RAW';
export const SEARCH_MESSAGES = 'SEARCH_MESSAGES';
export const SELECT_TAB = 'SELECT_TAB';
export const SEND_MESSAGE = 'SEND_MESSAGE';
@ -34,8 +35,8 @@ export const SOCKET_NICK = 'SOCKET_NICK';
export const SOCKET_PART = 'SOCKET_PART';
export const SOCKET_PM = 'SOCKET_PM';
export const SOCKET_QUIT = 'SOCKET_QUIT';
export const SOCKET_SERVERS = 'SOCKET_SERVERS';
export const SOCKET_SEARCH = 'SOCKET_SEARCH';
export const SOCKET_SERVERS = 'SOCKET_SERVERS';
export const SOCKET_TOPIC = 'SOCKET_TOPIC';
export const SOCKET_USERS = 'SOCKET_USERS';
export const TAB_HISTORY_POP = 'TAB_HISTORY_POP';

View file

@ -75,3 +75,15 @@ export function runCommand(command, channel, server) {
server
};
}
export function raw(message, server) {
return {
type: actions.RAW,
message,
server,
socket: {
type: 'raw',
data: { message, server }
}
};
}

View file

@ -4,7 +4,7 @@ import { COMMAND } from './actions';
import { setNick, disconnect, whois, away } from './actions/server';
import { join, part, invite, kick } from './actions/channel';
import { select } from './actions/tab';
import { sendMessage, addMessage, inform } from './actions/message';
import { sendMessage, addMessage, inform, raw } from './actions/message';
const help = [
'/join <channel> - Join a channel',
@ -18,7 +18,8 @@ const help = [
'/invite <user> [channel] - Invite user to the current or specified channel',
'/kick <user> - Kick user from the current channel',
'/whois <user> - Get information about user',
'/away [message] - Set or clear away message'
'/away [message] - Set or clear away message',
'/raw [message] - Send raw IRC message to the current server'
].map(_.escape);
export default createCommandMiddleware(COMMAND, {
@ -102,6 +103,12 @@ export default createCommandMiddleware(COMMAND, {
dispatch(away(message, server));
},
raw({ dispatch, server }, ...message) {
if (message) {
dispatch(raw(message.join(' '), server));
}
},
help({ dispatch, server, channel }) {
dispatch(inform(help, server, channel));
}