comparison irclib.py @ 75:6034087b1d10

First hack at pings Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Thu, 03 Sep 2009 18:56:58 +0200
parents 676c2d2bf240
children 75a05faea5ca
comparison
equal deleted inserted replaced
74:676c2d2bf240 75:6034087b1d10
408 408
409 def __str__(self): 409 def __str__(self):
410 return self.real_nickname+' at '+self.server+':'+str(self.port) 410 return self.real_nickname+' at '+self.server+':'+str(self.port)
411 411
412 412
413 def _ping(self):
414 self.irclibobj.execute_delayed(60, self._ping)
415 if self.connected == False:
416 return
417 self.irclibobj.bot.error('=> Debug: sending IRC ping', debug=True)
418 self.ping(self.get_server_name())
419
420
413 def connect(self, password=None, username=None, 421 def connect(self, password=None, username=None,
414 ircname=None, localaddress="", localport=0, ssl=False, ipv6=False, nick_callback=None): 422 ircname=None, localaddress="", localport=0, ssl=False, ipv6=False, nick_callback=None):
415 """Connect to the server. 423 """Connect to the server.
416 424
417 Arguments: 425 Arguments:
459 self.localaddress = localaddress 467 self.localaddress = localaddress
460 self.localport = localport 468 self.localport = localport
461 self.localhost = socket.gethostname() 469 self.localhost = socket.gethostname()
462 470
463 self.irclibobj.bot.error('===> Debug: opening new IRC connection for '+self.__str__(), debug=True) 471 self.irclibobj.bot.error('===> Debug: opening new IRC connection for '+self.__str__(), debug=True)
472 self._ping()
464 473
465 if ipv6: 474 if ipv6:
466 self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) 475 self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
467 else: 476 else:
468 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 477 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)