ircbot: guess at nickmask in __init__()
some ircds don't lead to a welcome signal, so our attempts to set the nickmask there may never happen. guess at one first, in the event that _on_welcome() never fires
This commit is contained in:
		
							parent
							
								
									c9542c1617
								
							
						
					
					
						commit
						ed5f164092
					
				| @ -7,6 +7,7 @@ import collections | |||||||
| import copy | import copy | ||||||
| import logging | import logging | ||||||
| import re | import re | ||||||
|  | import socket | ||||||
| import ssl | import ssl | ||||||
| import sys | import sys | ||||||
| 
 | 
 | ||||||
| @ -304,6 +305,14 @@ class IRCBot(irc.client.SimpleIRCClient): | |||||||
|         self._nickname = settings.IRCBOT_NICKNAME |         self._nickname = settings.IRCBOT_NICKNAME | ||||||
|         self._realname = settings.IRCBOT_REALNAME |         self._realname = settings.IRCBOT_REALNAME | ||||||
| 
 | 
 | ||||||
|  |         # guess at nickmask. hopefully _on_welcome() will set this, but this should be | ||||||
|  |         # a pretty good guess if not | ||||||
|  |         nick = self._nickname | ||||||
|  |         user = self._nickname | ||||||
|  |         host = socket.getfqdn() | ||||||
|  |         self.nickmask = "{0:s}!~{1:s}@{2:s}".format(nick, user, host) | ||||||
|  |         log.debug("guessing at nickmask '{0:s}'".format(self.nickmask)) | ||||||
|  | 
 | ||||||
|         # handlers |         # handlers | ||||||
|         for i in ['disconnect', 'join', 'kick', 'mode', 'namreply', 'nick', 'part', 'quit', 'welcome']: |         for i in ['disconnect', 'join', 'kick', 'mode', 'namreply', 'nick', 'part', 'quit', 'welcome']: | ||||||
|             self.connection.add_global_handler(i, getattr(self, '_on_' + i), -20) |             self.connection.add_global_handler(i, getattr(self, '_on_' + i), -20) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user