|
@@ -57,6 +57,11 @@ func (server *Server) nickservNoticeHandler(client *Client, message string, rb *
|
57
|
57
|
// do nothing
|
58
|
58
|
}
|
59
|
59
|
|
|
60
|
+// send a notice from the NickServ "nick"
|
|
61
|
+func nsNotice(rb *ResponseBuffer, text string) {
|
|
62
|
+ rb.Add(nil, "NickServ", "NOTICE", rb.target.Nick(), text)
|
|
63
|
+}
|
|
64
|
+
|
60
|
65
|
// nickservPrivmsgHandler handles PRIVMSGs that NickServ receives.
|
61
|
66
|
func (server *Server) nickservPrivmsgHandler(client *Client, message string, rb *ResponseBuffer) {
|
62
|
67
|
command, params := extractParam(message)
|
|
@@ -64,7 +69,7 @@ func (server *Server) nickservPrivmsgHandler(client *Client, message string, rb
|
64
|
69
|
|
65
|
70
|
if command == "help" {
|
66
|
71
|
for _, line := range strings.Split(nickservHelp, "\n") {
|
67
|
|
- rb.Notice(line)
|
|
72
|
+ nsNotice(rb, line)
|
68
|
73
|
}
|
69
|
74
|
} else if command == "register" {
|
70
|
75
|
// get params
|
|
@@ -95,13 +100,13 @@ func (server *Server) nickservPrivmsgHandler(client *Client, message string, rb
|
95
|
100
|
nick, _ := extractParam(params)
|
96
|
101
|
server.nickservDropHandler(client, nick, true, rb)
|
97
|
102
|
} else {
|
98
|
|
- rb.Notice(client.t("Command not recognised. To see the available commands, run /NS HELP"))
|
|
103
|
+ nsNotice(rb, client.t("Command not recognised. To see the available commands, run /NS HELP"))
|
99
|
104
|
}
|
100
|
105
|
}
|
101
|
106
|
|
102
|
107
|
func (server *Server) nickservUnregisterHandler(client *Client, username string, rb *ResponseBuffer) {
|
103
|
108
|
if !server.AccountConfig().Registration.Enabled {
|
104
|
|
- rb.Notice(client.t("Account registration has been disabled"))
|
|
109
|
+ nsNotice(rb, client.t("Account registration has been disabled"))
|
105
|
110
|
return
|
106
|
111
|
}
|
107
|
112
|
|
|
@@ -109,16 +114,16 @@ func (server *Server) nickservUnregisterHandler(client *Client, username string,
|
109
|
114
|
username = client.Account()
|
110
|
115
|
}
|
111
|
116
|
if username == "" {
|
112
|
|
- rb.Notice(client.t("You're not logged into an account"))
|
|
117
|
+ nsNotice(rb, client.t("You're not logged into an account"))
|
113
|
118
|
return
|
114
|
119
|
}
|
115
|
120
|
cfname, err := CasefoldName(username)
|
116
|
121
|
if err != nil {
|
117
|
|
- rb.Notice(client.t("Invalid username"))
|
|
122
|
+ nsNotice(rb, client.t("Invalid username"))
|
118
|
123
|
return
|
119
|
124
|
}
|
120
|
125
|
if !(cfname == client.Account() || client.HasRoleCapabs("unregister")) {
|
121
|
|
- rb.Notice(client.t("Insufficient oper privs"))
|
|
126
|
+ nsNotice(rb, client.t("Insufficient oper privs"))
|
122
|
127
|
return
|
123
|
128
|
}
|
124
|
129
|
|
|
@@ -128,11 +133,11 @@ func (server *Server) nickservUnregisterHandler(client *Client, username string,
|
128
|
133
|
|
129
|
134
|
err = server.accounts.Unregister(cfname)
|
130
|
135
|
if err == errAccountDoesNotExist {
|
131
|
|
- rb.Notice(client.t(err.Error()))
|
|
136
|
+ nsNotice(rb, client.t(err.Error()))
|
132
|
137
|
} else if err != nil {
|
133
|
|
- rb.Notice(client.t("Error while unregistering account"))
|
|
138
|
+ nsNotice(rb, client.t("Error while unregistering account"))
|
134
|
139
|
} else {
|
135
|
|
- rb.Notice(fmt.Sprintf(client.t("Successfully unregistered account %s"), cfname))
|
|
140
|
+ nsNotice(rb, fmt.Sprintf(client.t("Successfully unregistered account %s"), cfname))
|
136
|
141
|
}
|
137
|
142
|
}
|
138
|
143
|
|
|
@@ -147,7 +152,7 @@ func (server *Server) nickservVerifyHandler(client *Client, username string, cod
|
147
|
152
|
}
|
148
|
153
|
|
149
|
154
|
if errorMessage != "" {
|
150
|
|
- rb.Notice(client.t(errorMessage))
|
|
155
|
+ nsNotice(rb, client.t(errorMessage))
|
151
|
156
|
return
|
152
|
157
|
}
|
153
|
158
|
|
|
@@ -156,18 +161,18 @@ func (server *Server) nickservVerifyHandler(client *Client, username string, cod
|
156
|
161
|
|
157
|
162
|
func (server *Server) nickservRegisterHandler(client *Client, username, email, passphrase string, rb *ResponseBuffer) {
|
158
|
163
|
if !server.AccountConfig().Registration.Enabled {
|
159
|
|
- rb.Notice(client.t("Account registration has been disabled"))
|
|
164
|
+ nsNotice(rb, client.t("Account registration has been disabled"))
|
160
|
165
|
return
|
161
|
166
|
}
|
162
|
167
|
|
163
|
168
|
if username == "" {
|
164
|
|
- rb.Notice(client.t("No username supplied"))
|
|
169
|
+ nsNotice(rb, client.t("No username supplied"))
|
165
|
170
|
return
|
166
|
171
|
}
|
167
|
172
|
|
168
|
173
|
certfp := client.certfp
|
169
|
174
|
if passphrase == "" && certfp == "" {
|
170
|
|
- rb.Notice(client.t("You need to either supply a passphrase or be connected via TLS with a client cert"))
|
|
175
|
+ nsNotice(rb, client.t("You need to either supply a passphrase or be connected via TLS with a client cert"))
|
171
|
176
|
return
|
172
|
177
|
}
|
173
|
178
|
|
|
@@ -175,7 +180,7 @@ func (server *Server) nickservRegisterHandler(client *Client, username, email, p
|
175
|
180
|
if server.AccountConfig().Registration.AllowMultiplePerConnection {
|
176
|
181
|
server.accounts.Logout(client)
|
177
|
182
|
} else {
|
178
|
|
- rb.Notice(client.t("You're already logged into an account"))
|
|
183
|
+ nsNotice(rb, client.t("You're already logged into an account"))
|
179
|
184
|
return
|
180
|
185
|
}
|
181
|
186
|
}
|
|
@@ -196,7 +201,7 @@ func (server *Server) nickservRegisterHandler(client *Client, username, email, p
|
196
|
201
|
} else {
|
197
|
202
|
callbackNamespace, callbackValue = parseCallback(email, config)
|
198
|
203
|
if callbackNamespace == "" {
|
199
|
|
- rb.Notice(client.t("Registration requires a valid e-mail address"))
|
|
204
|
+ nsNotice(rb, client.t("Registration requires a valid e-mail address"))
|
200
|
205
|
return
|
201
|
206
|
}
|
202
|
207
|
}
|
|
@@ -214,7 +219,7 @@ func (server *Server) nickservRegisterHandler(client *Client, username, email, p
|
214
|
219
|
} else {
|
215
|
220
|
messageTemplate := client.t("Account created, pending verification; verification code has been sent to %s:%s")
|
216
|
221
|
message := fmt.Sprintf(messageTemplate, callbackNamespace, callbackValue)
|
217
|
|
- rb.Notice(message)
|
|
222
|
+ nsNotice(rb, message)
|
218
|
223
|
}
|
219
|
224
|
}
|
220
|
225
|
|
|
@@ -226,7 +231,7 @@ func (server *Server) nickservRegisterHandler(client *Client, username, email, p
|
226
|
231
|
} else if err == errAccountAlreadyRegistered {
|
227
|
232
|
errMsg = "Account already exists"
|
228
|
233
|
}
|
229
|
|
- rb.Notice(client.t(errMsg))
|
|
234
|
+ nsNotice(rb, client.t(errMsg))
|
230
|
235
|
return
|
231
|
236
|
}
|
232
|
237
|
}
|
|
@@ -234,7 +239,7 @@ func (server *Server) nickservRegisterHandler(client *Client, username, email, p
|
234
|
239
|
func (server *Server) nickservIdentifyHandler(client *Client, username, passphrase string, rb *ResponseBuffer) {
|
235
|
240
|
// fail out if we need to
|
236
|
241
|
if !server.AccountConfig().AuthenticationEnabled {
|
237
|
|
- rb.Notice(client.t("Login has been disabled"))
|
|
242
|
+ nsNotice(rb, client.t("Login has been disabled"))
|
238
|
243
|
return
|
239
|
244
|
}
|
240
|
245
|
|
|
@@ -255,28 +260,28 @@ func (server *Server) nickservIdentifyHandler(client *Client, username, passphra
|
255
|
260
|
if loginSuccessful {
|
256
|
261
|
sendSuccessfulSaslAuth(client, rb, true)
|
257
|
262
|
} else {
|
258
|
|
- rb.Notice(client.t("Could not login with your TLS certificate or supplied username/password"))
|
|
263
|
+ nsNotice(rb, client.t("Could not login with your TLS certificate or supplied username/password"))
|
259
|
264
|
}
|
260
|
265
|
}
|
261
|
266
|
|
262
|
267
|
func (server *Server) nickservGhostHandler(client *Client, nick string, rb *ResponseBuffer) {
|
263
|
268
|
if !server.AccountConfig().NickReservation.Enabled {
|
264
|
|
- rb.Notice(client.t("Nickname reservation is disabled"))
|
|
269
|
+ nsNotice(rb, client.t("Nickname reservation is disabled"))
|
265
|
270
|
return
|
266
|
271
|
}
|
267
|
272
|
|
268
|
273
|
account := client.Account()
|
269
|
274
|
if account == "" || server.accounts.NickToAccount(nick) != account {
|
270
|
|
- rb.Notice(client.t("You don't own that nick"))
|
|
275
|
+ nsNotice(rb, client.t("You don't own that nick"))
|
271
|
276
|
return
|
272
|
277
|
}
|
273
|
278
|
|
274
|
279
|
ghost := server.clients.Get(nick)
|
275
|
280
|
if ghost == nil {
|
276
|
|
- rb.Notice(client.t("No such nick"))
|
|
281
|
+ nsNotice(rb, client.t("No such nick"))
|
277
|
282
|
return
|
278
|
283
|
} else if ghost == client {
|
279
|
|
- rb.Notice(client.t("You can't GHOST yourself (try /QUIT instead)"))
|
|
284
|
+ nsNotice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
|
280
|
285
|
return
|
281
|
286
|
}
|
282
|
287
|
|
|
@@ -286,26 +291,26 @@ func (server *Server) nickservGhostHandler(client *Client, nick string, rb *Resp
|
286
|
291
|
|
287
|
292
|
func (server *Server) nickservGroupHandler(client *Client, rb *ResponseBuffer) {
|
288
|
293
|
if !server.AccountConfig().NickReservation.Enabled {
|
289
|
|
- rb.Notice(client.t("Nickname reservation is disabled"))
|
|
294
|
+ nsNotice(rb, client.t("Nickname reservation is disabled"))
|
290
|
295
|
return
|
291
|
296
|
}
|
292
|
297
|
|
293
|
298
|
account := client.Account()
|
294
|
299
|
if account == "" {
|
295
|
|
- rb.Notice(client.t("You're not logged into an account"))
|
|
300
|
+ nsNotice(rb, client.t("You're not logged into an account"))
|
296
|
301
|
return
|
297
|
302
|
}
|
298
|
303
|
|
299
|
304
|
nick := client.NickCasefolded()
|
300
|
305
|
err := server.accounts.SetNickReserved(client, nick, false, true)
|
301
|
306
|
if err == nil {
|
302
|
|
- rb.Notice(fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
|
|
307
|
+ nsNotice(rb, fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
|
303
|
308
|
} else if err == errAccountTooManyNicks {
|
304
|
|
- rb.Notice(client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
|
|
309
|
+ nsNotice(rb, client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
|
305
|
310
|
} else if err == errNicknameReserved {
|
306
|
|
- rb.Notice(client.t("That nickname is already reserved by someone else"))
|
|
311
|
+ nsNotice(rb, client.t("That nickname is already reserved by someone else"))
|
307
|
312
|
} else {
|
308
|
|
- rb.Notice(client.t("Error reserving nickname"))
|
|
313
|
+ nsNotice(rb, client.t("Error reserving nickname"))
|
309
|
314
|
}
|
310
|
315
|
}
|
311
|
316
|
|
|
@@ -318,43 +323,43 @@ func (server *Server) nickservInfoHandler(client *Client, nick string, rb *Respo
|
318
|
323
|
if server.AccountConfig().NickReservation.Enabled {
|
319
|
324
|
accountName = server.accounts.NickToAccount(nick)
|
320
|
325
|
if accountName == "" {
|
321
|
|
- rb.Notice(client.t("That nickname is not registered"))
|
|
326
|
+ nsNotice(rb, client.t("That nickname is not registered"))
|
322
|
327
|
return
|
323
|
328
|
}
|
324
|
329
|
}
|
325
|
330
|
|
326
|
331
|
account, err := server.accounts.LoadAccount(accountName)
|
327
|
332
|
if err != nil || !account.Verified {
|
328
|
|
- rb.Notice(client.t("Account does not exist"))
|
|
333
|
+ nsNotice(rb, client.t("Account does not exist"))
|
329
|
334
|
}
|
330
|
335
|
|
331
|
|
- rb.Notice(fmt.Sprintf(client.t("Account: %s"), account.Name))
|
|
336
|
+ nsNotice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name))
|
332
|
337
|
registeredAt := account.RegisteredAt.Format("Jan 02, 2006 15:04:05Z")
|
333
|
|
- rb.Notice(fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
|
|
338
|
+ nsNotice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
|
334
|
339
|
// TODO nicer formatting for this
|
335
|
340
|
for _, nick := range account.AdditionalNicks {
|
336
|
|
- rb.Notice(fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
|
|
341
|
+ nsNotice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
|
337
|
342
|
}
|
338
|
343
|
}
|
339
|
344
|
|
340
|
345
|
func (server *Server) nickservDropHandler(client *Client, nick string, sadrop bool, rb *ResponseBuffer) {
|
341
|
346
|
if sadrop {
|
342
|
347
|
if !client.HasRoleCapabs("unregister") {
|
343
|
|
- rb.Notice(client.t("Insufficient oper privs"))
|
|
348
|
+ nsNotice(rb, client.t("Insufficient oper privs"))
|
344
|
349
|
return
|
345
|
350
|
}
|
346
|
351
|
}
|
347
|
352
|
|
348
|
353
|
err := server.accounts.SetNickReserved(client, nick, sadrop, false)
|
349
|
354
|
if err == nil {
|
350
|
|
- rb.Notice(fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
|
|
355
|
+ nsNotice(rb, fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
|
351
|
356
|
} else if err == errAccountNotLoggedIn {
|
352
|
|
- rb.Notice(fmt.Sprintf(client.t("You're not logged into an account")))
|
|
357
|
+ nsNotice(rb, fmt.Sprintf(client.t("You're not logged into an account")))
|
353
|
358
|
} else if err == errAccountCantDropPrimaryNick {
|
354
|
|
- rb.Notice(fmt.Sprintf(client.t("You can't ungroup your primary nickname (try unregistering your account instead)")))
|
|
359
|
+ nsNotice(rb, fmt.Sprintf(client.t("You can't ungroup your primary nickname (try unregistering your account instead)")))
|
355
|
360
|
} else if err == errNicknameReserved {
|
356
|
|
- rb.Notice(fmt.Sprintf(client.t("That nickname is already reserved by someone else")))
|
|
361
|
+ nsNotice(rb, fmt.Sprintf(client.t("That nickname is already reserved by someone else")))
|
357
|
362
|
} else {
|
358
|
|
- rb.Notice(client.t("Error ungrouping nick"))
|
|
363
|
+ nsNotice(rb, client.t("Error ungrouping nick"))
|
359
|
364
|
}
|
360
|
365
|
}
|