diff options
author | mathieui <mathieui@mathieui.net> | 2013-03-31 16:33:10 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-03-31 16:33:10 +0200 |
commit | e8fae6f24cf783de7f17f85084d53a55d14e9f89 (patch) | |
tree | d199fc687516f3d0f13b9588376c4cfc60a0fe88 /src/common.py | |
parent | f58cd588c293f504b0c8858b207d30fa4c89b5b1 (diff) | |
download | poezio-e8fae6f24cf783de7f17f85084d53a55d14e9f89.tar.gz poezio-e8fae6f24cf783de7f17f85084d53a55d14e9f89.tar.bz2 poezio-e8fae6f24cf783de7f17f85084d53a55d14e9f89.tar.xz poezio-e8fae6f24cf783de7f17f85084d53a55d14e9f89.zip |
Fix #2275, ref #2229
- Refactor the message handlers to be more readable
- Add a group_corrections tab-specific option (#2229)
- Fix issues with /correct in private tabs and conversation tabs
Diffstat (limited to 'src/common.py')
-rw-r--r-- | src/common.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common.py b/src/common.py index 16fcfba5..987c93a9 100644 --- a/src/common.py +++ b/src/common.py @@ -196,6 +196,31 @@ def datetime_tuple(timestamp): ret -= dst return ret +def find_delayed_tag(message): + """ + Check if a message is delayed or not. + + :param sleekxmpp.Message message: The message to check. + :return: A tuple containing (True, the datetime) or (False, None) + :rtype: :py:class:`tuple` + """ + + delay_tag = message.find('{urn:xmpp:delay}delay') + if delay_tag is not None: + delayed = True + date = datetime_tuple(delay_tag.attrib['stamp']) + else: + # We support the OLD and deprecated XEP: http://xmpp.org/extensions/xep-0091.html + # But it sucks, please, Jabber servers, don't do this :( + delay_tag = message.find('{jabber:x:delay}x') + if delay_tag is not None: + delayed = True + date = common.datetime_tuple(delay_tag.attrib['stamp']) + else: + delayed = False + date = None + return (delayed, date) + def shell_split(st): """ Split a string correctly according to the quotes |