mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
core: Use IRCv3.2 extension server-time to fill IrcMsg.time, if available.
This commit is contained in:
parent
11c10bb3f1
commit
b338a23708
@ -955,7 +955,7 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
||||
|
||||
REQUEST_CAPABILITIES = set(['account-notify', 'extended-join',
|
||||
'multi-prefix', 'metadata-notify', 'account-tag',
|
||||
'userhost-in-names', 'invite-notify'])
|
||||
'userhost-in-names', 'invite-notify', 'server-time'])
|
||||
|
||||
def _queueConnectMessages(self):
|
||||
if self.zombie:
|
||||
|
@ -38,6 +38,7 @@ object (which, as you'll read later, is quite...full-featured :))
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
import functools
|
||||
|
||||
from . import conf, ircutils, utils
|
||||
@ -148,6 +149,12 @@ class IrcMsg(object):
|
||||
else:
|
||||
self.args = s.split()
|
||||
self.command = self.args.pop(0)
|
||||
if 'time' in self.server_tags:
|
||||
s = self.server_tags['time']
|
||||
date = datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S.%fZ')
|
||||
print(repr(date))
|
||||
self.time = date.timestamp()
|
||||
else:
|
||||
self.time = time.time()
|
||||
except (IndexError, ValueError):
|
||||
raise MalformedIrcMsg(repr(originalString))
|
||||
|
@ -153,6 +153,10 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
after = time.time()
|
||||
self.assertTrue(before <= msg.time <= after)
|
||||
|
||||
msg = ircmsgs.IrcMsg('@time=2011-10-19T16:40:51.620Z '
|
||||
':Angel!angel@example.org PRIVMSG Wiz :Hello')
|
||||
self.assertEqual(msg.time, 1319035251.62)
|
||||
|
||||
class FunctionsTestCase(SupyTestCase):
|
||||
def testIsAction(self):
|
||||
L = [':jemfinch!~jfincher@ts26-2.homenet.ohio-state.edu PRIVMSG'
|
||||
|
Loading…
Reference in New Issue
Block a user