mirror of
https://github.com/ergochat/ergo.git
synced 2025-02-16 21:50:39 +01:00
simplify Replier
This commit is contained in:
parent
ac186a0669
commit
33b1e6c582
@ -64,10 +64,8 @@ func (channel *Channel) Command(command ChannelCommand) {
|
|||||||
channel.commands <- command
|
channel.commands <- command
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) Reply(replies ...Reply) {
|
func (channel *Channel) Reply(reply Reply) {
|
||||||
for _, reply := range replies {
|
channel.replies <- reply
|
||||||
channel.replies <- reply
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) receiveCommands(commands <-chan ChannelCommand) {
|
func (channel *Channel) receiveCommands(commands <-chan ChannelCommand) {
|
||||||
|
@ -181,16 +181,14 @@ func (client *Client) Destroy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Reply(replies ...Reply) {
|
func (client *Client) Reply(reply Reply) {
|
||||||
for _, reply := range replies {
|
if client.replies == nil {
|
||||||
if client.replies == nil {
|
if DEBUG_CLIENT {
|
||||||
if DEBUG_CLIENT {
|
log.Printf("%s dropped %s", client, reply)
|
||||||
log.Printf("%s dropped %s", client, reply)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
client.replies <- reply
|
return
|
||||||
}
|
}
|
||||||
|
client.replies <- reply
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) HasNick() bool {
|
func (client *Client) HasNick() bool {
|
||||||
|
@ -171,11 +171,10 @@ func (s *Server) tryRegister(c *Client) {
|
|||||||
if c.HasNick() && c.HasUsername() {
|
if c.HasNick() && c.HasUsername() {
|
||||||
c.phase = Normal
|
c.phase = Normal
|
||||||
c.loginTimer.Stop()
|
c.loginTimer.Stop()
|
||||||
c.Reply(
|
c.Reply(RplWelcome(s, c))
|
||||||
RplWelcome(s, c),
|
c.Reply(RplYourHost(s))
|
||||||
RplYourHost(s),
|
c.Reply(RplCreated(s))
|
||||||
RplCreated(s),
|
c.Reply(RplMyInfo(s))
|
||||||
RplMyInfo(s))
|
|
||||||
s.MOTD(c)
|
s.MOTD(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ type Identifier interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Replier interface {
|
type Replier interface {
|
||||||
Reply(...Reply)
|
Reply(Reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Reply interface {
|
type Reply interface {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user