mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-27 04:34:18 +01:00
Add labels to outgoing messages when labeled-response is supported.
This is going to be useful for implementing echo-message; and to plugins targetting only networks with labeled-response support.
This commit is contained in:
parent
bb063b8064
commit
572c609181
@ -1040,6 +1040,13 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
||||
self.outstandingPing = True
|
||||
self.queueMsg(ircmsgs.ping(now))
|
||||
if msg:
|
||||
if not world.testing and 'label' not in msg.server_tags \
|
||||
and 'labeled-response' in self.state.capabilities_ack:
|
||||
# Not adding labels while testing, because it would break
|
||||
# all plugin tests using IrcMsg equality (unless they
|
||||
# explicitly add the label, but it becomes a burden).
|
||||
msg.server_tags['label'] = ircutils.makeLabel()
|
||||
msg._len = msg._str = None
|
||||
for callback in reversed(self.callbacks):
|
||||
self._setMsgChannel(msg)
|
||||
msg = callback.outFilter(self, msg)
|
||||
@ -1247,7 +1254,7 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
||||
'multi-prefix', 'metadata-notify', 'account-tag',
|
||||
'userhost-in-names', 'invite-notify', 'server-time',
|
||||
'chghost', 'batch', 'away-notify', 'message-tags',
|
||||
'msgid', 'setname'])
|
||||
'msgid', 'setname', 'labeled-response'])
|
||||
|
||||
def _queueConnectMessages(self):
|
||||
if self.zombie:
|
||||
|
@ -41,6 +41,7 @@ from __future__ import print_function
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
import base64
|
||||
import random
|
||||
import string
|
||||
@ -960,6 +961,17 @@ def parseStsPolicy(logger, policy, parseDuration):
|
||||
return parsed_policy
|
||||
|
||||
|
||||
def makeLabel():
|
||||
"""Returns a unique label for outgoing message tags.
|
||||
|
||||
Unicity is not guaranteed across restarts.
|
||||
Returns should be handled as opaque strings, using only equality.
|
||||
|
||||
This is used for <https://ircv3.net/specs/extensions/labeled-response>
|
||||
"""
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
numerics = {
|
||||
# <= 2.10
|
||||
# Reply
|
||||
|
Loading…
Reference in New Issue
Block a user