Try to restaure frm_owner flag

This commit is contained in:
nemunaire 2016-11-10 18:36:10 +01:00 committed by nemunaire
parent 838b76081d
commit 1f5cfb2ead
3 changed files with 9 additions and 4 deletions

View File

@ -21,7 +21,7 @@ class Abstract:
"""This class represents an abstract message""" """This class represents an abstract message"""
def __init__(self, server=None, date=None, to=None, to_response=None, frm=None): def __init__(self, server=None, date=None, to=None, to_response=None, frm=None, frm_owner=False):
"""Initialize an abstract message """Initialize an abstract message
Arguments: Arguments:
@ -40,7 +40,7 @@ class Abstract:
else [ to_response ]) else [ to_response ])
self.frm = frm # None allowed when it designate this bot self.frm = frm # None allowed when it designate this bot
self.frm_owner = False # Filled later, in consumer self.frm_owner = frm_owner
@property @property
@ -78,7 +78,8 @@ class Abstract:
"date": self.date, "date": self.date,
"to": self.to, "to": self.to,
"to_response": self._to_response, "to_response": self._to_response,
"frm": self.frm "frm": self.frm,
"frm_owner": self.frm_owner,
} }
for w in without: for w in without:

View File

@ -150,7 +150,8 @@ class IRC(Abstract):
"date": self.tags["time"], "date": self.tags["time"],
"to": receivers, "to": receivers,
"to_response": [r if r != srv.nick else self.nick for r in receivers], "to_response": [r if r != srv.nick else self.nick for r in receivers],
"frm": self.nick "frm": self.nick,
"frm_owner": self.nick == srv.owner
} }
# If CTCP, remove 0x01 # If CTCP, remove 0x01

View File

@ -109,6 +109,9 @@ class MessageTreater:
msg -- message to treat msg -- message to treat
""" """
if hasattr(msg, "frm_owner"):
msg.frm_owner = (not hasattr(msg.server, "owner") or msg.server.owner == msg.frm)
while hook is not None: while hook is not None:
res = hook.run(msg) res = hook.run(msg)