summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Matveev <stargrave@stargrave.org>2014-11-14 23:26:32 +0300
committerSergey Matveev <stargrave@stargrave.org>2014-11-14 23:26:32 +0300
commit8702ace766119effc2c2ec4afa284bec6f24c4da (patch)
tree955e32ab3cd5da7a1db22c6c7ded79536e58f21c
parent990937d451208b0299246c46dd29adf7a35f97ee (diff)
downloadgoircd-8702ace766119effc2c2ec4afa284bec6f24c4da.tar.xz
Add AWAY command support1.1
-rw-r--r--README2
-rw-r--r--client.go1
-rw-r--r--daemon.go15
3 files changed, 16 insertions, 2 deletions
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
}
}