DrBotIRC: clean up event handlers a bit
this brings them more in line with the code in irclib, which will be nice since i'm using that code as basis f or additions in a later commit
This commit is contained in:
parent
891b2bcab8
commit
53a3c40102
24
DrBotIRC.py
24
DrBotIRC.py
|
@ -288,9 +288,12 @@ class DrBotIRC(irclib.IRC):
|
||||||
self.try_alias(connection, event)
|
self.try_alias(connection, event)
|
||||||
|
|
||||||
h = self.handlers
|
h = self.handlers
|
||||||
for handler in h.get("all_events", []) + h.get(event.eventtype(), []):
|
th = sorted(h.get('all_events', []) + h.get(event.eventtype(), []))
|
||||||
|
for handler in th:
|
||||||
try:
|
try:
|
||||||
if handler[1](connection, event) == "NO MORE":
|
prio, method = handler
|
||||||
|
ret = method(connection, event)
|
||||||
|
if ret == 'NO MORE':
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("exception floated up to DrBotIrc!")
|
log.error("exception floated up to DrBotIrc!")
|
||||||
|
@ -330,13 +333,20 @@ class DrBotIRC(irclib.IRC):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
h = self.handlers
|
|
||||||
replies = []
|
replies = []
|
||||||
|
|
||||||
for handler in h.get("all_events", []) + h.get(event.eventtype(), []):
|
h = self.handlers
|
||||||
ret = handler[1](connection, event)
|
th = sorted(h.get('all_events', []) + h.get(event.eventtype(), []))
|
||||||
if ret:
|
for handler in th:
|
||||||
replies.append(ret)
|
try:
|
||||||
|
prio, method = handler
|
||||||
|
ret = method(connection, event)
|
||||||
|
if ret:
|
||||||
|
replies.append(ret)
|
||||||
|
except Exception as e:
|
||||||
|
log.error("exception floated up to DrBotIrc!")
|
||||||
|
log.exception(e)
|
||||||
|
|
||||||
if len(replies):
|
if len(replies):
|
||||||
event.arguments()[0] = '\n'.join(replies)
|
event.arguments()[0] = '\n'.join(replies)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue