Browse Source

Merge pull request #2030 from slingamn/roundtime

round wait times to the nearest millisecond
tags/v2.12.0-rc1
Shivaram Lingamneni 1 year ago
parent
commit
b16350e559
No account linked to committer's email address
3 changed files with 5 additions and 4 deletions
  1. 1
    1
      irc/errors.go
  2. 3
    2
      irc/handlers.go
  3. 1
    1
      irc/nickserv.go

+ 1
- 1
irc/errors.go View File

@@ -97,5 +97,5 @@ type ThrottleError struct {
97 97
 }
98 98
 
99 99
 func (te *ThrottleError) Error() string {
100
-	return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
100
+	return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration.Round(time.Millisecond))
101 101
 }

+ 3
- 2
irc/handlers.go View File

@@ -207,7 +207,8 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.Message, rb
207 207
 	if session.sasl.mechanism == "" {
208 208
 		throttled, remainingTime := client.loginThrottle.Touch()
209 209
 		if throttled {
210
-			rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(), fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
210
+			rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(),
211
+				fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime.Round(time.Millisecond)))
211 212
 			return false
212 213
 		}
213 214
 
@@ -1666,7 +1667,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
1666 1667
 	config := server.Config()
1667 1668
 	if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" && !client.HasMode(modes.Operator) {
1668 1669
 		remaining := time.Until(client.ctime.Add(config.Channels.ListDelay))
1669
-		rb.Notice(fmt.Sprintf(client.t("This server requires that you wait %v after connecting before you can use /LIST. You have %v left."), config.Channels.ListDelay, remaining))
1670
+		rb.Notice(fmt.Sprintf(client.t("This server requires that you wait %v after connecting before you can use /LIST. You have %v left."), config.Channels.ListDelay, remaining.Round(time.Millisecond)))
1670 1671
 		rb.Add(nil, server.name, RPL_LISTEND, client.Nick(), client.t("End of LIST"))
1671 1672
 		return false
1672 1673
 	}

+ 1
- 1
irc/nickserv.go View File

@@ -811,7 +811,7 @@ func nsGroupHandler(service *ircService, server *Server, client *Client, command
811 811
 func nsLoginThrottleCheck(service *ircService, client *Client, rb *ResponseBuffer) (success bool) {
812 812
 	throttled, remainingTime := client.checkLoginThrottle()
813 813
 	if throttled {
814
-		service.Notice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
814
+		service.Notice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime.Round(time.Millisecond)))
815 815
 	}
816 816
 	return !throttled
817 817
 }

Loading…
Cancel
Save