Add /away

This commit is contained in:
khlieng 2015-02-21 13:06:05 +01:00
parent ed9a1c3216
commit ccb0149b3d
6 changed files with 29 additions and 5 deletions

View File

@ -6,6 +6,7 @@ var serverActions = Reflux.createActions([
'connect', 'connect',
'disconnect', 'disconnect',
'whois', 'whois',
'away',
'setNick', 'setNick',
'load' 'load'
]); ]);
@ -30,6 +31,10 @@ serverActions.whois.preEmit = (user, server) => {
socket.send('whois', { server, user }); socket.send('whois', { server, user });
}; };
serverActions.away.preEmit = (message, server) => {
socket.send('away', { server, message });
};
serverActions.setNick.preEmit = (nick, server) => { serverActions.setNick.preEmit = (nick, server) => {
socket.send('nick', { socket.send('nick', {
server, server,

View File

@ -84,5 +84,9 @@ messageActions.command.listen(function(line, channel, server) {
serverActions.whois(params[1], server); serverActions.whois(params[1], server);
} }
break; break;
case 'away':
serverActions.away(params[1], server);
break;
} }
}); });

6
irc.go
View File

@ -30,6 +30,8 @@ const (
RPL_LUSERCHANNELS = "254" RPL_LUSERCHANNELS = "254"
RPL_LUSERME = "255" RPL_LUSERME = "255"
RPL_AWAY = "301"
RPL_WHOISUSER = "311" RPL_WHOISUSER = "311"
RPL_WHOISSERVER = "312" RPL_WHOISSERVER = "312"
RPL_WHOISOPERATOR = "313" RPL_WHOISOPERATOR = "313"
@ -195,6 +197,10 @@ func (i *IRC) Whois(nick string) {
i.Write("WHOIS " + nick) i.Write("WHOIS " + nick)
} }
func (i *IRC) Away(message string) {
i.Write("AWAY :" + message)
}
func (i *IRC) GetNick() string { func (i *IRC) GetNick() string {
i.nickLock.Lock() i.nickLock.Lock()
defer i.nickLock.Unlock() defer i.nickLock.Unlock()

View File

@ -106,6 +106,11 @@ type WhoisReply struct {
Channels []string `json:"channels"` Channels []string `json:"channels"`
} }
type Away struct {
Server string `json:"server"`
Message string `json:"message"`
}
type Error struct { type Error struct {
Server string `json:"server"` Server string `json:"server"`
Message string `json:"message"` Message string `json:"message"`

View File

@ -141,11 +141,6 @@ func handleMessages(irc *IRC, session *Session) {
case RPL_NAMREPLY: case RPL_NAMREPLY:
users := strings.Split(msg.Trailing, " ") users := strings.Split(msg.Trailing, " ")
/*for i, user := range users {
users[i] = strings.TrimLeft(user, "@+")
}*/
userBuffer := userBuffers[msg.Params[2]] userBuffer := userBuffers[msg.Params[2]]
userBuffers[msg.Params[2]] = append(userBuffer, users...) userBuffers[msg.Params[2]] = append(userBuffer, users...)

View File

@ -183,6 +183,15 @@ func handleWS(ws *websocket.Conn) {
if irc, ok := session.getIRC(data.Server); ok { if irc, ok := session.getIRC(data.Server); ok {
irc.Whois(data.User) irc.Whois(data.User)
} }
case "away":
var data Away
json.Unmarshal(req.Request, &data)
if irc, ok := session.getIRC(data.Server); ok {
irc.Away(data.Message)
}
} }
} }
} }