diff --git a/README b/README index f2b3317..9b4d8cf 100644 --- a/README +++ b/README @@ -40,7 +40,7 @@ SUPPORTED IRC COMMANDS * PASS/NICK/USER during registration workflow * PING/PONGs * NOTICE/PRIVMSG -* MOTD, LUSERS, WHO, WHOIS, VERSION, QUIT +* AWAY, MOTD, LUSERS, WHO, WHOIS, VERSION, QUIT * LIST, JOIN, TOPIC, +k/-k channel MODE USAGE diff --git a/client.go b/client.go index 3637d49..1b4a9c3 100644 --- a/client.go +++ b/client.go @@ -38,6 +38,7 @@ type Client struct { username string realname string password string + away *string } type ClientAlivenessState struct { diff --git a/daemon.go b/daemon.go index 9b0d77f..ed708de 100644 --- a/daemon.go +++ b/daemon.go @@ -111,6 +111,9 @@ func (daemon *Daemon) SendWhois(client *Client, nicknames []string) { } client.ReplyNicknamed("311", c.nickname, c.username, h, "*", c.realname) client.ReplyNicknamed("312", c.nickname, *daemon.hostname, *daemon.hostname) + if c.away != nil { + client.ReplyNicknamed("301", c.nickname, *c.away) + } subscriptions := []string{} for _, room := range daemon.rooms { for subscriber := range room.members { @@ -347,7 +350,14 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) { } switch command { case "AWAY": - continue + if len(cols) == 1 { + client.away = nil + client.ReplyNicknamed("305", "You are no longer marked as being away") + continue + } + msg := strings.TrimLeft(cols[1], ":") + client.away = &msg + client.ReplyNicknamed("306", "You have been marked as being away") case "JOIN": if len(cols) == 1 || len(cols[1]) < 1 { client.ReplyNotEnoughParameters("JOIN") @@ -422,6 +432,9 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) { if c.nickname == target { msg = fmt.Sprintf(":%s %s %s %s", client, command, c.nickname, cols[1]) c.Msg(msg) + if c.away != nil { + client.ReplyNicknamed("301", c.nickname, *c.away) + } break } }