|
@@ -49,6 +49,15 @@ func RplNick(client *Client, newNick string) Reply {
|
49
|
49
|
return NewReply(client, RPL_NICK, ":"+newNick)
|
50
|
50
|
}
|
51
|
51
|
|
|
52
|
+func RplInviteMsg(channel *Channel, inviter *Client) Reply {
|
|
53
|
+ return NewReply(inviter, RPL_INVITE, channel.name)
|
|
54
|
+}
|
|
55
|
+
|
|
56
|
+func RplInvitingMsg(channel *Channel, invitee *Client) Reply {
|
|
57
|
+ return NewReply(channel.server, RPL_INVITING,
|
|
58
|
+ fmt.Sprintf("%s %s", channel.name, invitee.Nick()))
|
|
59
|
+}
|
|
60
|
+
|
52
|
61
|
func RplPrivMsgChannel(channel *Channel, source *Client, message string) Reply {
|
53
|
62
|
return &ChannelReply{NewReply(source, RPL_PRIVMSG, ":"+message), channel}
|
54
|
63
|
}
|
|
@@ -64,19 +73,23 @@ func RplPart(channel *Channel, client *Client, message string) Reply {
|
64
|
73
|
// Server Info
|
65
|
74
|
|
66
|
75
|
func RplWelcome(source Identifier, client *Client) Reply {
|
67
|
|
- return NewReply(source, RPL_WELCOME, "Welcome to the Internet Relay Network "+client.Id())
|
|
76
|
+ return NewReply(source, RPL_WELCOME,
|
|
77
|
+ "Welcome to the Internet Relay Network "+client.Id())
|
68
|
78
|
}
|
69
|
79
|
|
70
|
80
|
func RplYourHost(server *Server, target *Client) Reply {
|
71
|
|
- return NewReply(server, RPL_YOURHOST, fmt.Sprintf("Your host is %s, running version %s", server.hostname, VERSION))
|
|
81
|
+ return NewReply(server, RPL_YOURHOST,
|
|
82
|
+ fmt.Sprintf("Your host is %s, running version %s", server.hostname, VERSION))
|
72
|
83
|
}
|
73
|
84
|
|
74
|
85
|
func RplCreated(server *Server) Reply {
|
75
|
|
- return NewReply(server, RPL_CREATED, "This server was created "+server.ctime.Format(time.RFC1123))
|
|
86
|
+ return NewReply(server, RPL_CREATED,
|
|
87
|
+ "This server was created "+server.ctime.Format(time.RFC1123))
|
76
|
88
|
}
|
77
|
89
|
|
78
|
90
|
func RplMyInfo(server *Server) Reply {
|
79
|
|
- return NewReply(server, RPL_MYINFO, fmt.Sprintf("%s %s i ik", server.name, VERSION))
|
|
91
|
+ return NewReply(server, RPL_MYINFO,
|
|
92
|
+ fmt.Sprintf("%s %s i ik", server.name, VERSION))
|
80
|
93
|
}
|
81
|
94
|
|
82
|
95
|
func RplUModeIs(server *Server, client *Client) Reply {
|
|
@@ -86,20 +99,24 @@ func RplUModeIs(server *Server, client *Client) Reply {
|
86
|
99
|
// channel operations
|
87
|
100
|
|
88
|
101
|
func RplNoTopic(channel *Channel) Reply {
|
89
|
|
- return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC, channel.name+" :No topic is set"), channel}
|
|
102
|
+ return &ChannelReply{NewReply(channel.server, RPL_NOTOPIC,
|
|
103
|
+ channel.name+" :No topic is set"), channel}
|
90
|
104
|
}
|
91
|
105
|
|
92
|
106
|
func RplTopic(channel *Channel) Reply {
|
93
|
|
- return &ChannelReply{NewReply(channel.server, RPL_TOPIC, fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
|
|
107
|
+ return &ChannelReply{NewReply(channel.server, RPL_TOPIC,
|
|
108
|
+ fmt.Sprintf("%s :%s", channel.name, channel.topic)), channel}
|
94
|
109
|
}
|
95
|
110
|
|
96
|
111
|
func RplNamReply(channel *Channel) Reply {
|
97
|
112
|
// TODO multiple names and splitting based on message size
|
98
|
|
- return NewReply(channel.server, RPL_NAMREPLY, fmt.Sprintf("= %s :%s", channel.name, strings.Join(channel.Nicks(), " ")))
|
|
113
|
+ return NewReply(channel.server, RPL_NAMREPLY,
|
|
114
|
+ fmt.Sprintf("= %s :%s", channel.name, strings.Join(channel.Nicks(), " ")))
|
99
|
115
|
}
|
100
|
116
|
|
101
|
117
|
func RplEndOfNames(source Identifier) Reply {
|
102
|
|
- return NewReply(source, RPL_ENDOFNAMES, ":End of NAMES list")
|
|
118
|
+ return NewReply(source, RPL_ENDOFNAMES,
|
|
119
|
+ ":End of NAMES list")
|
103
|
120
|
}
|
104
|
121
|
|
105
|
122
|
func RplPong(server *Server) Reply {
|
|
@@ -109,41 +126,56 @@ func RplPong(server *Server) Reply {
|
109
|
126
|
// errors
|
110
|
127
|
|
111
|
128
|
func ErrAlreadyRegistered(source Identifier) Reply {
|
112
|
|
- return NewReply(source, ERR_ALREADYREGISTRED, ":You may not reregister")
|
|
129
|
+ return NewReply(source, ERR_ALREADYREGISTRED,
|
|
130
|
+ ":You may not reregister")
|
113
|
131
|
}
|
114
|
132
|
|
115
|
133
|
func ErrNickNameInUse(source Identifier, nick string) Reply {
|
116
|
|
- return NewReply(source, ERR_NICKNAMEINUSE, nick+" :Nickname is already in use")
|
|
134
|
+ return NewReply(source, ERR_NICKNAMEINUSE,
|
|
135
|
+ nick+" :Nickname is already in use")
|
117
|
136
|
}
|
118
|
137
|
|
119
|
138
|
func ErrUnknownCommand(source Identifier, command string) Reply {
|
120
|
|
- return NewReply(source, ERR_UNKNOWNCOMMAND, command+" :Unknown command")
|
|
139
|
+ return NewReply(source, ERR_UNKNOWNCOMMAND,
|
|
140
|
+ command+" :Unknown command")
|
121
|
141
|
}
|
122
|
142
|
|
123
|
143
|
func ErrUsersDontMatch(source Identifier) Reply {
|
124
|
|
- return NewReply(source, ERR_USERSDONTMATCH, ":Cannot change mode for other users")
|
|
144
|
+ return NewReply(source, ERR_USERSDONTMATCH,
|
|
145
|
+ ":Cannot change mode for other users")
|
125
|
146
|
}
|
126
|
147
|
|
127
|
148
|
func ErrNeedMoreParams(source Identifier, command string) Reply {
|
128
|
|
- return NewReply(source, ERR_NEEDMOREPARAMS, command+"%s :Not enough parameters")
|
|
149
|
+ return NewReply(source, ERR_NEEDMOREPARAMS,
|
|
150
|
+ command+"%s :Not enough parameters")
|
129
|
151
|
}
|
130
|
152
|
|
131
|
153
|
func ErrNoSuchChannel(source Identifier, channel string) Reply {
|
132
|
|
- return NewReply(source, ERR_NOSUCHCHANNEL, channel+" :No such channel")
|
|
154
|
+ return NewReply(source, ERR_NOSUCHCHANNEL,
|
|
155
|
+ channel+" :No such channel")
|
|
156
|
+}
|
|
157
|
+
|
|
158
|
+func ErrUserOnChannel(channel *Channel, member *Client) Reply {
|
|
159
|
+ return NewReply(channel.server, ERR_USERONCHANNEL,
|
|
160
|
+ fmt.Sprintf("%s %s :is already on channel", member.nick, channel.name))
|
133
|
161
|
}
|
134
|
162
|
|
135
|
163
|
func ErrNotOnChannel(channel *Channel) Reply {
|
136
|
|
- return NewReply(channel.server, ERR_NOTONCHANNEL, channel.name+" :You're not on that channel")
|
|
164
|
+ return NewReply(channel.server, ERR_NOTONCHANNEL,
|
|
165
|
+ channel.name+" :You're not on that channel")
|
137
|
166
|
}
|
138
|
167
|
|
139
|
168
|
func ErrInviteOnlyChannel(channel *Channel) Reply {
|
140
|
|
- return NewReply(channel.server, ERR_INVITEONLYCHANNEL, channel.name+" :Cannot join channel (+i)")
|
|
169
|
+ return NewReply(channel.server, ERR_INVITEONLYCHAN,
|
|
170
|
+ channel.name+" :Cannot join channel (+i)")
|
141
|
171
|
}
|
142
|
172
|
|
143
|
173
|
func ErrBadChannelKey(channel *Channel) Reply {
|
144
|
|
- return NewReply(channel.server, ERR_BADCHANNELKEY, channel.name+" :Cannot join channel (+k)")
|
|
174
|
+ return NewReply(channel.server, ERR_BADCHANNELKEY,
|
|
175
|
+ channel.name+" :Cannot join channel (+k)")
|
145
|
176
|
}
|
146
|
177
|
|
147
|
178
|
func ErrNoSuchNick(source Identifier, nick string) Reply {
|
148
|
|
- return NewReply(source, ERR_NOSUCHNICK, nick+" :No such nick/channel")
|
|
179
|
+ return NewReply(source, ERR_NOSUCHNICK,
|
|
180
|
+ nick+" :No such nick/channel")
|
149
|
181
|
}
|