Skip to content

Commit 75c7541

Browse files
committed
Add parsing logic to IrcOutevent
1 parent 39e7cf2 commit 75c7541

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

cloudbot/event.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import enum
44
import logging
55

6+
from cloudbot.util.parsers.irc import Message
7+
68
logger = logging.getLogger("cloudbot")
79

810

@@ -393,6 +395,31 @@ def __init__(self, *args, cap, cap_param=None, **kwargs):
393395

394396

395397
class IrcOutEvent(Event):
398+
def __init__(self, *args, **kwargs):
399+
super().__init__(*args, **kwargs)
400+
self.parsed_line = None
401+
402+
@asyncio.coroutine
403+
def prepare(self):
404+
yield from super().prepare()
405+
406+
if "parsed_line" in self.hook.required_args:
407+
try:
408+
self.parsed_line = Message.parse(self.line)
409+
except Exception:
410+
logger.exception("Unable to parse line requested by hook %s", self.hook)
411+
self.parsed_line = None
412+
413+
def prepare_threaded(self):
414+
super().prepare_threaded()
415+
416+
if "parsed_line" in self.hook.required_args:
417+
try:
418+
self.parsed_line = Message.parse(self.line)
419+
except Exception:
420+
logger.exception("Unable to parse line requested by hook %s", self.hook)
421+
self.parsed_line = None
422+
396423
@property
397424
def line(self):
398-
return self.irc_raw
425+
return str(self.irc_raw)

0 commit comments

Comments
 (0)