3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

clientbot: ping/pong support

This commit is contained in:
James Lu 2016-07-17 20:20:49 -07:00
parent 58fa769ba0
commit e0b254e6ad

View File

@ -84,8 +84,9 @@ class ClientbotWrapperProtocol(Protocol):
log.debug('(%s) join: faking JOIN of client %s/%s to %s', self.irc.name, client,
self.irc.getFriendlyName(client), channel)
def ping(self, *args):
return
def ping(self, source=None, target=None):
if self.irc.uplink:
self.irc.send('PING %s' % self.irc.getFriendlyName(self.irc.uplink))
def handle_events(self, data):
"""Event handler for the RFC1459 (clientbot) protocol.
@ -100,7 +101,7 @@ class ClientbotWrapperProtocol(Protocol):
except IndexError:
# Raw command without an explicit sender; assume it's being sent by our uplink.
args = self.parseArgs(data)
sender = self.irc.uplink
idsource = sender = self.irc.uplink
command = args[0]
args = args[1:]
else:
@ -146,4 +147,18 @@ class ClientbotWrapperProtocol(Protocol):
self.irc.connected.set()
return {'parse_as': 'ENDBURST'}
def handle_ping(self, source, command, args):
"""
Handles incoming PING requests.
"""
self.irc.send('PONG :%s' % args[0])
def handle_pong(self, source, command, args):
"""
Handles incoming PONG.
"""
if source == self.irc.uplink:
self.irc.lastping = time.time()
Class = ClientbotWrapperProtocol