3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 05:49:25 +01:00

Make like every client-facing string translatable

This commit is contained in:
Daniel Oaks 2018-01-22 21:26:01 +10:00
parent 0569b5cfaa
commit 275227a461
17 changed files with 205 additions and 208 deletions

View File

@ -67,9 +67,9 @@ func accHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if subcommand == "register" { if subcommand == "register" {
return accRegisterHandler(server, client, msg) return accRegisterHandler(server, client, msg)
} else if subcommand == "verify" { } else if subcommand == "verify" {
client.Notice("VERIFY is not yet implemented") client.Notice(client.t("VERIFY is not yet implemented"))
} else { } else {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", msg.Params[0], "Unknown subcommand") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", msg.Params[0], client.t("Unknown subcommand"))
} }
return false return false
@ -91,7 +91,7 @@ func removeFailedAccRegisterData(store *buntdb.DB, account string) {
func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// make sure reg is enabled // make sure reg is enabled
if !server.accountRegistration.Enabled { if !server.accountRegistration.Enabled {
client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", "Account registration is disabled") client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", client.t("Account registration is disabled"))
return false return false
} }
@ -100,7 +100,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
if server.accountRegistration.AllowMultiplePerConnection { if server.accountRegistration.AllowMultiplePerConnection {
client.LogoutOfAccount() client.LogoutOfAccount()
} else { } else {
client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", "You're already logged into an account") client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, "*", client.t("You're already logged into an account"))
return false return false
} }
} }
@ -110,7 +110,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
casefoldedAccount, err := CasefoldName(account) casefoldedAccount, err := CasefoldName(account)
// probably don't need explicit check for "*" here... but let's do it anyway just to make sure // probably don't need explicit check for "*" here... but let's do it anyway just to make sure
if err != nil || msg.Params[1] == "*" { if err != nil || msg.Params[1] == "*" {
client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, account, "Account name is not valid") client.Send(nil, server.name, ERR_REG_UNSPECIFIED_ERROR, client.nick, account, client.t("Account name is not valid"))
return false return false
} }
@ -122,7 +122,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
_, err := tx.Get(accountKey) _, err := tx.Get(accountKey)
if err != buntdb.ErrNotFound { if err != buntdb.ErrNotFound {
//TODO(dan): if account verified key doesn't exist account is not verified, calc the maximum time without verification and expire and continue if need be //TODO(dan): if account verified key doesn't exist account is not verified, calc the maximum time without verification and expire and continue if need be
client.Send(nil, server.name, ERR_ACCOUNT_ALREADY_EXISTS, client.nick, account, "Account already exists") client.Send(nil, server.name, ERR_ACCOUNT_ALREADY_EXISTS, client.nick, account, client.t("Account already exists"))
return errAccountCreation return errAccountCreation
} }
@ -137,7 +137,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
// account could not be created and relevant numerics have been dispatched, abort // account could not be created and relevant numerics have been dispatched, abort
if err != nil { if err != nil {
if err != errAccountCreation { if err != errAccountCreation {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", "Could not register") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", client.t("Could not register"))
log.Println("Could not save registration initial data:", err.Error()) log.Println("Could not save registration initial data:", err.Error())
} }
return false return false
@ -167,7 +167,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
} }
if !callbackValid { if !callbackValid {
client.Send(nil, server.name, ERR_REG_INVALID_CALLBACK, client.nick, account, callbackNamespace, "Callback namespace is not supported") client.Send(nil, server.name, ERR_REG_INVALID_CALLBACK, client.nick, account, callbackNamespace, client.t("Callback namespace is not supported"))
removeFailedAccRegisterData(server.store, casefoldedAccount) removeFailedAccRegisterData(server.store, casefoldedAccount)
return false return false
} }
@ -182,7 +182,7 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
credentialType = "passphrase" // default from the spec credentialType = "passphrase" // default from the spec
credentialValue = msg.Params[3] credentialValue = msg.Params[3]
} else { } else {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, client.t("Not enough parameters"))
removeFailedAccRegisterData(server.store, casefoldedAccount) removeFailedAccRegisterData(server.store, casefoldedAccount)
return false return false
} }
@ -195,13 +195,13 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
} }
} }
if credentialType == "certfp" && client.certfp == "" { if credentialType == "certfp" && client.certfp == "" {
client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "You are not using a TLS certificate") client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, client.t("You are not using a TLS certificate"))
removeFailedAccRegisterData(server.store, casefoldedAccount) removeFailedAccRegisterData(server.store, casefoldedAccount)
return false return false
} }
if !credentialValid { if !credentialValid {
client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, "Credential type is not supported") client.Send(nil, server.name, ERR_REG_INVALID_CRED_TYPE, client.nick, credentialType, callbackNamespace, client.t("Credential type is not supported"))
removeFailedAccRegisterData(server.store, casefoldedAccount) removeFailedAccRegisterData(server.store, casefoldedAccount)
return false return false
} }
@ -274,14 +274,14 @@ func accRegisterHandler(server *Server, client *Client, msg ircmsg.IrcMessage) b
server.accounts[casefoldedAccount] = &account server.accounts[casefoldedAccount] = &account
client.account = &account client.account = &account
client.Send(nil, server.name, RPL_REGISTRATION_SUCCESS, client.nick, account.Name, "Account created") client.Send(nil, server.name, RPL_REGISTRATION_SUCCESS, client.nick, account.Name, client.t("Account created"))
client.Send(nil, server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, account.Name, fmt.Sprintf("You are now logged in as %s", account.Name)) client.Send(nil, server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, account.Name, fmt.Sprintf(client.t("You are now logged in as %s"), account.Name))
client.Send(nil, server.name, RPL_SASLSUCCESS, client.nick, "Authentication successful") client.Send(nil, server.name, RPL_SASLSUCCESS, client.nick, client.t("Authentication successful"))
server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Account registered $c[grey][$r%s$c[grey]] by $c[grey][$r%s$c[grey]]"), account.Name, client.nickMaskString)) server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Account registered $c[grey][$r%s$c[grey]] by $c[grey][$r%s$c[grey]]"), account.Name, client.nickMaskString))
return nil return nil
}) })
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", "Could not register") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "ACC", "REGISTER", client.t("Could not register"))
log.Println("Could not save verification confirmation (*):", err.Error()) log.Println("Could not save verification confirmation (*):", err.Error())
removeFailedAccRegisterData(server.store, casefoldedAccount) removeFailedAccRegisterData(server.store, casefoldedAccount)
return false return false

View File

@ -91,7 +91,7 @@ func loadAccount(server *Server, tx *buntdb.Tx, accountKey string) *ClientAccoun
func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// sasl abort // sasl abort
if !server.accountAuthenticationEnabled || len(msg.Params) == 1 && msg.Params[0] == "*" { if !server.accountAuthenticationEnabled || len(msg.Params) == 1 && msg.Params[0] == "*" {
client.Send(nil, server.name, ERR_SASLABORTED, client.nick, "SASL authentication aborted") client.Send(nil, server.name, ERR_SASLABORTED, client.nick, client.t("SASL authentication aborted"))
client.saslInProgress = false client.saslInProgress = false
client.saslMechanism = "" client.saslMechanism = ""
client.saslValue = "" client.saslValue = ""
@ -108,7 +108,7 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
client.saslMechanism = mechanism client.saslMechanism = mechanism
client.Send(nil, server.name, "AUTHENTICATE", "+") client.Send(nil, server.name, "AUTHENTICATE", "+")
} else { } else {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed"))
} }
return false return false
@ -118,7 +118,7 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
rawData := msg.Params[0] rawData := msg.Params[0]
if len(rawData) > 400 { if len(rawData) > 400 {
client.Send(nil, server.name, ERR_SASLTOOLONG, client.nick, "SASL message too long") client.Send(nil, server.name, ERR_SASLTOOLONG, client.nick, client.t("SASL message too long"))
client.saslInProgress = false client.saslInProgress = false
client.saslMechanism = "" client.saslMechanism = ""
client.saslValue = "" client.saslValue = ""
@ -127,7 +127,7 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
client.saslValue += rawData client.saslValue += rawData
// allow 4 'continuation' lines before rejecting for length // allow 4 'continuation' lines before rejecting for length
if len(client.saslValue) > 400*4 { if len(client.saslValue) > 400*4 {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Passphrase too long") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed: Passphrase too long"))
client.saslInProgress = false client.saslInProgress = false
client.saslMechanism = "" client.saslMechanism = ""
client.saslValue = "" client.saslValue = ""
@ -144,7 +144,7 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
if client.saslValue != "+" { if client.saslValue != "+" {
data, err = base64.StdEncoding.DecodeString(client.saslValue) data, err = base64.StdEncoding.DecodeString(client.saslValue)
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid b64 encoding") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed: Invalid b64 encoding"))
client.saslInProgress = false client.saslInProgress = false
client.saslMechanism = "" client.saslMechanism = ""
client.saslValue = "" client.saslValue = ""
@ -157,7 +157,7 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
// like 100% not required, but it's good to be safe I guess // like 100% not required, but it's good to be safe I guess
if !handlerExists { if !handlerExists {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed"))
client.saslInProgress = false client.saslInProgress = false
client.saslMechanism = "" client.saslMechanism = ""
client.saslValue = "" client.saslValue = ""
@ -188,18 +188,18 @@ func authPlainHandler(server *Server, client *Client, mechanism string, value []
if accountKey == "" { if accountKey == "" {
accountKey = authzid accountKey = authzid
} else if accountKey != authzid { } else if accountKey != authzid {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: authcid and authzid should be the same") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed: authcid and authzid should be the same"))
return false return false
} }
} else { } else {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Invalid auth blob") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed: Invalid auth blob"))
return false return false
} }
// keep it the same as in the REG CREATE stage // keep it the same as in the REG CREATE stage
accountKey, err := CasefoldName(accountKey) accountKey, err := CasefoldName(accountKey)
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed: Bad account name") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed: Bad account name"))
return false return false
} }
@ -236,7 +236,7 @@ func authPlainHandler(server *Server, client *Client, mechanism string, value []
}) })
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed"))
return false return false
} }
@ -295,7 +295,7 @@ func (client *Client) LogoutOfAccount() {
// authExternalHandler parses the SASL EXTERNAL mechanism. // authExternalHandler parses the SASL EXTERNAL mechanism.
func authExternalHandler(server *Server, client *Client, mechanism string, value []byte) bool { func authExternalHandler(server *Server, client *Client, mechanism string, value []byte) bool {
if client.certfp == "" { if client.certfp == "" {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed, you are not connecting with a certificate") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed, you are not connecting with a certificate"))
return false return false
} }
@ -336,7 +336,7 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
}) })
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_SASLFAIL, client.nick, "SASL authentication failed") client.Send(nil, server.name, ERR_SASLFAIL, client.nick, client.t("SASL authentication failed"))
return false return false
} }
@ -347,7 +347,7 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
// successfulSaslAuth means that a SASL auth attempt completed successfully, and is used to dispatch messages. // successfulSaslAuth means that a SASL auth attempt completed successfully, and is used to dispatch messages.
func (client *Client) successfulSaslAuth() { func (client *Client) successfulSaslAuth() {
client.Send(nil, client.server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, client.account.Name, fmt.Sprintf("You are now logged in as %s", client.account.Name)) client.Send(nil, client.server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, client.account.Name, fmt.Sprintf("You are now logged in as %s", client.account.Name))
client.Send(nil, client.server.name, RPL_SASLSUCCESS, client.nick, "SASL authentication successful") client.Send(nil, client.server.name, RPL_SASLSUCCESS, client.nick, client.t("SASL authentication successful"))
// dispatch account-notify // dispatch account-notify
for friend := range client.Friends(caps.AccountNotify) { for friend := range client.Friends(caps.AccountNotify) {

View File

@ -88,7 +88,7 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
default: default:
client.Send(nil, server.name, ERR_INVALIDCAPCMD, client.nick, subCommand, "Invalid CAP subcommand") client.Send(nil, server.name, ERR_INVALIDCAPCMD, client.nick, subCommand, client.t("Invalid CAP subcommand"))
} }
return false return false
} }

