|
@@ -347,6 +347,17 @@ command lists all current suspensions.`,
|
347
|
347
|
minParams: 1,
|
348
|
348
|
capabs: []string{"accreg"},
|
349
|
349
|
},
|
|
350
|
+ "rename": {
|
|
351
|
+ handler: nsRenameHandler,
|
|
352
|
+ help: `Syntax: $bRENAME <account> <newname>$b
|
|
353
|
+
|
|
354
|
+RENAME allows a server administrator to change the name of an account.
|
|
355
|
+Currently, you can only change the canonical casefolding of an account
|
|
356
|
+(e.g., you can change "Alice" to "alice", but not "Alice" to "Amanda").`,
|
|
357
|
+ helpShort: `$bRENAME$b renames an account`,
|
|
358
|
+ minParams: 2,
|
|
359
|
+ capabs: []string{"accreg"},
|
|
360
|
+ },
|
350
|
361
|
}
|
351
|
362
|
)
|
352
|
363
|
|
|
@@ -1377,3 +1388,23 @@ func suspensionToString(client *Client, suspension AccountSuspension) (result st
|
1377
|
1388
|
}
|
1378
|
1389
|
return fmt.Sprintf(client.t("Account %[1]s suspended at %[2]s. Duration: %[3]s. %[4]s"), suspension.AccountName, ts, duration, reason)
|
1379
|
1390
|
}
|
|
1391
|
+
|
|
1392
|
+func nsRenameHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
1393
|
+ oldName, newName := params[0], params[1]
|
|
1394
|
+ err := server.accounts.Rename(oldName, newName)
|
|
1395
|
+
|
|
1396
|
+ if err != nil {
|
|
1397
|
+ nsNotice(rb, fmt.Sprintf(client.t("Couldn't rename account: %s"), client.t(err.Error())))
|
|
1398
|
+ return
|
|
1399
|
+ }
|
|
1400
|
+
|
|
1401
|
+ nsNotice(rb, client.t("Successfully renamed account"))
|
|
1402
|
+ if server.Config().Accounts.NickReservation.ForceNickEqualsAccount {
|
|
1403
|
+ if curClient := server.clients.Get(oldName); curClient != nil {
|
|
1404
|
+ renameErr := performNickChange(client.server, client, curClient, nil, newName, rb)
|
|
1405
|
+ if renameErr != nil && renameErr != errNoop {
|
|
1406
|
+ nsNotice(rb, fmt.Sprintf(client.t("Warning: could not rename affected client: %v"), err))
|
|
1407
|
+ }
|
|
1408
|
+ }
|
|
1409
|
+ }
|
|
1410
|
+}
|