Browse Source

Fix a few redundancies in replies.

tags/v0.1.0
Jeremy Latt 11 years ago
parent
commit
24b39fe847
2 changed files with 18 additions and 25 deletions
  1. 0
    5
      src/irc/channel.go
  2. 18
    20
      src/irc/reply.go

+ 0
- 5
src/irc/channel.go View File

@@ -1,9 +1,5 @@
1 1
 package irc
2 2
 
3
-import (
4
-	"sort"
5
-)
6
-
7 3
 type Channel struct {
8 4
 	name       string
9 5
 	key        string
@@ -44,7 +40,6 @@ func (ch *Channel) Nicks() []string {
44 40
 		nicks[i] = member.Nick()
45 41
 		i++
46 42
 	}
47
-	sort.Strings(nicks)
48 43
 	return nicks
49 44
 }
50 45
 

+ 18
- 20
src/irc/reply.go View File

@@ -58,18 +58,6 @@ func RplInvitingMsg(channel *Channel, invitee *Client) Reply {
58 58
 		fmt.Sprintf("%s %s", channel.name, invitee.Nick()))
59 59
 }
60 60
 
61
-func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
62
-	return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
63
-}
64
-
65
-func RplJoin(channel *Channel, client *Client) Reply {
66
-	return &ChannelReply{NewReply(client, RPL_JOIN, channel.name), channel}
67
-}
68
-
69
-func RplPart(channel *Channel, client *Client, message string) Reply {
70
-	return &ChannelReply{NewReply(client, RPL_PART, ":"+message), channel}
71
-}
72
-
73 61
 // Server Info
74 62
 
75 63
 func RplWelcome(source Identifier, client *Client) Reply {
@@ -98,16 +86,28 @@ func RplUModeIs(server *Server, client *Client) Reply {
98 86
 
99 87
 // channel operations
100 88
 
89
+func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
90
+	return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
91
+}
92
+
93
+func RplJoin(channel *Channel, client *Client) Reply {
94
+	return &ChannelReply{NewReply(client, RPL_JOIN, ""), channel}
95
+}
96
+
97
+func RplPart(channel *Channel, client *Client, message string) Reply {
98
+	return &ChannelReply{NewReply(client, RPL_PART, ":"+message), channel}
99
+}
100
+
101 101
 func RplNoTopic(channel *Channel) Reply {
102
-	return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC,
103
-		channel.name+" :No topic is set"), channel}
102
+	return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC, ":No topic is set"), channel}
104 103
 }
105 104
 
106 105
 func RplTopic(channel *Channel) Reply {
107
-	return &ChannelReply{NewReply(channel.server, RPL_TOPIC,
108
-		fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
106
+	return &ChannelReply{NewReply(channel.server, RPL_TOPIC, ":"+channel.topic), channel}
109 107
 }
110 108
 
109
+// server info
110
+
111 111
 func RplNamReply(channel *Channel) Reply {
112 112
 	// TODO multiple names and splitting based on message size
113 113
 	return NewReply(channel.server, RPL_NAMREPLY,
@@ -115,8 +115,7 @@ func RplNamReply(channel *Channel) Reply {
115 115
 }
116 116
 
117 117
 func RplEndOfNames(source Identifier) Reply {
118
-	return NewReply(source, RPL_ENDOFNAMES,
119
-		":End of NAMES list")
118
+	return NewReply(source, RPL_ENDOFNAMES, ":End of NAMES list")
120 119
 }
121 120
 
122 121
 func RplPong(server *Server) Reply {
@@ -126,8 +125,7 @@ func RplPong(server *Server) Reply {
126 125
 // errors
127 126
 
128 127
 func ErrAlreadyRegistered(source Identifier) Reply {
129
-	return NewReply(source, ERR_ALREADYREGISTRED,
130
-		":You may not reregister")
128
+	return NewReply(source, ERR_ALREADYREGISTRED, ":You may not reregister")
131 129
 }
132 130
 
133 131
 func ErrNickNameInUse(source Identifier, nick string) Reply {

Loading…
Cancel
Save