Add AWAY command support
This commit is contained in:
parent
990937d451
commit
8702ace766
2
README
2
README
@ -40,7 +40,7 @@ SUPPORTED IRC COMMANDS
|
|||||||
* PASS/NICK/USER during registration workflow
|
* PASS/NICK/USER during registration workflow
|
||||||
* PING/PONGs
|
* PING/PONGs
|
||||||
* NOTICE/PRIVMSG
|
* NOTICE/PRIVMSG
|
||||||
* MOTD, LUSERS, WHO, WHOIS, VERSION, QUIT
|
* AWAY, MOTD, LUSERS, WHO, WHOIS, VERSION, QUIT
|
||||||
* LIST, JOIN, TOPIC, +k/-k channel MODE
|
* LIST, JOIN, TOPIC, +k/-k channel MODE
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
|
@ -38,6 +38,7 @@ type Client struct {
|
|||||||
username string
|
username string
|
||||||
realname string
|
realname string
|
||||||
password string
|
password string
|
||||||
|
away *string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientAlivenessState struct {
|
type ClientAlivenessState struct {
|
||||||
|
13
daemon.go
13
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("311", c.nickname, c.username, h, "*", c.realname)
|
||||||
client.ReplyNicknamed("312", c.nickname, *daemon.hostname, *daemon.hostname)
|
client.ReplyNicknamed("312", c.nickname, *daemon.hostname, *daemon.hostname)
|
||||||
|
if c.away != nil {
|
||||||
|
client.ReplyNicknamed("301", c.nickname, *c.away)
|
||||||
|
}
|
||||||
subscriptions := []string{}
|
subscriptions := []string{}
|
||||||
for _, room := range daemon.rooms {
|
for _, room := range daemon.rooms {
|
||||||
for subscriber := range room.members {
|
for subscriber := range room.members {
|
||||||
@ -347,7 +350,14 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) {
|
|||||||
}
|
}
|
||||||
switch command {
|
switch command {
|
||||||
case "AWAY":
|
case "AWAY":
|
||||||
|
if len(cols) == 1 {
|
||||||
|
client.away = nil
|
||||||
|
client.ReplyNicknamed("305", "You are no longer marked as being away")
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
msg := strings.TrimLeft(cols[1], ":")
|
||||||
|
client.away = &msg
|
||||||
|
client.ReplyNicknamed("306", "You have been marked as being away")
|
||||||
case "JOIN":
|
case "JOIN":
|
||||||
if len(cols) == 1 || len(cols[1]) < 1 {
|
if len(cols) == 1 || len(cols[1]) < 1 {
|
||||||
client.ReplyNotEnoughParameters("JOIN")
|
client.ReplyNotEnoughParameters("JOIN")
|
||||||
@ -422,6 +432,9 @@ func (daemon *Daemon) Processor(events <-chan ClientEvent) {
|
|||||||
if c.nickname == target {
|
if c.nickname == target {
|
||||||
msg = fmt.Sprintf(":%s %s %s %s", client, command, c.nickname, cols[1])
|
msg = fmt.Sprintf(":%s %s %s %s", client, command, c.nickname, cols[1])
|
||||||
c.Msg(msg)
|
c.Msg(msg)
|
||||||
|
if c.away != nil {
|
||||||
|
client.ReplyNicknamed("301", c.nickname, *c.away)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user