mirror of
				https://github.com/ergochat/ergo.git
				synced 2025-11-03 23:37:22 +01:00 
			
		
		
		
	Merge pull request #2030 from slingamn/roundtime
round wait times to the nearest millisecond
This commit is contained in:
		
						commit
						b16350e559
					
				@ -97,5 +97,5 @@ type ThrottleError struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (te *ThrottleError) Error() string {
 | 
			
		||||
	return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
 | 
			
		||||
	return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration.Round(time.Millisecond))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -207,7 +207,8 @@ func authenticateHandler(server *Server, client *Client, msg ircmsg.Message, rb
 | 
			
		||||
	if session.sasl.mechanism == "" {
 | 
			
		||||
		throttled, remainingTime := client.loginThrottle.Touch()
 | 
			
		||||
		if throttled {
 | 
			
		||||
			rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(), fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
 | 
			
		||||
			rb.Add(nil, server.name, ERR_SASLFAIL, client.Nick(),
 | 
			
		||||
				fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime.Round(time.Millisecond)))
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -1666,7 +1667,7 @@ func listHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
 | 
			
		||||
	config := server.Config()
 | 
			
		||||
	if time.Since(client.ctime) < config.Channels.ListDelay && client.Account() == "" && !client.HasMode(modes.Operator) {
 | 
			
		||||
		remaining := time.Until(client.ctime.Add(config.Channels.ListDelay))
 | 
			
		||||
		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))
 | 
			
		||||
		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)))
 | 
			
		||||
		rb.Add(nil, server.name, RPL_LISTEND, client.Nick(), client.t("End of LIST"))
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -811,7 +811,7 @@ func nsGroupHandler(service *ircService, server *Server, client *Client, command
 | 
			
		||||
func nsLoginThrottleCheck(service *ircService, client *Client, rb *ResponseBuffer) (success bool) {
 | 
			
		||||
	throttled, remainingTime := client.checkLoginThrottle()
 | 
			
		||||
	if throttled {
 | 
			
		||||
		service.Notice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
 | 
			
		||||
		service.Notice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime.Round(time.Millisecond)))
 | 
			
		||||
	}
 | 
			
		||||
	return !throttled
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user