mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-11-15 07:07:25 +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.outstandingPing = True
|
||||||
self.queueMsg(ircmsgs.ping(now))
|
self.queueMsg(ircmsgs.ping(now))
|
||||||
if msg:
|
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):
|
for callback in reversed(self.callbacks):
|
||||||
self._setMsgChannel(msg)
|
self._setMsgChannel(msg)
|
||||||
msg = callback.outFilter(self, msg)
|
msg = callback.outFilter(self, msg)
|
||||||
@ -1247,7 +1254,7 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
|||||||
'multi-prefix', 'metadata-notify', 'account-tag',
|
'multi-prefix', 'metadata-notify', 'account-tag',
|
||||||
'userhost-in-names', 'invite-notify', 'server-time',
|
'userhost-in-names', 'invite-notify', 'server-time',
|
||||||
'chghost', 'batch', 'away-notify', 'message-tags',
|
'chghost', 'batch', 'away-notify', 'message-tags',
|
||||||
'msgid', 'setname'])
|
'msgid', 'setname', 'labeled-response'])
|
||||||
|
|
||||||
def _queueConnectMessages(self):
|
def _queueConnectMessages(self):
|
||||||
if self.zombie:
|
if self.zombie:
|
||||||
|
|||||||
@ -41,6 +41,7 @@ from __future__ import print_function
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import uuid
|
||||||
import base64
|
import base64
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
@ -960,6 +961,17 @@ def parseStsPolicy(logger, policy, parseDuration):
|
|||||||
return parsed_policy
|
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 = {
|
numerics = {
|
||||||
# <= 2.10
|
# <= 2.10
|
||||||
# Reply
|
# Reply
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user