mirror of
				https://github.com/fluffle/goirc
				synced 2025-11-04 03:58:03 +00:00 
			
		
		
		
	Use a static map of event handlers for internal handlers too.
This commit is contained in:
		
							parent
							
								
									aa75e0e0c6
								
							
						
					
					
						commit
						3feaa7f302
					
				
					 1 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -33,12 +33,20 @@ func NewHandler(f IRCHandler) event.Handler {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// sets up the internal event handlers to do essential IRC protocol things
 | 
			
		||||
var intHandlers map[string]event.Handler
 | 
			
		||||
func init() {
 | 
			
		||||
	intHandlers = make(map[string]event.Handler)
 | 
			
		||||
	intHandlers["001"] = NewHandler((*Conn).h_001)
 | 
			
		||||
	intHandlers["433"] = NewHandler((*Conn).h_433)
 | 
			
		||||
	intHandlers["CTCP"] = NewHandler((*Conn).h_CTCP)
 | 
			
		||||
	intHandlers["NICK"] = NewHandler((*Conn).h_NICK)
 | 
			
		||||
	intHandlers["PING"] = NewHandler((*Conn).h_PING)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (conn *Conn) addIntHandlers() {
 | 
			
		||||
	conn.AddHandler("001", (*Conn).h_001)
 | 
			
		||||
	conn.AddHandler("433", (*Conn).h_433)
 | 
			
		||||
	conn.AddHandler("CTCP", (*Conn).h_CTCP)
 | 
			
		||||
	conn.AddHandler("NICK", (*Conn).h_NICK)
 | 
			
		||||
	conn.AddHandler("PING", (*Conn).h_PING)
 | 
			
		||||
	for n, h := range intHandlers {
 | 
			
		||||
		conn.ER.AddHandler(h, n)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Basic ping/pong handler
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue