mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
clientbot: ping/pong support
This commit is contained in:
parent
58fa769ba0
commit
e0b254e6ad
@ -84,8 +84,9 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
log.debug('(%s) join: faking JOIN of client %s/%s to %s', self.irc.name, client,
|
log.debug('(%s) join: faking JOIN of client %s/%s to %s', self.irc.name, client,
|
||||||
self.irc.getFriendlyName(client), channel)
|
self.irc.getFriendlyName(client), channel)
|
||||||
|
|
||||||
def ping(self, *args):
|
def ping(self, source=None, target=None):
|
||||||
return
|
if self.irc.uplink:
|
||||||
|
self.irc.send('PING %s' % self.irc.getFriendlyName(self.irc.uplink))
|
||||||
|
|
||||||
def handle_events(self, data):
|
def handle_events(self, data):
|
||||||
"""Event handler for the RFC1459 (clientbot) protocol.
|
"""Event handler for the RFC1459 (clientbot) protocol.
|
||||||
@ -100,7 +101,7 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
# Raw command without an explicit sender; assume it's being sent by our uplink.
|
# Raw command without an explicit sender; assume it's being sent by our uplink.
|
||||||
args = self.parseArgs(data)
|
args = self.parseArgs(data)
|
||||||
sender = self.irc.uplink
|
idsource = sender = self.irc.uplink
|
||||||
command = args[0]
|
command = args[0]
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
else:
|
else:
|
||||||
@ -146,4 +147,18 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
self.irc.connected.set()
|
self.irc.connected.set()
|
||||||
return {'parse_as': 'ENDBURST'}
|
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
|
Class = ClientbotWrapperProtocol
|
||||||
|
Loading…
Reference in New Issue
Block a user