View File

@ -197,7 +197,7 @@ func (channel *Channel) Names(client *Client) {
} }
client.Send(nil, client.server.name, RPL_NAMREPLY, client.nick, "=", channel.name, buffer) client.Send(nil, client.server.name, RPL_NAMREPLY, client.nick, "=", channel.name, buffer)
client.Send(nil, client.server.name, RPL_ENDOFNAMES, client.nick, channel.name, "End of NAMES list") client.Send(nil, client.server.name, RPL_ENDOFNAMES, client.nick, channel.name, client.t("End of NAMES list"))
} }
// ClientIsAtLeast returns whether the client has at least the given channel privilege. // ClientIsAtLeast returns whether the client has at least the given channel privilege.
@ -381,25 +381,25 @@ func (channel *Channel) Join(client *Client, key string) {
} }
if channel.IsFull() { if channel.IsFull() {
client.Send(nil, client.server.name, ERR_CHANNELISFULL, channel.name, "Cannot join channel (+l)") client.Send(nil, client.server.name, ERR_CHANNELISFULL, channel.name, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "l"))
return return
} }
if !channel.CheckKey(key) { if !channel.CheckKey(key) {
client.Send(nil, client.server.name, ERR_BADCHANNELKEY, channel.name, "Cannot join channel (+k)") client.Send(nil, client.server.name, ERR_BADCHANNELKEY, channel.name, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "k"))
return return
} }
isInvited := channel.lists[InviteMask].Match(client.nickMaskCasefolded) isInvited := channel.lists[InviteMask].Match(client.nickMaskCasefolded)
if channel.flags[InviteOnly] && !isInvited { if channel.flags[InviteOnly] && !isInvited {
client.Send(nil, client.server.name, ERR_INVITEONLYCHAN, channel.name, "Cannot join channel (+i)") client.Send(nil, client.server.name, ERR_INVITEONLYCHAN, channel.name, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "i"))
return return
} }
if channel.lists[BanMask].Match(client.nickMaskCasefolded) && if channel.lists[BanMask].Match(client.nickMaskCasefolded) &&
!isInvited && !isInvited &&
!channel.lists[ExceptMask].Match(client.nickMaskCasefolded) { !channel.lists[ExceptMask].Match(client.nickMaskCasefolded) {
client.Send(nil, client.server.name, ERR_BANNEDFROMCHAN, channel.name, "Cannot join channel (+b)") client.Send(nil, client.server.name, ERR_BANNEDFROMCHAN, channel.name, fmt.Sprintf(client.t("Cannot join channel (+%s)"), "b"))
return return
} }
@ -455,7 +455,7 @@ func (channel *Channel) Join(client *Client, key string) {
// Part parts the given client from this channel, with the given message. // Part parts the given client from this channel, with the given message.
func (channel *Channel) Part(client *Client, message string) { func (channel *Channel) Part(client *Client, message string) {
if !channel.hasClient(client) { if !channel.hasClient(client) {
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, "You're not on that channel") client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, client.t("You're not on that channel"))
return return
} }
@ -470,7 +470,7 @@ func (channel *Channel) Part(client *Client, message string) {
// SendTopic sends the channel topic to the given client. // SendTopic sends the channel topic to the given client.
func (channel *Channel) SendTopic(client *Client) { func (channel *Channel) SendTopic(client *Client) {
if !channel.hasClient(client) { if !channel.hasClient(client) {
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, client.nick, channel.name, "You're not on that channel") client.Send(nil, client.server.name, ERR_NOTONCHANNEL, client.nick, channel.name, client.t("You're not on that channel"))
return return
} }
@ -482,7 +482,7 @@ func (channel *Channel) SendTopic(client *Client) {
channel.stateMutex.RUnlock() channel.stateMutex.RUnlock()
if topic == "" { if topic == "" {
client.Send(nil, client.server.name, RPL_NOTOPIC, client.nick, name, "No topic is set") client.Send(nil, client.server.name, RPL_NOTOPIC, client.nick, name, client.t("No topic is set"))
return return
} }
@ -493,12 +493,12 @@ func (channel *Channel) SendTopic(client *Client) {
// SetTopic sets the topic of this channel, if the client is allowed to do so. // SetTopic sets the topic of this channel, if the client is allowed to do so.
func (channel *Channel) SetTopic(client *Client, topic string) { func (channel *Channel) SetTopic(client *Client, topic string) {
if !(client.flags[Operator] || channel.hasClient(client)) { if !(client.flags[Operator] || channel.hasClient(client)) {
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, "You're not on that channel") client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, client.t("You're not on that channel"))
return return
} }
if channel.HasMode(OpOnlyTopic) && !channel.ClientIsAtLeast(client, ChannelOperator) { if channel.HasMode(OpOnlyTopic) && !channel.ClientIsAtLeast(client, ChannelOperator) {
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator") client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You're not a channel operator"))
return return
} }
@ -545,7 +545,7 @@ func (channel *Channel) TagMsg(msgid string, minPrefix *Mode, clientOnlyTags *ma
// sendMessage sends a given message to everyone on this channel. // sendMessage sends a given message to everyone on this channel.
func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []caps.Capability, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *string) { func (channel *Channel) sendMessage(msgid, cmd string, requiredCaps []caps.Capability, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *string) {
if !channel.CanSpeak(client) { if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
return return
} }
@ -598,7 +598,7 @@ func (channel *Channel) SplitNotice(msgid string, minPrefix *Mode, clientOnlyTag
func (channel *Channel) sendSplitMessage(msgid, cmd string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *SplitMessage) { func (channel *Channel) sendSplitMessage(msgid, cmd string, minPrefix *Mode, clientOnlyTags *map[string]ircmsg.TagValue, client *Client, message *SplitMessage) {
if !channel.CanSpeak(client) { if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
return return
} }
@ -632,14 +632,14 @@ func (channel *Channel) applyModeMemberNoMutex(client *Client, mode Mode,
op ModeOp, nick string) *ModeChange { op ModeOp, nick string) *ModeChange {
if nick == "" { if nick == "" {
//TODO(dan): shouldn't this be handled before it reaches this function? //TODO(dan): shouldn't this be handled before it reaches this function?
client.Send(nil, client.server.name, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters") client.Send(nil, client.server.name, ERR_NEEDMOREPARAMS, "MODE", client.t("Not enough parameters"))
return nil return nil
} }
casefoldedName, err := CasefoldName(nick) casefoldedName, err := CasefoldName(nick)
target := channel.server.clients.Get(casefoldedName) target := channel.server.clients.Get(casefoldedName)
if err != nil || target == nil { if err != nil || target == nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nick, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nick, client.t("No such nick"))
return nil return nil
} }
@ -654,7 +654,7 @@ func (channel *Channel) applyModeMemberNoMutex(client *Client, mode Mode,
channel.stateMutex.Unlock() channel.stateMutex.Unlock()
if !exists { if !exists {
client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nick, channel.name, "They aren't on that channel") client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nick, channel.name, client.t("They aren't on that channel"))
return nil return nil
} else if already { } else if already {
return nil return nil
@ -690,7 +690,7 @@ func (channel *Channel) ShowMaskList(client *Client, mode Mode) {
} }
channel.stateMutex.RUnlock() channel.stateMutex.RUnlock()
client.Send(nil, client.server.name, rplendoflist, nick, channel.name, "End of list") client.Send(nil, client.server.name, rplendoflist, nick, channel.name, client.t("End of list"))
} }
func (channel *Channel) applyModeMask(client *Client, mode Mode, op ModeOp, mask string) bool { func (channel *Channel) applyModeMask(client *Client, mode Mode, op ModeOp, mask string) bool {
@ -706,7 +706,7 @@ func (channel *Channel) applyModeMask(client *Client, mode Mode, op ModeOp, mask
} }
if !channel.ClientIsAtLeast(client, ChannelOperator) { if !channel.ClientIsAtLeast(client, ChannelOperator) {
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator") client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You're not a channel operator"))
return false return false
} }
@ -733,19 +733,19 @@ func (channel *Channel) Quit(client *Client) {
func (channel *Channel) Kick(client *Client, target *Client, comment string) { func (channel *Channel) Kick(client *Client, target *Client, comment string) {
if !(client.flags[Operator] || channel.hasClient(client)) { if !(client.flags[Operator] || channel.hasClient(client)) {
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, "You're not on that channel") client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.name, client.t("You're not on that channel"))
return return
} }
if !channel.ClientIsAtLeast(client, ChannelOperator) { if !channel.ClientIsAtLeast(client, ChannelOperator) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
return return
} }
if !channel.hasClient(target) { if !channel.hasClient(target) {
client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nick, channel.name, "They aren't on that channel") client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nick, channel.name, client.t("They aren't on that channel"))
return return
} }
if !channel.ClientHasPrivsOver(client, target) { if !channel.ClientHasPrivsOver(client, target) {
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator") client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You're not a channel operator"))
return return
} }
@ -766,12 +766,12 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string) {
// Invite invites the given client to the channel, if the inviter can do so. // Invite invites the given client to the channel, if the inviter can do so.
func (channel *Channel) Invite(invitee *Client, inviter *Client) { func (channel *Channel) Invite(invitee *Client, inviter *Client) {
if channel.flags[InviteOnly] && !channel.ClientIsAtLeast(inviter, ChannelOperator) { if channel.flags[InviteOnly] && !channel.ClientIsAtLeast(inviter, ChannelOperator) {
inviter.Send(nil, inviter.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator") inviter.Send(nil, inviter.server.name, ERR_CHANOPRIVSNEEDED, channel.name, inviter.t("You're not a channel operator"))
return return
} }
if !channel.hasClient(inviter) { if !channel.hasClient(inviter) {
inviter.Send(nil, inviter.server.name, ERR_NOTONCHANNEL, channel.name, "You're not on that channel") inviter.Send(nil, inviter.server.name, ERR_NOTONCHANNEL, channel.name, inviter.t("You're not on that channel"))
return return
} }

View File

@ -35,7 +35,7 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
} }
} }
if len(params) < 1 { if len(params) < 1 {
client.ChanServNotice("You need to run a command") client.ChanServNotice(client.t("You need to run a command"))
//TODO(dan): dump CS help here //TODO(dan): dump CS help here
return return
} }
@ -45,30 +45,30 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
if command == "register" { if command == "register" {
if len(params) < 2 { if len(params) < 2 {
client.ChanServNotice("Syntax: REGISTER <channel>") client.ChanServNotice(client.t("Syntax: REGISTER <channel>"))
return return
} }
if !server.channelRegistrationEnabled { if !server.channelRegistrationEnabled {
client.ChanServNotice("Channel registration is not enabled") client.ChanServNotice(client.t("Channel registration is not enabled"))
return return
} }
channelName := params[1] channelName := params[1]
channelKey, err := CasefoldChannel(channelName) channelKey, err := CasefoldChannel(channelName)
if err != nil { if err != nil {
client.ChanServNotice("Channel name is not valid") client.ChanServNotice(client.t("Channel name is not valid"))
return return
} }
channelInfo := server.channels.Get(channelKey) channelInfo := server.channels.Get(channelKey)
if channelInfo == nil || !channelInfo.ClientIsAtLeast(client, ChannelOperator) { if channelInfo == nil || !channelInfo.ClientIsAtLeast(client, ChannelOperator) {
client.ChanServNotice("You must be an oper on the channel to register it") client.ChanServNotice(client.t("You must be an oper on the channel to register it"))
return return
} }
if client.account == &NoAccount { if client.account == &NoAccount {
client.ChanServNotice("You must be logged in to register a channel") client.ChanServNotice(client.t("You must be logged in to register a channel"))
return return
} }
@ -82,7 +82,7 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
// registration was successful: make the database reflect it // registration was successful: make the database reflect it
go server.channelRegistry.StoreChannel(channelInfo, true) go server.channelRegistry.StoreChannel(channelInfo, true)
client.ChanServNotice(fmt.Sprintf("Channel %s successfully registered", channelName)) client.ChanServNotice(fmt.Sprintf(client.t("Channel %s successfully registered"), channelName))
server.logger.Info("chanserv", fmt.Sprintf("Client %s registered channel %s", client.nick, channelName)) server.logger.Info("chanserv", fmt.Sprintf("Client %s registered channel %s", client.nick, channelName))
server.snomasks.Send(sno.LocalChannels, fmt.Sprintf(ircfmt.Unescape("Channel registered $c[grey][$r%s$c[grey]] by $c[grey][$r%s$c[grey]]"), channelName, client.nickMaskString)) server.snomasks.Send(sno.LocalChannels, fmt.Sprintf(ircfmt.Unescape("Channel registered $c[grey][$r%s$c[grey]] by $c[grey][$r%s$c[grey]]"), channelName, client.nickMaskString))
@ -98,6 +98,6 @@ func (server *Server) chanservReceivePrivmsg(client *Client, message string) {
} }
} }
} else { } else {
client.ChanServNotice("Sorry, I don't know that command") client.ChanServNotice(client.t("Sorry, I don't know that command"))
} }
} }

