Skip to content

Commit d36b45a

Browse files
committed
Add hook for deciding whether to tag a message.
It is useful for Context subclasses to be able to decide whether to tag a message based on its content. For example, do not tag CTCP messages in IRC.
1 parent 8ba4981 commit d36b45a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/potr/context.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def processOutgoingMessage(self, msg, flags, tlvs=[]):
282282
# TODO notify
283283
msg = self.user.getDefaultQueryMessage(self.getPolicy)
284284
return msg
285-
if self.getPolicy('SEND_TAG') and self.tagOffer != OFFER_REJECTED:
285+
if self.getPolicy('SEND_TAG') and \
286+
self.tagOffer != OFFER_REJECTED and \
287+
self.shouldTagMessage(msg):
286288
self.tagOffer = OFFER_SENT
287289
versions = set()
288290
if self.getPolicy('ALLOW_V1'):
@@ -492,6 +494,10 @@ def getExtraKey(self, extraKeyAppId=None, extraKeyAppData=None, appdata=None):
492494
self.sendInternal(b'', tlvs=tlvs, appdata=appdata)
493495
return self.crypto.extraKey
494496

497+
def shouldTagMessage(self, msg):
498+
"""Hook to decide whether to tag a message based on its contents."""
499+
return True
500+
495501
class Account(object):
496502
contextclass = Context
497503
def __init__(self, name, protocol, maxMessageSize, privkey=None):

0 commit comments

Comments
 (0)