Add /raw command
This commit is contained in:
parent
d51b5a35fd
commit
b50a4a1068
File diff suppressed because one or more lines are too long
@ -15,6 +15,7 @@ export const JOIN = 'JOIN';
|
|||||||
export const KICK = 'KICK';
|
export const KICK = 'KICK';
|
||||||
export const OPEN_PRIVATE_CHAT = 'OPEN_PRIVATE_CHAT';
|
export const OPEN_PRIVATE_CHAT = 'OPEN_PRIVATE_CHAT';
|
||||||
export const PART = 'PART';
|
export const PART = 'PART';
|
||||||
|
export const RAW = 'RAW';
|
||||||
export const SEARCH_MESSAGES = 'SEARCH_MESSAGES';
|
export const SEARCH_MESSAGES = 'SEARCH_MESSAGES';
|
||||||
export const SELECT_TAB = 'SELECT_TAB';
|
export const SELECT_TAB = 'SELECT_TAB';
|
||||||
export const SEND_MESSAGE = 'SEND_MESSAGE';
|
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_PART = 'SOCKET_PART';
|
||||||
export const SOCKET_PM = 'SOCKET_PM';
|
export const SOCKET_PM = 'SOCKET_PM';
|
||||||
export const SOCKET_QUIT = 'SOCKET_QUIT';
|
export const SOCKET_QUIT = 'SOCKET_QUIT';
|
||||||
export const SOCKET_SERVERS = 'SOCKET_SERVERS';
|
|
||||||
export const SOCKET_SEARCH = 'SOCKET_SEARCH';
|
export const SOCKET_SEARCH = 'SOCKET_SEARCH';
|
||||||
|
export const SOCKET_SERVERS = 'SOCKET_SERVERS';
|
||||||
export const SOCKET_TOPIC = 'SOCKET_TOPIC';
|
export const SOCKET_TOPIC = 'SOCKET_TOPIC';
|
||||||
export const SOCKET_USERS = 'SOCKET_USERS';
|
export const SOCKET_USERS = 'SOCKET_USERS';
|
||||||
export const TAB_HISTORY_POP = 'TAB_HISTORY_POP';
|
export const TAB_HISTORY_POP = 'TAB_HISTORY_POP';
|
||||||
|
@ -75,3 +75,15 @@ export function runCommand(command, channel, server) {
|
|||||||
server
|
server
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function raw(message, server) {
|
||||||
|
return {
|
||||||
|
type: actions.RAW,
|
||||||
|
message,
|
||||||
|
server,
|
||||||
|
socket: {
|
||||||
|
type: 'raw',
|
||||||
|
data: { message, server }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { COMMAND } from './actions';
|
|||||||
import { setNick, disconnect, whois, away } from './actions/server';
|
import { setNick, disconnect, whois, away } from './actions/server';
|
||||||
import { join, part, invite, kick } from './actions/channel';
|
import { join, part, invite, kick } from './actions/channel';
|
||||||
import { select } from './actions/tab';
|
import { select } from './actions/tab';
|
||||||
import { sendMessage, addMessage, inform } from './actions/message';
|
import { sendMessage, addMessage, inform, raw } from './actions/message';
|
||||||
|
|
||||||
const help = [
|
const help = [
|
||||||
'/join <channel> - Join a channel',
|
'/join <channel> - Join a channel',
|
||||||
@ -18,7 +18,8 @@ const help = [
|
|||||||
'/invite <user> [channel] - Invite user to the current or specified channel',
|
'/invite <user> [channel] - Invite user to the current or specified channel',
|
||||||
'/kick <user> - Kick user from the current channel',
|
'/kick <user> - Kick user from the current channel',
|
||||||
'/whois <user> - Get information about user',
|
'/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);
|
].map(_.escape);
|
||||||
|
|
||||||
export default createCommandMiddleware(COMMAND, {
|
export default createCommandMiddleware(COMMAND, {
|
||||||
@ -102,6 +103,12 @@ export default createCommandMiddleware(COMMAND, {
|
|||||||
dispatch(away(message, server));
|
dispatch(away(message, server));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
raw({ dispatch, server }, ...message) {
|
||||||
|
if (message) {
|
||||||
|
dispatch(raw(message.join(' '), server));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
help({ dispatch, server, channel }) {
|
help({ dispatch, server, channel }) {
|
||||||
dispatch(inform(help, server, channel));
|
dispatch(inform(help, server, channel));
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,11 @@ type Away struct {
|
|||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Raw struct {
|
||||||
|
Server string `json:"server"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
type SearchRequest struct {
|
type SearchRequest struct {
|
||||||
Server string `json:"server"`
|
Server string `json:"server"`
|
||||||
Channel string `json:"channel"`
|
Channel string `json:"channel"`
|
||||||
|
@ -217,6 +217,15 @@ func (h *wsHandler) away(b []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *wsHandler) raw(b []byte) {
|
||||||
|
var data Raw
|
||||||
|
json.Unmarshal(b, &data)
|
||||||
|
|
||||||
|
if i, ok := h.session.getIRC(data.Server); ok {
|
||||||
|
i.Write(data.Message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (h *wsHandler) search(b []byte) {
|
func (h *wsHandler) search(b []byte) {
|
||||||
go func() {
|
go func() {
|
||||||
var data SearchRequest
|
var data SearchRequest
|
||||||
@ -261,6 +270,7 @@ func (h *wsHandler) initHandlers() {
|
|||||||
"kick": h.kick,
|
"kick": h.kick,
|
||||||
"whois": h.whois,
|
"whois": h.whois,
|
||||||
"away": h.away,
|
"away": h.away,
|
||||||
|
"raw": h.raw,
|
||||||
"search": h.search,
|
"search": h.search,
|
||||||
"cert": h.cert,
|
"cert": h.cert,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user