From 4936b912732a6db9ec2ce761da986d2c71cf28ce Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 5 Nov 2018 15:15:08 +0000 Subject: Support JSON messages tags, as per IRCv'3 message-tags-0.3 #318 pull request --- src/utils/irc.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/utils/irc.py b/src/utils/irc.py index c22cfd25..f68af6ec 100644 --- a/src/utils/irc.py +++ b/src/utils/irc.py @@ -83,10 +83,16 @@ def parse_line(line: str) -> IRCLine: command = None if line[0] == "@": - tags_prefix, line = line[1:].split(" ", 1) - for tag in filter(None, tags_prefix.split(";")): - tag, _, value = tag.partition("=") - tags[tag] = value + if line[1] == "{": + tags = json.loads(line[2:]) + else: + tags_prefix, line = line[1:].split(" ", 1) + for tag in filter(None, tags_prefix.split(";")): + tag, sep, value = tag.partition("=") + if sep: + tags[tag] = value + else: + tags[tag] = None line, _, arbitrary_split = line.partition(" :") arbitrary = arbitrary_split or None -- cgit v1.3.1-10-gc9f91