View File

@ -102,6 +102,7 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
nickCasefolded: "*", nickCasefolded: "*",
nickMaskString: "*", // * is used until actual nick is given nickMaskString: "*", // * is used until actual nick is given
} }
client.recomputeMaxlens() client.recomputeMaxlens()
if isTLS { if isTLS {
client.flags[TLS] = true client.flags[TLS] = true
@ -121,20 +122,20 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
log.Fatal(err) log.Fatal(err)
} }
client.Notice("*** Looking up your username") client.Notice(client.t("*** Looking up your username"))
resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds) resp, err := ident.Query(clientHost, serverPort, clientPort, IdentTimeoutSeconds)
if err == nil { if err == nil {
username := resp.Identifier username := resp.Identifier
_, err := CasefoldName(username) // ensure it's a valid username _, err := CasefoldName(username) // ensure it's a valid username
if err == nil { if err == nil {
client.Notice("*** Found your username") client.Notice(client.t("*** Found your username"))
client.username = username client.username = username
// we don't need to updateNickMask here since nickMask is not used for anything yet // we don't need to updateNickMask here since nickMask is not used for anything yet
} else { } else {
client.Notice("*** Got a malformed username, ignoring") client.Notice(client.t("*** Got a malformed username, ignoring"))
} }
} else { } else {
client.Notice("*** Could not find your username") client.Notice(client.t("*** Could not find your username"))
} }
} }
go client.run() go client.run()
@ -236,16 +237,16 @@ func (client *Client) run() {
if err == ircmsg.ErrorLineIsEmpty { if err == ircmsg.ErrorLineIsEmpty {
continue continue
} else if err != nil { } else if err != nil {
client.Quit("received malformed line") client.Quit(client.t("Received malformed line"))
break break
} }
cmd, exists := Commands[msg.Command] cmd, exists := Commands[msg.Command]
if !exists { if !exists {
if len(msg.Command) > 0 { if len(msg.Command) > 0 {
client.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.nick, msg.Command, "Unknown command") client.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.nick, msg.Command, client.t("Unknown command"))
} else { } else {
client.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.nick, "lastcmd", "No command given") client.Send(nil, client.server.name, ERR_UNKNOWNCOMMAND, client.nick, "lastcmd", client.t("No command given"))
} }
continue continue
} }
@ -328,13 +329,13 @@ func (client *Client) TryResume() {
// can't use server.clients.Get since we hold server.clients' tier 1 mutex // can't use server.clients.Get since we hold server.clients' tier 1 mutex
casefoldedName, err := CasefoldName(oldnick) casefoldedName, err := CasefoldName(oldnick)
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Cannot resume connection, old client not found"))
return return
} }
oldClient := server.clients.byNick[casefoldedName] oldClient := server.clients.byNick[casefoldedName]
if oldClient == nil { if oldClient == nil {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old client not found") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Cannot resume connection, old client not found"))
return return
} }
@ -342,12 +343,12 @@ func (client *Client) TryResume() {
newAccountName := client.AccountName() newAccountName := client.AccountName()
if oldAccountName == "" || newAccountName == "" || oldAccountName != newAccountName { if oldAccountName == "" || newAccountName == "" || oldAccountName != newAccountName {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old and new clients must be logged into the same account") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Cannot resume connection, old and new clients must be logged into the same account"))
return return
} }
if !oldClient.HasMode(TLS) || !client.HasMode(TLS) { if !oldClient.HasMode(TLS) || !client.HasMode(TLS) {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, old and new clients must have TLS") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Cannot resume connection, old and new clients must have TLS"))
return return
} }
@ -370,7 +371,7 @@ func (client *Client) TryResume() {
friend.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname(), timestampString) friend.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname(), timestampString)
} }
} else { } else {
friend.Send(nil, oldClient.NickMaskString(), "QUIT", "Client reconnected") friend.Send(nil, oldClient.NickMaskString(), "QUIT", friend.t("Client reconnected"))
} }
} }

View File

