Support JSON messages tags, as per IRCv'3 message-tags-0.3 #318 pull request

This commit is contained in:
jesopo 2018-11-05 15:15:08 +00:00
parent 90a72eb24d
commit 4936b91273
2 changed files with 12 additions and 6 deletions

View file

@ -10,8 +10,8 @@ RE_MODES = re.compile(r"[-+]\w+")
CAPABILITIES = {"multi-prefix", "chghost", "invite-notify", "account-tag",
"account-notify", "extended-join", "away-notify", "userhost-in-names",
"draft/message-tags-0.2", "server-time", "cap-notify",
"batch", "draft/labeled-response", "draft/rename"}
"draft/message-tags-0.2", "draft/message-tags-0.3", "server-time",
"cap-notify", "batch", "draft/labeled-response", "draft/rename"}
class Module(ModuleManager.BaseModule):
def _handle(self, server, line):

View file

@ -83,10 +83,16 @@ def parse_line(line: str) -> IRCLine:
command = None
if line[0] == "@":
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, _, value = tag.partition("=")
tag, sep, value = tag.partition("=")
if sep:
tags[tag] = value
else:
tags[tag] = None
line, _, arbitrary_split = line.partition(" :")
arbitrary = arbitrary_split or None