Merge pull request #5 from edjsu/split-rplMOTD
Split rplMOTD into rplMOTDStart, rplMOTD and rplEndOfMOTD
This commit is contained in:
commit
9cbea548a3
14
client.go
14
client.go
@ -183,17 +183,11 @@ func (c *Client) reply(code replyCode, args ...string) {
|
||||
c.outputChan <- fmt.Sprintf(":%s 371 %s :%s", c.server.name, c.nick, args[0])
|
||||
case rplVersion:
|
||||
c.outputChan <- fmt.Sprintf(":%s 351 %s %s", c.server.name, c.nick, args[0])
|
||||
case rplMOTD:
|
||||
motd := args[0]
|
||||
case rplMOTDStart:
|
||||
c.outputChan <- fmt.Sprintf(":%s 375 %s :- Message of the day - ", c.server.name, c.nick)
|
||||
for size := len(motd); size > 0; size = len(motd) {
|
||||
if size <= 80 {
|
||||
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, motd)
|
||||
break
|
||||
}
|
||||
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, motd[:80])
|
||||
motd = motd[80:]
|
||||
}
|
||||
case rplMOTD:
|
||||
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, args[0])
|
||||
case rplEndOfMOTD:
|
||||
c.outputChan <- fmt.Sprintf(":%s 376 %s :End of MOTD Command", c.server.name, c.nick)
|
||||
case rplPong:
|
||||
c.outputChan <- fmt.Sprintf(":%s PONG %s %s", c.server.name, c.nick, c.server.name)
|
||||
|
@ -126,7 +126,9 @@ const (
|
||||
rplKick
|
||||
rplInfo
|
||||
rplVersion
|
||||
rplMOTDStart
|
||||
rplMOTD
|
||||
rplEndOfMOTD
|
||||
rplPong
|
||||
errMoreArgs
|
||||
errNoNick
|
||||
|
11
server.go
11
server.go
@ -53,7 +53,16 @@ func (s *Server) handleEvent(e Event) {
|
||||
switch e.event {
|
||||
case connected:
|
||||
//Client connected
|
||||
e.client.reply(rplMOTD, s.motd)
|
||||
e.client.reply(rplMOTDStart)
|
||||
motd := s.motd
|
||||
for len(motd) > 80 {
|
||||
e.client.reply(rplMOTD, motd[:80])
|
||||
motd = motd[80:]
|
||||
}
|
||||
if len(motd) > 0 {
|
||||
e.client.reply(rplMOTD, motd)
|
||||
}
|
||||
e.client.reply(rplEndOfMOTD)
|
||||
case disconnected:
|
||||
//Client disconnected
|
||||
case command:
|
||||
|
Loading…
Reference in New Issue
Block a user