mirror of
				https://github.com/fluffle/goirc
				synced 2025-11-03 19:48:04 +00:00 
			
		
		
		
	Allow renicking to be customised. (Closes #14)
This commit is contained in:
		
							parent
							
								
									f8a786f9c7
								
							
						
					
					
						commit
						831bf7a733
					
				
					 2 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -20,6 +20,9 @@ type Conn struct {
 | 
			
		|||
	Me      *state.Nick
 | 
			
		||||
	Network string
 | 
			
		||||
 | 
			
		||||
	// Replaceable function to customise the 433 handler's new nick
 | 
			
		||||
	NewNick func(string) string
 | 
			
		||||
 | 
			
		||||
	// Event handler registry and dispatcher
 | 
			
		||||
	ER event.EventRegistry
 | 
			
		||||
	ED event.EventDispatcher
 | 
			
		||||
| 
						 | 
				
			
			@ -97,6 +100,7 @@ func Client(nick, ident, name string,
 | 
			
		|||
		SSLConfig: nil,
 | 
			
		||||
		PingFreq:  3 * time.Minute,
 | 
			
		||||
		Flood:     false,
 | 
			
		||||
		NewNick:   func(s string) string { return s + "_" },
 | 
			
		||||
		badness:   0,
 | 
			
		||||
		lastsent:  time.Now(),
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ func (conn *Conn) h_001(line *Line) {
 | 
			
		|||
// Handler to deal with "433 :Nickname already in use"
 | 
			
		||||
func (conn *Conn) h_433(line *Line) {
 | 
			
		||||
	// Args[1] is the new nick we were attempting to acquire
 | 
			
		||||
	neu := line.Args[1] + "_"
 | 
			
		||||
	neu := conn.NewNick(line.Args[1])
 | 
			
		||||
	conn.Nick(neu)
 | 
			
		||||
	// if this is happening before we're properly connected (i.e. the nick
 | 
			
		||||
	// we sent in the initial NICK command is in use) we will not receive
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue