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])
|
c.outputChan <- fmt.Sprintf(":%s 371 %s :%s", c.server.name, c.nick, args[0])
|
||||||
case rplVersion:
|
case rplVersion:
|
||||||
c.outputChan <- fmt.Sprintf(":%s 351 %s %s", c.server.name, c.nick, args[0])
|
c.outputChan <- fmt.Sprintf(":%s 351 %s %s", c.server.name, c.nick, args[0])
|
||||||
case rplMOTD:
|
case rplMOTDStart:
|
||||||
motd := args[0]
|
|
||||||
c.outputChan <- fmt.Sprintf(":%s 375 %s :- Message of the day - ", c.server.name, c.nick)
|
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) {
|
case rplMOTD:
|
||||||
if size <= 80 {
|
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, args[0])
|
||||||
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, motd)
|
case rplEndOfMOTD:
|
||||||
break
|
|
||||||
}
|
|
||||||
c.outputChan <- fmt.Sprintf(":%s 372 %s :- %s", c.server.name, c.nick, motd[:80])
|
|
||||||
motd = motd[80:]
|
|
||||||
}
|
|
||||||
c.outputChan <- fmt.Sprintf(":%s 376 %s :End of MOTD Command", c.server.name, c.nick)
|
c.outputChan <- fmt.Sprintf(":%s 376 %s :End of MOTD Command", c.server.name, c.nick)
|
||||||
case rplPong:
|
case rplPong:
|
||||||
c.outputChan <- fmt.Sprintf(":%s PONG %s %s", c.server.name, c.nick, c.server.name)
|
c.outputChan <- fmt.Sprintf(":%s PONG %s %s", c.server.name, c.nick, c.server.name)
|
||||||
|
@ -126,7 +126,9 @@ const (
|
|||||||
rplKick
|
rplKick
|
||||||
rplInfo
|
rplInfo
|
||||||
rplVersion
|
rplVersion
|
||||||
|
rplMOTDStart
|
||||||
rplMOTD
|
rplMOTD
|
||||||
|
rplEndOfMOTD
|
||||||
rplPong
|
rplPong
|
||||||
errMoreArgs
|
errMoreArgs
|
||||||
errNoNick
|
errNoNick
|
||||||
|
11
server.go
11
server.go
@ -53,7 +53,16 @@ func (s *Server) handleEvent(e Event) {
|
|||||||
switch e.event {
|
switch e.event {
|
||||||
case connected:
|
case connected:
|
||||||
//Client 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:
|
case disconnected:
|
||||||
//Client disconnected
|
//Client disconnected
|
||||||
case command:
|
case command:
|
||||||
|
Loading…
Reference in New Issue
Block a user