mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
classes: split up run() into run() and runline()
This helps the debugging process, by allowing us to also inject lines directly into the protocol module.
This commit is contained in:
parent
c77f92357a
commit
19c4c2ce3f
33
classes.py
33
classes.py
@ -207,21 +207,24 @@ class Irc():
|
|||||||
line = line.strip(b'\r')
|
line = line.strip(b'\r')
|
||||||
# FIXME: respect other encodings?
|
# FIXME: respect other encodings?
|
||||||
line = line.decode("utf-8", "replace")
|
line = line.decode("utf-8", "replace")
|
||||||
log.debug("(%s) <- %s", self.name, line)
|
self.runline(line)
|
||||||
hook_args = None
|
|
||||||
try:
|
def runline(self, line):
|
||||||
hook_args = self.proto.handle_events(line)
|
"""Sends a command to the protocol module."""
|
||||||
except Exception:
|
log.debug("(%s) <- %s", self.name, line)
|
||||||
log.exception('(%s) Caught error in handle_events, disconnecting!', self.name)
|
try:
|
||||||
log.error('(%s) The offending line was: <- %s', self.name, line)
|
hook_args = self.proto.handle_events(line)
|
||||||
return
|
except Exception:
|
||||||
# Only call our hooks if there's data to process. Handlers that support
|
log.exception('(%s) Caught error in handle_events, disconnecting!', self.name)
|
||||||
# hooks will return a dict of parsed arguments, which can be passed on
|
log.error('(%s) The offending line was: <- %s', self.name, line)
|
||||||
# to plugins and the like. For example, the JOIN handler will return
|
return
|
||||||
# something like: {'channel': '#whatever', 'users': ['UID1', 'UID2',
|
# Only call our hooks if there's data to process. Handlers that support
|
||||||
# 'UID3']}, etc.
|
# hooks will return a dict of parsed arguments, which can be passed on
|
||||||
if hook_args is not None:
|
# to plugins and the like. For example, the JOIN handler will return
|
||||||
self.callHooks(hook_args)
|
# something like: {'channel': '#whatever', 'users': ['UID1', 'UID2',
|
||||||
|
# 'UID3']}, etc.
|
||||||
|
if hook_args is not None:
|
||||||
|
self.callHooks(hook_args)
|
||||||
|
|
||||||
def callHooks(self, hook_args):
|
def callHooks(self, hook_args):
|
||||||
numeric, command, parsed_args = hook_args
|
numeric, command, parsed_args = hook_args
|
||||||
|
Loading…
Reference in New Issue
Block a user