Adda system of aliases for CAPs, mostly for changeable draft specs and creating

dependence between moving specs
This commit is contained in:
jesopo 2019-06-21 17:15:46 +01:00
parent eef14abae3
commit 8a0d99f969
7 changed files with 14 additions and 9 deletions

View file

@ -5,7 +5,8 @@ from src import ModuleManager, utils
TAG = utils.irc.MessageTag("msgid", "draft/msgid") TAG = utils.irc.MessageTag("msgid", "draft/msgid")
CHATHISTORY_BATCH = utils.irc.BatchType("chathistory") CHATHISTORY_BATCH = utils.irc.BatchType("chathistory")
EVENTPLAYBACK_CAP = utils.irc.Capability(None, "draft/event-playback") EVENTPLAYBACK_CAP = utils.irc.Capability(None, "draft/event-playback",
alias="event-playback")
HISTORY_BATCH = utils.irc.BatchType("history") HISTORY_BATCH = utils.irc.BatchType("history")
@utils.export("cap", EVENTPLAYBACK_CAP) @utils.export("cap", EVENTPLAYBACK_CAP)

View file

@ -1,7 +1,8 @@
import uuid import uuid
from src import ModuleManager, utils from src import ModuleManager, utils
CAP = utils.irc.Capability(None, "draft/labeled-response-0.2") CAP = utils.irc.Capability(None, "draft/labeled-response-0.2",
alias="labeled-response")
TAG = utils.irc.MessageTag(None, "draft/label") TAG = utils.irc.MessageTag(None, "draft/label")
BATCH = utils.irc.BatchType(None, "draft/labeled-response") BATCH = utils.irc.BatchType(None, "draft/labeled-response")

View file

@ -1,6 +1,6 @@
from src import IRCBot, ModuleManager, utils from src import IRCBot, ModuleManager, utils
CAP = utils.irc.Capability(None, "draft/metadata") CAP = utils.irc.Capability(None, "draft/metadata", alias="metadata")
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
@utils.hook("received.cap.new") @utils.hook("received.cap.new")

View file

@ -1,6 +1,6 @@
from src import ModuleManager, utils from src import ModuleManager, utils
CAP = utils.irc.Capability(None, "bitbot.dev/multiline") CAP = utils.irc.Capability(None, "bitbot.dev/multiline", alias="multiline")
BATCH = utils.irc.BatchType(None, "bitbot.dev/multiline") BATCH = utils.irc.BatchType(None, "bitbot.dev/multiline")
TAG = utils.irc.MessageTag(None, "+bitbot.dev/multiline-concat") TAG = utils.irc.MessageTag(None, "+bitbot.dev/multiline-concat")

View file

@ -2,7 +2,7 @@
from src import ModuleManager, utils from src import ModuleManager, utils
CAP = utils.irc.Capability(None, "draft/resume-0.5") CAP = utils.irc.Capability(None, "draft/resume-0.5", alias="resume")
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
def _setting(self, new): def _setting(self, new):

View file

@ -12,8 +12,8 @@ CAPABILITIES = [
utils.irc.Capability("message-tags", "draft/message-tags-0.2"), utils.irc.Capability("message-tags", "draft/message-tags-0.2"),
utils.irc.Capability("cap-notify"), utils.irc.Capability("cap-notify"),
utils.irc.Capability("batch"), utils.irc.Capability("batch"),
utils.irc.Capability(None, "draft/rename"), utils.irc.Capability(None, "draft/rename", alias="rename"),
utils.irc.Capability(None, "draft/setname") utils.irc.Capability(None, "draft/setname", alias="setname")
] ]
def _cap_match(server, caps): def _cap_match(server, caps):

View file

@ -286,8 +286,11 @@ class IRCSendBatch(IRCBatch):
return lines return lines
class Capability(object): class Capability(object):
def __init__(self, name: typing.Optional[str], draft_name: str=None): def __init__(self, ratified_name: typing.Optional[str],
self._caps = set([name, draft_name]) draft_name: str=None, alias: str=None,
depends_on: typing.List[str]=None):
self.alias = alias or ratified_name
self._caps = set([ratified_name, draft_name])
self._on_ack_callbacks = [ self._on_ack_callbacks = [
] # type: typing.List[typing.Callable[[], None]] ] # type: typing.List[typing.Callable[[], None]]