3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00

Fix a few redundancies in replies.

This commit is contained in:
Jeremy Latt 2012-12-09 15:20:21 -08:00
parent ae2444c423
commit 24b39fe847
2 changed files with 18 additions and 25 deletions

View File

@ -1,9 +1,5 @@
package irc package irc
import (
"sort"
)
type Channel struct { type Channel struct {
name string name string
key string key string
@ -44,7 +40,6 @@ func (ch *Channel) Nicks() []string {
nicks[i] = member.Nick() nicks[i] = member.Nick()
i++ i++
} }
sort.Strings(nicks)
return nicks return nicks
} }

View File

@ -58,18 +58,6 @@ func RplInvitingMsg(channel *Channel, invitee *Client) Reply {
fmt.Sprintf("%s %s", channel.name, invitee.Nick())) fmt.Sprintf("%s %s", channel.name, invitee.Nick()))
} }
func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
}
func RplJoin(channel *Channel, client *Client) Reply {
return &ChannelReply{NewReply(client, RPL_JOIN, channel.name), channel}
}
func RplPart(channel *Channel, client *Client, message string) Reply {
return &ChannelReply{NewReply(client, RPL_PART, ":"+message), channel}
}
// Server Info // Server Info
func RplWelcome(source Identifier, client *Client) Reply { func RplWelcome(source Identifier, client *Client) Reply {
@ -98,16 +86,28 @@ func RplUModeIs(server *Server, client *Client) Reply {
// channel operations // channel operations
func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
}
func RplJoin(channel *Channel, client *Client) Reply {
return &ChannelReply{NewReply(client, RPL_JOIN, ""), channel}
}
func RplPart(channel *Channel, client *Client, message string) Reply {
return &ChannelReply{NewReply(client, RPL_PART, ":"+message), channel}
}
func RplNoTopic(channel *Channel) Reply { func RplNoTopic(channel *Channel) Reply {
return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC, return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC, ":No topic is set"), channel}
channel.name+" :No topic is set"), channel}
} }
func RplTopic(channel *Channel) Reply { func RplTopic(channel *Channel) Reply {
return &ChannelReply{NewReply(channel.server, RPL_TOPIC, return &ChannelReply{NewReply(channel.server, RPL_TOPIC, ":"+channel.topic), channel}
fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
} }
// server info
func RplNamReply(channel *Channel) Reply { func RplNamReply(channel *Channel) Reply {
// TODO multiple names and splitting based on message size // TODO multiple names and splitting based on message size
return NewReply(channel.server, RPL_NAMREPLY, return NewReply(channel.server, RPL_NAMREPLY,
@ -115,8 +115,7 @@ func RplNamReply(channel *Channel) Reply {
} }
func RplEndOfNames(source Identifier) Reply { func RplEndOfNames(source Identifier) Reply {
return NewReply(source, RPL_ENDOFNAMES, return NewReply(source, RPL_ENDOFNAMES, ":End of NAMES list")
":End of NAMES list")
} }
func RplPong(server *Server) Reply { func RplPong(server *Server) Reply {
@ -126,8 +125,7 @@ func RplPong(server *Server) Reply {
// errors // errors
func ErrAlreadyRegistered(source Identifier) Reply { func ErrAlreadyRegistered(source Identifier) Reply {
return NewReply(source, ERR_ALREADYREGISTRED, return NewReply(source, ERR_ALREADYREGISTRED, ":You may not reregister")
":You may not reregister")
} }
func ErrNickNameInUse(source Identifier, nick string) Reply { func ErrNickNameInUse(source Identifier, nick string) Reply {