@ -21,19 +21,19 @@ type Command struct {
// Run runs this command with the given client/message. // Run runs this command with the given client/message.
func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if !client.registered && !cmd.usablePreReg { if !client.registered && !cmd.usablePreReg {
client.Send(nil, server.name, ERR_NOTREGISTERED, client.nick, "You need to register before you can use that command") client.Send(nil, server.name, ERR_NOTREGISTERED, client.nick, client.t("You need to register before you can use that command"))
return false return false
} }
if cmd.oper && !client.flags[Operator] { if cmd.oper && !client.flags[Operator] {
client.Send(nil, server.name, ERR_NOPRIVILEGES, client.nick, "Permission Denied - You're not an IRC operator") client.Send(nil, server.name, ERR_NOPRIVILEGES, client.nick, client.t("Permission Denied - You're not an IRC operator"))
return false return false
} }
if len(cmd.capabs) > 0 && !client.HasRoleCapabs(cmd.capabs...) { if len(cmd.capabs) > 0 && !client.HasRoleCapabs(cmd.capabs...) {
client.Send(nil, server.name, ERR_NOPRIVILEGES, client.nick, "Permission Denied") client.Send(nil, server.name, ERR_NOPRIVILEGES, client.nick, client.t("Permission Denied"))
return false return false
} }
if len(msg.Params) < cmd.minParams { if len(msg.Params) < cmd.minParams {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, client.t("Not enough parameters"))
return false return false
} }
if !cmd.leaveClientActive { if !cmd.leaveClientActive {

View File

@ -221,7 +221,7 @@ func (dm *DLineManager) CheckIP(addr net.IP) (isBanned bool, info *IPBanInfo) {
func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// check oper permissions // check oper permissions
if !client.class.Capabilities["oper:local_ban"] { if !client.class.Capabilities["oper:local_ban"] {
client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, "Insufficient oper privs") client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -232,11 +232,11 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
bans := server.dlines.AllBans() bans := server.dlines.AllBans()
if len(bans) == 0 { if len(bans) == 0 {
client.Notice("No DLINEs have been set!") client.Notice(client.t("No DLINEs have been set!"))
} }
for key, info := range bans { for key, info := range bans {
client.Notice(fmt.Sprintf("Ban - %s - added by %s - %s", key, info.OperName, info.BanMessage("%s"))) client.Notice(fmt.Sprintf(client.t("Ban - %s - added by %s - %s"), key, info.OperName, info.BanMessage("%s")))
} }
return false return false
@ -266,7 +266,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// get host // get host
if len(msg.Params) < currentArg+1 { if len(msg.Params) < currentArg+1 {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, client.t("Not enough parameters"))
return false return false
} }
hostString := msg.Params[currentArg] hostString := msg.Params[currentArg]
@ -282,27 +282,27 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
if hostAddr == nil && hostNet == nil { if hostAddr == nil && hostNet == nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "Could not parse IP address or CIDR network") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("Could not parse IP address or CIDR network"))
return false return false
} }
if hostNet == nil { if hostNet == nil {
hostString = hostAddr.String() hostString = hostAddr.String()
if !dlineMyself && hostAddr.Equal(client.IP()) { if !dlineMyself && hostAddr.Equal(client.IP()) {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "This ban matches you. To DLINE yourself, you must use the command: /DLINE MYSELF <arguments>") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("This ban matches you. To DLINE yourself, you must use the command: /DLINE MYSELF <arguments>"))
return false return false
} }
} else { } else {
hostString = hostNet.String() hostString = hostNet.String()
if !dlineMyself && hostNet.Contains(client.IP()) { if !dlineMyself && hostNet.Contains(client.IP()) {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "This ban matches you. To DLINE yourself, you must use the command: /DLINE MYSELF <arguments>") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("This ban matches you. To DLINE yourself, you must use the command: /DLINE MYSELF <arguments>"))
return false return false
} }
} }
// check remote // check remote
if len(msg.Params) > currentArg && msg.Params[currentArg] == "ON" { if len(msg.Params) > currentArg && msg.Params[currentArg] == "ON" {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "Remote servers not yet supported") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("Remote servers not yet supported"))
return false return false
} }
@ -360,7 +360,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
}) })
if err != nil { if err != nil {
client.Notice(fmt.Sprintf("Could not successfully save new D-LINE: %s", err.Error())) client.Notice(fmt.Sprintf(client.t("Could not successfully save new D-LINE: %s"), err.Error()))
return false return false
} }
@ -401,7 +401,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for _, mcl := range clientsToKill { for _, mcl := range clientsToKill {
mcl.exitedSnomaskSent = true mcl.exitedSnomaskSent = true
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason)) mcl.Quit(fmt.Sprintf(mcl.t("You have been banned from this server (%s)"), reason))
if mcl == client { if mcl == client {
killClient = true killClient = true
} else { } else {
@ -421,7 +421,7 @@ func dlineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// check oper permissions // check oper permissions
if !client.class.Capabilities["oper:local_unban"] { if !client.class.Capabilities["oper:local_unban"] {
client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, "Insufficient oper privs") client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -438,7 +438,7 @@ func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
} }
if hostAddr == nil && hostNet == nil { if hostAddr == nil && hostNet == nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "Could not parse IP address or CIDR network") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("Could not parse IP address or CIDR network"))
return false return false
} }
@ -465,7 +465,7 @@ func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
}) })
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, fmt.Sprintf("Could not remove ban [%s]", err.Error())) client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, fmt.Sprintf(client.t("Could not remove ban [%s]"), err.Error()))
return false return false
} }
@ -475,7 +475,7 @@ func unDLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
server.dlines.RemoveNetwork(*hostNet) server.dlines.RemoveNetwork(*hostNet)
} }
client.Notice(fmt.Sprintf("Removed D-Line for %s", hostString)) client.Notice(fmt.Sprintf(client.t("Removed D-Line for %s"), hostString))
server.snomasks.Send(sno.LocalXline, fmt.Sprintf(ircfmt.Unescape("%s$r removed D-Line for %s"), client.nick, hostString)) server.snomasks.Send(sno.LocalXline, fmt.Sprintf(ircfmt.Unescape("%s$r removed D-Line for %s"), client.nick, hostString))
return false return false
} }

View File

@ -85,7 +85,7 @@ func webircHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
} }
client.Quit("WEBIRC command is not usable from your address or incorrect password given") client.Quit(client.t("WEBIRC command is not usable from your address or incorrect password given"))
return true return true
} }
@ -107,7 +107,7 @@ func proxyHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
return client.ApplyProxiedIP(proxiedIP, true) return client.ApplyProxiedIP(proxiedIP, true)
} }
} }
client.Quit("PROXY command is not usable from your address") client.Quit(client.t("PROXY command is not usable from your address"))
return true return true
} }
@ -116,7 +116,7 @@ func (client *Client) ApplyProxiedIP(proxiedIP string, tls bool) (exiting bool)
// ensure IP is sane // ensure IP is sane
parsedProxiedIP := net.ParseIP(proxiedIP) parsedProxiedIP := net.ParseIP(proxiedIP)
if parsedProxiedIP == nil { if parsedProxiedIP == nil {
client.Quit(fmt.Sprintf("Proxied IP address is not valid: [%s]", proxiedIP)) client.Quit(fmt.Sprintf(client.t("Proxied IP address is not valid: [%s]"), proxiedIP))
return true return true
} }

View File

