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',
'disconnect',
'whois',
'away',
'setNick',
'load'
]);
@ -30,6 +31,10 @@ serverActions.whois.preEmit = (user, server) => {
socket.send('whois', { server, user });
};
serverActions.away.preEmit = (message, server) => {
socket.send('away', { server, message });
};
serverActions.setNick.preEmit = (nick, server) => {
socket.send('nick', {
server,

View File

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

6
irc.go
View File

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

View File

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

View File

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