3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +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
import (
"sort"
)
type Channel struct {
name string
key string
@ -44,7 +40,6 @@ func (ch *Channel) Nicks() []string {
nicks[i] = member.Nick()
i++
}
sort.Strings(nicks)
return nicks
}

View File

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