@ -652,7 +652,7 @@ func (client *Client) sendHelp(name string, text string) {
} }
} }
args := splitName args := splitName
args = append(args, "End of /HELPOP") args = append(args, client.t("End of /HELPOP"))
client.Send(nil, client.server.name, RPL_ENDOFHELP, args...) client.Send(nil, client.server.name, RPL_ENDOFHELP, args...)
} }
@ -661,9 +661,9 @@ func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
argument := strings.ToLower(strings.TrimSpace(strings.Join(msg.Params, " "))) argument := strings.ToLower(strings.TrimSpace(strings.Join(msg.Params, " ")))
if len(argument) < 1 { if len(argument) < 1 {
client.sendHelp("HELPOP", `HELPOP <argument> client.sendHelp("HELPOP", client.t(`HELPOP <argument>
Get an explanation of <argument>, or "index" for a list of help topics.`) Get an explanation of <argument>, or "index" for a list of help topics.`))
return false return false
} }
@ -683,7 +683,7 @@ Get an explanation of <argument>, or "index" for a list of help topics.`)
client.sendHelp(strings.ToUpper(argument), helpHandler.text) client.sendHelp(strings.ToUpper(argument), helpHandler.text)
} else { } else {
args := msg.Params args := msg.Params
args = append(args, "Help not found") args = append(args, client.t("Help not found"))
client.Send(nil, server.name, ERR_HELPNOTFOUND, args...) client.Send(nil, server.name, ERR_HELPNOTFOUND, args...)
} }

View File

@ -132,7 +132,7 @@ func (km *KLineManager) CheckMasks(masks ...string) (isBanned bool, info *IPBanI
func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// check oper permissions // check oper permissions
if !client.class.Capabilities["oper:local_ban"] { if !client.class.Capabilities["oper:local_ban"] {
client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, "Insufficient oper privs") client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -147,7 +147,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
for key, info := range bans { for key, info := range bans {
client.Notice(fmt.Sprintf("Ban - %s - added by %s - %s", key, info.OperName, info.BanMessage("%s"))) client.Notice(fmt.Sprintf(client.t("Ban - %s - added by %s - %s"), key, info.OperName, info.BanMessage("%s")))
} }
return false return false
@ -177,7 +177,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// get mask // get mask
if len(msg.Params) < currentArg+1 { if len(msg.Params) < currentArg+1 {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, msg.Command, client.t("Not enough parameters"))
return false return false
} }
mask := strings.ToLower(msg.Params[currentArg]) mask := strings.ToLower(msg.Params[currentArg])
@ -194,14 +194,14 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for _, clientMask := range client.AllNickmasks() { for _, clientMask := range client.AllNickmasks() {
if !klineMyself && matcher.Match(clientMask) { if !klineMyself && matcher.Match(clientMask) {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "This ban matches you. To KLINE yourself, you must use the command: /KLINE MYSELF <arguments>") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("This ban matches you. To KLINE yourself, you must use the command: /KLINE MYSELF <arguments>"))
return false return false
} }
} }
// check remote // check remote
if len(msg.Params) > currentArg && msg.Params[currentArg] == "ON" { if len(msg.Params) > currentArg && msg.Params[currentArg] == "ON" {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "Remote servers not yet supported") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("Remote servers not yet supported"))
return false return false
} }
@ -261,7 +261,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
}) })
if err != nil { if err != nil {
client.Notice(fmt.Sprintf("Could not successfully save new K-LINE: %s", err.Error())) client.Notice(fmt.Sprintf(client.t("Could not successfully save new K-LINE: %s"), err.Error()))
return false return false
} }
@ -269,10 +269,10 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
var snoDescription string var snoDescription string
if durationIsUsed { if durationIsUsed {
client.Notice(fmt.Sprintf("Added temporary (%s) K-Line for %s", duration.String(), mask)) client.Notice(fmt.Sprintf(client.t("Added temporary (%s) K-Line for %s"), duration.String(), mask))
snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added temporary (%s) K-Line for %s"), client.nick, operName, duration.String(), mask) snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added temporary (%s) K-Line for %s"), client.nick, operName, duration.String(), mask)
} else { } else {
client.Notice(fmt.Sprintf("Added K-Line for %s", mask)) client.Notice(fmt.Sprintf(client.t("Added K-Line for %s"), mask))
snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added K-Line for %s"), client.nick, operName, mask) snoDescription = fmt.Sprintf(ircfmt.Unescape("%s [%s]$r added K-Line for %s"), client.nick, operName, mask)
} }
server.snomasks.Send(sno.LocalXline, snoDescription) server.snomasks.Send(sno.LocalXline, snoDescription)
@ -293,7 +293,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for _, mcl := range clientsToKill { for _, mcl := range clientsToKill {
mcl.exitedSnomaskSent = true mcl.exitedSnomaskSent = true
mcl.Quit(fmt.Sprintf("You have been banned from this server (%s)", reason)) mcl.Quit(fmt.Sprintf(mcl.t("You have been banned from this server (%s)"), reason))
if mcl == client { if mcl == client {
killClient = true killClient = true
} else { } else {
@ -313,7 +313,7 @@ func klineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// check oper permissions // check oper permissions
if !client.class.Capabilities["oper:local_unban"] { if !client.class.Capabilities["oper:local_unban"] {
client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, "Insufficient oper privs") client.Send(nil, server.name, ERR_NOPRIVS, client.nick, msg.Command, client.t("Insufficient oper privs"))
return false return false
} }
@ -343,13 +343,13 @@ func unKLineHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
}) })
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, fmt.Sprintf("Could not remove ban [%s]", err.Error())) client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, fmt.Sprintf(client.t("Could not remove ban [%s]"), err.Error()))
return false return false
} }
server.klines.RemoveMask(mask) server.klines.RemoveMask(mask)
client.Notice(fmt.Sprintf("Removed K-Line for %s", mask)) client.Notice(fmt.Sprintf(client.t("Removed K-Line for %s"), mask))
server.snomasks.Send(sno.LocalXline, fmt.Sprintf(ircfmt.Unescape("%s$r removed K-Line for %s"), client.nick, mask)) server.snomasks.Send(sno.LocalXline, fmt.Sprintf(ircfmt.Unescape("%s$r removed K-Line for %s"), client.nick, mask))
return false return false
} }

View File

@ -330,7 +330,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
target := server.clients.Get(nickname) target := server.clients.Get(nickname)
if err != nil || target == nil { if err != nil || target == nil {
if len(msg.Params[0]) > 0 { if len(msg.Params[0]) > 0 {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, msg.Params[0], "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, msg.Params[0], client.t("No such nick"))
} }
return false return false
} }
@ -340,9 +340,9 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if !hasPrivs { if !hasPrivs {
if len(msg.Params) > 1 { if len(msg.Params) > 1 {
client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't change modes for other users") client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, client.t("Can't change modes for other users"))
} else { } else {
client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't view modes for other users") client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, client.t("Can't view modes for other users"))
} }
return false return false
} }
@ -357,7 +357,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// alert for unknown mode changes // alert for unknown mode changes
for char := range unknown { for char := range unknown {
client.Send(nil, server.name, ERR_UNKNOWNMODE, client.nick, string(char), "is an unknown mode character to me") client.Send(nil, server.name, ERR_UNKNOWNMODE, client.nick, string(char), client.t("is an unknown mode character to me"))
} }
if len(unknown) == 1 && len(changes) == 0 { if len(unknown) == 1 && len(changes) == 0 {
return false return false
@ -374,7 +374,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if client.flags[LocalOperator] || client.flags[Operator] { if client.flags[LocalOperator] || client.flags[Operator] {
masks := server.snomasks.String(client) masks := server.snomasks.String(client)
if 0 < len(masks) { if 0 < len(masks) {
client.Send(nil, target.nickMaskString, RPL_SNOMASKIS, targetNick, masks, "Server notice masks") client.Send(nil, target.nickMaskString, RPL_SNOMASKIS, targetNick, masks, client.t("Server notice masks"))
} }
} }
} }
@ -521,7 +521,7 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
if !hasPrivs(change) { if !hasPrivs(change) {
if !alreadySentPrivError { if !alreadySentPrivError {
alreadySentPrivError = true alreadySentPrivError = true
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator") client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, client.t("You're not a channel operator"))
} }
continue continue
} }
@ -543,7 +543,7 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
case Add: case Add:
if channel.lists[change.mode].Length() >= client.server.Limits().ChanListModes { if channel.lists[change.mode].Length() >= client.server.Limits().ChanListModes {
if !listFullWarned[change.mode] { if !listFullWarned[change.mode] {
client.Send(nil, client.server.name, ERR_BANLISTFULL, client.Nick(), channel.Name(), change.mode.String(), "Channel list is full") client.Send(nil, client.server.name, ERR_BANLISTFULL, client.Nick(), channel.Name(), change.mode.String(), client.t("Channel list is full"))
listFullWarned[change.mode] = true listFullWarned[change.mode] = true
} }
continue continue
@ -612,7 +612,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
channel := server.channels.Get(channelName) channel := server.channels.Get(channelName)
if err != nil || channel == nil { if err != nil || channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, msg.Params[0], "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, msg.Params[0], client.t("No such channel"))
return false return false
} }
@ -626,7 +626,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// alert for unknown mode changes // alert for unknown mode changes
for char := range unknown { for char := range unknown {
client.Send(nil, server.name, ERR_UNKNOWNMODE, client.nick, string(char), "is an unknown mode character to me") client.Send(nil, server.name, ERR_UNKNOWNMODE, client.nick, string(char), client.t("is an unknown mode character to me"))
} }
if len(unknown) == 1 && len(changes) == 0 { if len(unknown) == 1 && len(changes) == 0 {
return false return false

View File

@ -123,7 +123,7 @@ func monitorHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
handler, exists := metadataSubcommands[strings.ToLower(msg.Params[0])] handler, exists := metadataSubcommands[strings.ToLower(msg.Params[0])]
if !exists { if !exists {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "MONITOR", msg.Params[0], "Unknown subcommand") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "MONITOR", msg.Params[0], client.t("Unknown subcommand"))
return false return false
} }
@ -132,7 +132,7 @@ func monitorHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if len(msg.Params) < 2 { if len(msg.Params) < 2 {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
return false return false
} }
@ -150,7 +150,7 @@ func monitorRemoveHandler(server *Server, client *Client, msg ircmsg.IrcMessage)
func monitorAddHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func monitorAddHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if len(msg.Params) < 2 { if len(msg.Params) < 2 {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), msg.Command, client.t("Not enough parameters"))
return false return false
} }

View File

@ -36,12 +36,12 @@ func performNickChange(server *Server, client *Client, target *Client, newnick s
cfnick, err := CasefoldName(nickname) cfnick, err := CasefoldName(nickname)
if len(nickname) < 1 { if len(nickname) < 1 {
client.Send(nil, server.name, ERR_NONICKNAMEGIVEN, client.nick, "No nickname given") client.Send(nil, server.name, ERR_NONICKNAMEGIVEN, client.nick, client.t("No nickname given"))
return false return false
} }
if err != nil || len(nickname) > server.Limits().NickLen || restrictedNicknames[cfnick] { if err != nil || len(nickname) > server.Limits().NickLen || restrictedNicknames[cfnick] {
client.Send(nil, server.name, ERR_ERRONEUSNICKNAME, client.nick, nickname, "Erroneous nickname") client.Send(nil, server.name, ERR_ERRONEUSNICKNAME, client.nick, nickname, client.t("Erroneous nickname"))
return false return false
} }
@ -54,10 +54,10 @@ func performNickChange(server *Server, client *Client, target *Client, newnick s
origNickMask := target.NickMaskString() origNickMask := target.NickMaskString()
err = client.server.clients.SetNick(target, nickname) err = client.server.clients.SetNick(target, nickname)
if err == ErrNicknameInUse { if err == ErrNicknameInUse {
client.Send(nil, server.name, ERR_NICKNAMEINUSE, client.nick, nickname, "Nickname is already in use") client.Send(nil, server.name, ERR_NICKNAMEINUSE, client.nick, nickname, client.t("Nickname is already in use"))
return false return false
} else if err != nil { } else if err != nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "NICK", fmt.Sprintf("Could not set or change nickname: %s", err.Error())) client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "NICK", fmt.Sprintf(client.t("Could not set or change nickname: %s"), err.Error()))
return false return false
} }
@ -83,7 +83,7 @@ func sanickHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
targetNick := strings.TrimSpace(msg.Params[0]) targetNick := strings.TrimSpace(msg.Params[0])
target := server.clients.Get(targetNick) target := server.clients.Get(targetNick)
if target == nil { if target == nil {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, msg.Params[0], "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, msg.Params[0], client.t("No such nick"))
return false return false
} }
return performNickChange(server, client, target, msg.Params[1]) return performNickChange(server, client, target, msg.Params[1])

View File

@ -20,5 +20,5 @@ func (server *Server) nickservReceiveNotice(client *Client, message string) {
} }
func (server *Server) nickservReceivePrivmsg(client *Client, message string) { func (server *Server) nickservReceivePrivmsg(client *Client, message string) {
client.Notice("NickServ is not yet implemented, sorry! To register an account, check /HELPOP REG") client.Notice(client.t("NickServ is not yet implemented, sorry! To register an account, check /HELPOP REG"))
} }

View File

@ -34,7 +34,7 @@ func npcHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
_, err := CasefoldName(fakeSource) _, err := CasefoldName(fakeSource)
if err != nil { if err != nil {
client.Send(nil, client.server.name, ERR_CANNOTSENDRP, target, "Fake source must be a valid nickname") client.Send(nil, client.server.name, ERR_CANNOTSENDRP, target, client.t("Fake source must be a valid nickname"))
return false return false
} }
@ -54,7 +54,7 @@ func npcaHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
_, err := CasefoldName(fakeSource) _, err := CasefoldName(fakeSource)
if err != nil { if err != nil {
client.Send(nil, client.server.name, ERR_CANNOTSENDRP, target, "Fake source must be a valid nickname") client.Send(nil, client.server.name, ERR_CANNOTSENDRP, target, client.t("Fake source must be a valid nickname"))
return false return false
} }
@ -74,17 +74,17 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
if cerr == nil { if cerr == nil {
channel := server.channels.Get(target) channel := server.channels.Get(target)
if channel == nil { if channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, client.t("No such channel"))
return return
} }
if !channel.CanSpeak(client) { if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
return return
} }
if !channel.flags[ChanRoleplaying] { if !channel.flags[ChanRoleplaying] {
client.Send(nil, client.server.name, ERR_CANNOTSENDRP, channel.name, "Channel doesn't have roleplaying mode available") client.Send(nil, client.server.name, ERR_CANNOTSENDRP, channel.name, client.t("Channel doesn't have roleplaying mode available"))
return return
} }
@ -98,12 +98,12 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
target, err := CasefoldName(targetString) target, err := CasefoldName(targetString)
user := server.clients.Get(target) user := server.clients.Get(target)
if err != nil || user == nil { if err != nil || user == nil {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, client.t("No such nick"))
return return
} }
if !user.flags[UserRoleplaying] { if !user.flags[UserRoleplaying] {
client.Send(nil, client.server.name, ERR_CANNOTSENDRP, user.nick, "User doesn't have roleplaying mode enabled") client.Send(nil, client.server.name, ERR_CANNOTSENDRP, user.nick, client.t("User doesn't have roleplaying mode enabled"))
return return
} }

View File

@ -44,10 +44,6 @@ var (
RenamePrivsNeeded = errors.New("Only chanops can rename channels") RenamePrivsNeeded = errors.New("Only chanops can rename channels")
) )
const (
rawIONotice = "This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."
)
// Limits holds the maximum limits for various things such as topic lengths. // Limits holds the maximum limits for various things such as topic lengths.
type Limits struct { type Limits struct {
AwayLen int AwayLen int
@ -423,7 +419,7 @@ func (server *Server) tryRegister(c *Client) {
if info.Time != nil { if info.Time != nil {
reason += fmt.Sprintf(" [%s]", info.Time.Duration.String()) reason += fmt.Sprintf(" [%s]", info.Time.Duration.String())
} }
c.Quit(fmt.Sprintf("You are banned from this server (%s)", reason)) c.Quit(fmt.Sprintf(c.t("You are banned from this server (%s)"), reason))
c.destroy(false) c.destroy(false)
return return
} }
@ -437,15 +433,15 @@ func (server *Server) tryRegister(c *Client) {
//NOTE(dan): we specifically use the NICK here instead of the nickmask //NOTE(dan): we specifically use the NICK here instead of the nickmask
// see http://modern.ircdocs.horse/#rplwelcome-001 for details on why we avoid using the nickmask // see http://modern.ircdocs.horse/#rplwelcome-001 for details on why we avoid using the nickmask
c.Send(nil, server.name, RPL_WELCOME, c.nick, fmt.Sprintf(c.t("Welcome to the Internet Relay Network %s"), c.nick)) c.Send(nil, server.name, RPL_WELCOME, c.nick, fmt.Sprintf(c.t("Welcome to the Internet Relay Network %s"), c.nick))
c.Send(nil, server.name, RPL_YOURHOST, c.nick, fmt.Sprintf("Your host is %s, running version %s", server.name, Ver)) c.Send(nil, server.name, RPL_YOURHOST, c.nick, fmt.Sprintf(c.t("Your host is %s, running version %s"), server.name, Ver))
c.Send(nil, server.name, RPL_CREATED, c.nick, fmt.Sprintf("This server was created %s", server.ctime.Format(time.RFC1123))) c.Send(nil, server.name, RPL_CREATED, c.nick, fmt.Sprintf(c.t("This server was created %s"), server.ctime.Format(time.RFC1123)))
//TODO(dan): Look at adding last optional [<channel modes with a parameter>] parameter //TODO(dan): Look at adding last optional [<channel modes with a parameter>] parameter
c.Send(nil, server.name, RPL_MYINFO, c.nick, server.name, Ver, supportedUserModesString, supportedChannelModesString) c.Send(nil, server.name, RPL_MYINFO, c.nick, server.name, Ver, supportedUserModesString, supportedChannelModesString)
c.RplISupport() c.RplISupport()
server.MOTD(c) server.MOTD(c)
c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString()) c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString())
if server.logger.IsLoggingRawIO() { if server.logger.IsLoggingRawIO() {
c.Notice(rawIONotice) c.Notice(c.t("This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
} }
// if resumed, send fake channel joins // if resumed, send fake channel joins
@ -500,15 +496,15 @@ func (server *Server) MOTD(client *Client) {
server.configurableStateMutex.RUnlock() server.configurableStateMutex.RUnlock()
if len(motdLines) < 1 { if len(motdLines) < 1 {
client.Send(nil, server.name, ERR_NOMOTD, client.nick, "MOTD File is missing") client.Send(nil, server.name, ERR_NOMOTD, client.nick, client.t("MOTD File is missing"))
return return
} }
client.Send(nil, server.name, RPL_MOTDSTART, client.nick, fmt.Sprintf("- %s Message of the day - ", server.name)) client.Send(nil, server.name, RPL_MOTDSTART, client.nick, fmt.Sprintf(client.t("- %s Message of the day - "), server.name))
for _, line := range motdLines { for _, line := range motdLines {
client.Send(nil, server.name, RPL_MOTD, client.nick, line) client.Send(nil, server.name, RPL_MOTD, client.nick, line)
} }
client.Send(nil, server.name, RPL_ENDOFMOTD, client.nick, "End of MOTD command") client.Send(nil, server.name, RPL_ENDOFMOTD, client.nick, client.t("End of MOTD command"))
} }
// //
@ -518,7 +514,7 @@ func (server *Server) MOTD(client *Client) {
// PASS <password> // PASS <password>
func passHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func passHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if client.registered { if client.registered {
client.Send(nil, server.name, ERR_ALREADYREGISTRED, client.nick, "You may not reregister") client.Send(nil, server.name, ERR_ALREADYREGISTRED, client.nick, client.t("You may not reregister"))
return false return false
} }
@ -531,8 +527,8 @@ func passHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// check the provided password // check the provided password
password := []byte(msg.Params[0]) password := []byte(msg.Params[0])
if passwd.ComparePassword(server.password, password) != nil { if passwd.ComparePassword(server.password, password) != nil {
client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, "Password incorrect") client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, client.t("Password incorrect"))
client.Send(nil, server.name, "ERROR", "Password incorrect") client.Send(nil, server.name, "ERROR", client.t("Password incorrect"))
return true return true
} }
@ -543,7 +539,7 @@ func passHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// USER <username> * 0 <realname> // USER <username> * 0 <realname>
func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if client.registered { if client.registered {
client.Send(nil, server.name, ERR_ALREADYREGISTRED, client.nick, "You may not reregister") client.Send(nil, server.name, ERR_ALREADYREGISTRED, client.nick, client.t("You may not reregister"))
return false return false
} }
@ -560,7 +556,7 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// //
_, err := CasefoldName(msg.Params[0]) _, err := CasefoldName(msg.Params[0])
if err != nil { if err != nil {
client.Send(nil, "", "ERROR", "Malformed username") client.Send(nil, "", "ERROR", client.t("Malformed username"))
return true return true
} }
@ -656,7 +652,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) (resul
founder := channel.Founder() founder := channel.Founder()
if founder != "" && founder != client.AccountName() { if founder != "" && founder != client.AccountName() {
//TODO(dan): Change this to ERR_CANNOTRENAME //TODO(dan): Change this to ERR_CANNOTRENAME
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "RENAME", oldName, "Only channel founders can change registered channels") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "RENAME", oldName, client.t("Only channel founders can change registered channels"))
return false return false
} }
@ -675,7 +671,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) (resul
if mcl.capabilities.Has(caps.Rename) { if mcl.capabilities.Has(caps.Rename) {
mcl.Send(nil, client.nickMaskString, "RENAME", oldName, newName, reason) mcl.Send(nil, client.nickMaskString, "RENAME", oldName, newName, reason)
} else { } else {
mcl.Send(nil, mcl.nickMaskString, "PART", oldName, fmt.Sprintf("Channel renamed: %s", reason)) mcl.Send(nil, mcl.nickMaskString, "PART", oldName, fmt.Sprintf(mcl.t("Channel renamed: %s"), reason))
if mcl.capabilities.Has(caps.ExtendedJoin) { if mcl.capabilities.Has(caps.ExtendedJoin) {
accountName := "*" accountName := "*"
if mcl.account != nil { if mcl.account != nil {
@ -695,7 +691,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage) (resul
func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// kill JOIN 0 requests // kill JOIN 0 requests
if msg.Params[0] == "0" { if msg.Params[0] == "0" {
client.Notice("JOIN 0 is not allowed") client.Notice(client.t("JOIN 0 is not allowed"))
return false return false
} }
@ -713,7 +709,7 @@ func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
err := server.channels.Join(client, name, key) err := server.channels.Join(client, name, key)
if err == NoSuchChannel { if err == NoSuchChannel {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), name, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.Nick(), name, client.t("No such channel"))
} }
} }
return false return false
@ -730,7 +726,7 @@ func partHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for _, chname := range channels { for _, chname := range channels {
err := server.channels.Part(client, chname, reason) err := server.channels.Part(client, chname, reason)
if err == NoSuchChannel { if err == NoSuchChannel {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, client.t("No such channel"))
} }
} }
return false return false
@ -742,7 +738,7 @@ func topicHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
channel := server.channels.Get(name) channel := server.channels.Get(name)
if err != nil || channel == nil { if err != nil || channel == nil {
if len(msg.Params[0]) > 0 { if len(msg.Params[0]) > 0 {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, msg.Params[0], "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, msg.Params[0], client.t("No such channel"))
} }
return false return false
} }
@ -844,11 +840,11 @@ func privmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
if err == nil { if err == nil {
channel := server.channels.Get(target) channel := server.channels.Get(target)
if channel == nil { if channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, client.t("No such channel"))
continue continue
} }
if !channel.CanSpeak(client) { if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
continue continue
} }
msgid := server.generateMessageID() msgid := server.generateMessageID()
@ -917,11 +913,11 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if err == nil { if err == nil {
channel := server.channels.Get(target) channel := server.channels.Get(target)
if channel == nil { if channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, targetString, client.t("No such channel"))
continue continue
} }
if !channel.CanSpeak(client) { if !channel.CanSpeak(client) {
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, "Cannot send to channel") client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.name, client.t("Cannot send to channel"))
continue continue
} }
msgid := server.generateMessageID() msgid := server.generateMessageID()
@ -932,7 +928,7 @@ func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
user := server.clients.Get(target) user := server.clients.Get(target)
if err != nil || user == nil { if err != nil || user == nil {
if len(target) > 0 { if len(target) > 0 {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, target, client.t("No such nick"))
} }
continue continue
} }
@ -982,7 +978,7 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
if len(strings.TrimSpace(masksString)) < 1 { if len(strings.TrimSpace(masksString)) < 1 {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, "No masks given") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("No masks given"))
return false return false
} }
@ -991,12 +987,12 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for _, mask := range masks { for _, mask := range masks {
casefoldedMask, err := Casefold(mask) casefoldedMask, err := Casefold(mask)
if err != nil { if err != nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
continue continue
} }
matches := server.clients.FindAll(casefoldedMask) matches := server.clients.FindAll(casefoldedMask)
if len(matches) == 0 { if len(matches) == 0 {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
continue continue
} }
for mclient := range matches { for mclient := range matches {
@ -1008,13 +1004,13 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0]) casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0])
mclient := server.clients.Get(casefoldedMask) mclient := server.clients.Get(casefoldedMask)
if err != nil || mclient == nil { if err != nil || mclient == nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, client.t("No such nick"))
// fall through, ENDOFWHOIS is always sent // fall through, ENDOFWHOIS is always sent
} else { } else {
client.getWhoisOf(mclient) client.getWhoisOf(mclient)
} }
} }
client.Send(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, "End of /WHOIS list") client.Send(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, client.t("End of /WHOIS list"))
return false return false
} }
@ -1032,17 +1028,17 @@ func (client *Client) getWhoisOf(target *Client) {
client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine) client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine)
} }
if client.flags[Operator] || client == target { if client.flags[Operator] || client == target {
client.Send(nil, client.server.name, RPL_WHOISACTUALLY, client.nick, target.nick, fmt.Sprintf("%s@%s", target.username, utils.LookupHostname(target.IPString())), target.IPString(), "Actual user@host, Actual IP") client.Send(nil, client.server.name, RPL_WHOISACTUALLY, client.nick, target.nick, fmt.Sprintf("%s@%s", target.username, utils.LookupHostname(target.IPString())), target.IPString(), client.t("Actual user@host, Actual IP"))
} }
if target.flags[TLS] { if target.flags[TLS] {
client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, "is using a secure connection") client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, client.t("is using a secure connection"))
} }
accountName := target.AccountName() accountName := target.AccountName()
if accountName != "" { if accountName != "" {
client.Send(nil, client.server.name, RPL_WHOISACCOUNT, client.nick, accountName, "is logged in as") client.Send(nil, client.server.name, RPL_WHOISACCOUNT, client.nick, accountName, client.t("is logged in as"))
} }
if target.flags[Bot] { if target.flags[Bot] {
client.Send(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape("is a $bBot$b on ")+client.server.networkName) client.Send(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape(fmt.Sprintf(client.t("is a $bBot$b on %s"), client.server.networkName)))
} }
if 0 < len(target.languages) { if 0 < len(target.languages) {
@ -1050,14 +1046,14 @@ func (client *Client) getWhoisOf(target *Client) {
for _, str := range client.server.languages.Codes(target.languages) { for _, str := range client.server.languages.Codes(target.languages) {
params = append(params, str) params = append(params, str)
} }
params = append(params, "can speak these languages") params = append(params, client.t("can speak these languages"))
client.Send(nil, client.server.name, RPL_WHOISLANGUAGE, params...) client.Send(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
} }
if target.certfp != "" && (client.flags[Operator] || client == target) { if target.certfp != "" && (client.flags[Operator] || client == target) {
client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf("has client certificate fingerprint %s", target.certfp)) client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf(client.t("has client certificate fingerprint %s"), target.certfp))
} }
client.Send(nil, client.server.name, RPL_WHOISIDLE, client.nick, target.nick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), "seconds idle, signon time") client.Send(nil, client.server.name, RPL_WHOISIDLE, client.nick, target.nick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
} }
// rplWhoReply returns the WHO reply between one user and another channel/user. // rplWhoReply returns the WHO reply between one user and another channel/user.
@ -1094,7 +1090,7 @@ func whoChannel(client *Client, channel *Channel, friends ClientSet) {
// WHO [ <mask> [ "o" ] ] // WHO [ <mask> [ "o" ] ]
func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if msg.Params[0] == "" { if msg.Params[0] == "" {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "WHO", "First param must be a mask or channel") client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "WHO", client.t("First param must be a mask or channel"))
return false return false
} }
@ -1102,7 +1098,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if len(msg.Params) > 0 { if len(msg.Params) > 0 {
casefoldedMask, err := Casefold(msg.Params[0]) casefoldedMask, err := Casefold(msg.Params[0])
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_UNKNOWNERROR, "WHO", "Mask isn't valid") client.Send(nil, server.name, ERR_UNKNOWNERROR, "WHO", client.t("Mask isn't valid"))
return false return false
} }
mask = casefoldedMask mask = casefoldedMask
@ -1130,7 +1126,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
} }
client.Send(nil, server.name, RPL_ENDOFWHO, client.nick, mask, "End of WHO list") client.Send(nil, server.name, RPL_ENDOFWHO, client.nick, mask, client.t("End of WHO list"))
return false return false
} }
@ -1138,11 +1134,11 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
name, err := CasefoldName(msg.Params[0]) name, err := CasefoldName(msg.Params[0])
if err != nil { if err != nil {
client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, "Password incorrect") client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, client.t("Password incorrect"))
return true return true
} }
if client.flags[Operator] == true { if client.flags[Operator] == true {
client.Send(nil, server.name, ERR_UNKNOWNERROR, "OPER", "You're already opered-up!") client.Send(nil, server.name, ERR_UNKNOWNERROR, "OPER", client.t("You're already opered-up!"))
return false return false
} }
server.configurableStateMutex.RLock() server.configurableStateMutex.RLock()
@ -1152,7 +1148,7 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
password := []byte(msg.Params[1]) password := []byte(msg.Params[1])
err = passwd.ComparePassword(oper.Pass, password) err = passwd.ComparePassword(oper.Pass, password)
if (oper.Pass == nil) || (err != nil) { if (oper.Pass == nil) || (err != nil) {
client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, "Password incorrect") client.Send(nil, server.name, ERR_PASSWDMISMATCH, client.nick, client.t("Password incorrect"))
return true return true
} }
@ -1181,11 +1177,11 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
for r := range unknownChanges { for r := range unknownChanges {
runes += string(r) runes += string(r)
} }
client.Notice(fmt.Sprintf("Could not apply mode changes: +%s", runes)) client.Notice(fmt.Sprintf(client.t("Could not apply mode changes: +%s"), runes))
} }
} }
client.Send(nil, server.name, RPL_YOUREOPER, client.nick, "You are now an IRC operator") client.Send(nil, server.name, RPL_YOUREOPER, client.nick, client.t("You are now an IRC operator"))
applied = append(applied, ModeChange{ applied = append(applied, ModeChange{
mode: Operator, mode: Operator,
@ -1464,7 +1460,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
} }
if sendRawOutputNotice { if sendRawOutputNotice {
sClient.Notice(rawIONotice) sClient.Notice(sClient.t("This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
} }
} }
} }
@ -1626,7 +1622,7 @@ func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
err := server.rehash() err := server.rehash()
if err == nil { if err == nil {
client.Send(nil, server.name, RPL_REHASHING, client.nick, "ircd.yaml", "Rehashing") client.Send(nil, server.name, RPL_REHASHING, client.nick, "ircd.yaml", client.t("Rehashing"))
} else { } else {
server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error())) server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error()))
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REHASH", err.Error()) client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REHASH", err.Error())
@ -1657,10 +1653,10 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
var op ModeOp var op ModeOp
if client.flags[Away] { if client.flags[Away] {
op = Add op = Add
client.Send(nil, server.name, RPL_NOWAWAY, client.nick, "You have been marked as being away") client.Send(nil, server.name, RPL_NOWAWAY, client.nick, client.t("You have been marked as being away"))
} else { } else {
op = Remove op = Remove
client.Send(nil, server.name, RPL_UNAWAY, client.nick, "You are no longer marked as being away") client.Send(nil, server.name, RPL_UNAWAY, client.nick, client.t("You are no longer marked as being away"))
} }
//TODO(dan): Should this be sent automagically as part of setting the flag/mode? //TODO(dan): Should this be sent automagically as part of setting the flag/mode?
modech := ModeChanges{ModeChange{ modech := ModeChanges{ModeChange{
@ -1784,7 +1780,7 @@ func kickHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
channels := strings.Split(msg.Params[0], ",") channels := strings.Split(msg.Params[0], ",")
users := strings.Split(msg.Params[1], ",") users := strings.Split(msg.Params[1], ",")
if (len(channels) != len(users)) && (len(users) != 1) { if (len(channels) != len(users)) && (len(users) != 1) {
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, "KICK", "Not enough parameters") client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nick, "KICK", client.t("Not enough parameters"))
return false return false
} }
@ -1807,14 +1803,14 @@ func kickHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
casefoldedChname, err := CasefoldChannel(chname) casefoldedChname, err := CasefoldChannel(chname)
channel := server.channels.Get(casefoldedChname) channel := server.channels.Get(casefoldedChname)
if err != nil || channel == nil { if err != nil || channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, client.t("No such channel"))
continue continue
} }
casefoldedNickname, err := CasefoldName(nickname) casefoldedNickname, err := CasefoldName(nickname)
target := server.clients.Get(casefoldedNickname) target := server.clients.Get(casefoldedNickname)
if err != nil || target == nil { if err != nil || target == nil {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, nickname, "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, nickname, client.t("No such nick"))
continue continue
} }
@ -1912,7 +1908,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
channel := server.channels.Get(casefoldedChname) channel := server.channels.Get(casefoldedChname)
if err != nil || channel == nil || (!client.flags[Operator] && channel.flags[Secret]) { if err != nil || channel == nil || (!client.flags[Operator] && channel.flags[Secret]) {
if len(chname) > 0 { if len(chname) > 0 {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, client.t("No such channel"))
} }
continue continue
} }
@ -1921,7 +1917,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
} }
} }
client.Send(nil, server.name, RPL_LISTEND, client.nick, "End of LIST") client.Send(nil, server.name, RPL_LISTEND, client.nick, client.t("End of LIST"))
return false return false
} }
@ -1970,7 +1966,7 @@ func namesHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
channel := server.channels.Get(casefoldedChname) channel := server.channels.Get(casefoldedChname)
if err != nil || channel == nil { if err != nil || channel == nil {
if len(chname) > 0 { if len(chname) > 0 {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, chname, client.t("No such channel"))
} }
continue continue
} }
@ -1987,7 +1983,7 @@ func versionHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
} }
casefoldedTarget, err := Casefold(target) casefoldedTarget, err := Casefold(target)
if target != "" && (err != nil || casefoldedTarget != server.nameCasefolded) { if target != "" && (err != nil || casefoldedTarget != server.nameCasefolded) {
client.Send(nil, server.name, ERR_NOSUCHSERVER, client.nick, target, "No such server") client.Send(nil, server.name, ERR_NOSUCHSERVER, client.nick, target, client.t("No such server"))
return false return false
} }
@ -2004,14 +2000,14 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
casefoldedNickname, err := CasefoldName(nickname) casefoldedNickname, err := CasefoldName(nickname)
target := server.clients.Get(casefoldedNickname) target := server.clients.Get(casefoldedNickname)
if err != nil || target == nil { if err != nil || target == nil {
client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, nickname, "No such nick") client.Send(nil, server.name, ERR_NOSUCHNICK, client.nick, nickname, client.t("No such nick"))
return false return false
} }
casefoldedChannelName, err := CasefoldChannel(channelName) casefoldedChannelName, err := CasefoldChannel(channelName)
channel := server.channels.Get(casefoldedChannelName) channel := server.channels.Get(casefoldedChannelName)
if err != nil || channel == nil { if err != nil || channel == nil {
client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, channelName, "No such channel") client.Send(nil, server.name, ERR_NOSUCHCHANNEL, client.nick, channelName, client.t("No such channel"))
return false return false
} }
@ -2027,7 +2023,7 @@ func timeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
casefoldedTarget, err := Casefold(target) casefoldedTarget, err := Casefold(target)
if (target != "") && err != nil || (casefoldedTarget != server.nameCasefolded) { if (target != "") && err != nil || (casefoldedTarget != server.nameCasefolded) {
client.Send(nil, server.name, ERR_NOSUCHSERVER, client.nick, target, "No such server") client.Send(nil, server.name, ERR_NOSUCHSERVER, client.nick, target, client.t("No such server"))
return false return false
} }
client.Send(nil, server.name, RPL_TIME, client.nick, server.name, time.Now().Format(time.RFC1123)) client.Send(nil, server.name, RPL_TIME, client.nick, server.name, time.Now().Format(time.RFC1123))
@ -2045,7 +2041,7 @@ func killHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
casefoldedNickname, err := CasefoldName(nickname) casefoldedNickname, err := CasefoldName(nickname)
target := server.clients.Get(casefoldedNickname) target := server.clients.Get(casefoldedNickname)
if err != nil || target == nil { if err != nil || target == nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nickname, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nickname, client.t("No such nick"))
return false return false
} }
@ -2075,7 +2071,7 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
results := server.whoWas.Find(nickname, count) results := server.whoWas.Find(nickname, count)
if len(results) == 0 { if len(results) == 0 {
if len(nickname) > 0 { if len(nickname) > 0 {
client.Send(nil, server.name, ERR_WASNOSUCHNICK, client.nick, nickname, "There was no such nickname") client.Send(nil, server.name, ERR_WASNOSUCHNICK, client.nick, nickname, client.t("There was no such nickname"))
} }
} else { } else {
for _, whoWas := range results { for _, whoWas := range results {
@ -2083,7 +2079,7 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
} }
} }
if len(nickname) > 0 { if len(nickname) > 0 {
client.Send(nil, server.name, RPL_ENDOFWHOWAS, client.nick, nickname, "End of WHOWAS") client.Send(nil, server.name, RPL_ENDOFWHOWAS, client.nick, nickname, client.t("End of WHOWAS"))
} }
} }
return false return false
@ -2103,10 +2099,10 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
opercount++ opercount++
} }
} }
client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf("There are %d users and %d invisible on %d server(s)", totalcount, invisiblecount, 1)) client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf(client.t("There are %d users and %d invisible on %d server(s)"), totalcount, invisiblecount, 1))
client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf("%d IRC Operators online", opercount)) client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf(client.t("%d IRC Operators online"), opercount))
client.Send(nil, server.name, RPL_LUSERCHANNELS, client.nick, fmt.Sprintf("%d channels formed", server.channels.Len())) client.Send(nil, server.name, RPL_LUSERCHANNELS, client.nick, fmt.Sprintf(client.t("%d channels formed"), server.channels.Len()))
client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf("I have %d clients and %d servers", totalcount, 1)) client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf(client.t("I have %d clients and %d servers"), totalcount, 1))
return false return false
} }
@ -2122,12 +2118,12 @@ func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
oldnick := msg.Params[0] oldnick := msg.Params[0]
if strings.Contains(oldnick, " ") { if strings.Contains(oldnick, " ") {
client.Send(nil, server.name, ERR_CANNOT_RESUME, "*", "Cannot resume connection, old nickname contains spaces") client.Send(nil, server.name, ERR_CANNOT_RESUME, "*", client.t("Cannot resume connection, old nickname contains spaces"))
return false return false
} }
if client.Registered() { if client.Registered() {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Cannot resume connection, connection registration has already been completed") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Cannot resume connection, connection registration has already been completed"))
return false return false
} }
@ -2137,7 +2133,7 @@ func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
if err == nil { if err == nil {
timestamp = &ts timestamp = &ts
} else { } else {
client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, "Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it") client.Send(nil, server.name, ERR_CANNOT_RESUME, oldnick, client.t("Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it"))
} }
} }
@ -2161,7 +2157,7 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
casefoldedNickname, err := CasefoldName(nickname) casefoldedNickname, err := CasefoldName(nickname)
target := server.clients.Get(casefoldedNickname) target := server.clients.Get(casefoldedNickname)
if err != nil || target == nil { if err != nil || target == nil {
client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nickname, "No such nick") client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, nickname, client.t("No such nick"))
return false return false
} }
if returnedNicks[casefoldedNickname] { if returnedNicks[casefoldedNickname] {
@ -2194,7 +2190,7 @@ func languageHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
supportedLanguagesCount := server.languages.Count() supportedLanguagesCount := server.languages.Count()
if supportedLanguagesCount < len(msg.Params) { if supportedLanguagesCount < len(msg.Params) {
client.Send(nil, client.server.name, ERR_TOOMANYLANGUAGES, client.nick, strconv.Itoa(supportedLanguagesCount), "You specified too many languages") client.Send(nil, client.server.name, ERR_TOOMANYLANGUAGES, client.nick, strconv.Itoa(supportedLanguagesCount), client.t("You specified too many languages"))
return false return false
} }
@ -2210,7 +2206,7 @@ func languageHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
_, exists := server.languages.Info[value] _, exists := server.languages.Info[value]
if !exists { if !exists {
client.Send(nil, client.server.name, ERR_NOLANGUAGE, client.nick, "Languages are not supported by this server") client.Send(nil, client.server.name, ERR_NOLANGUAGE, client.nick, client.t("Languages are not supported by this server"))
return false return false
} }