diff options
| author | 2019-06-04 17:51:55 +0100 | |
|---|---|---|
| committer | 2019-06-04 17:51:55 +0100 | |
| commit | 2470c1ec03cad2f7eeb2575dd1c5d3052c948c5e (patch) | |
| tree | f9a0c11676513460d28c9a3ce420de4790cf798b | |
| parent | Give SentLine (and preproc.send events) a new event object, to track events (diff) | |
| signature | ||
Add new BatchType object, to match like how Capability and MessageTag do
| -rw-r--r-- | modules/ircv3_labeled_responses.py | 1 | ||||
| -rw-r--r-- | src/utils/irc/__init__.py | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/modules/ircv3_labeled_responses.py b/modules/ircv3_labeled_responses.py index eee53c58..59bab81a 100644 --- a/modules/ircv3_labeled_responses.py +++ b/modules/ircv3_labeled_responses.py @@ -3,6 +3,7 @@ from src import ModuleManager, utils CAP = utils.irc.Capability(None, "draft/labeled-response-0.2") TAG = utils.irc.MessageTag(None, "draft/label") +BATCH = utils.irc.BatchType(None, "draft/labeled-response") CAP_TO_TAG = { "draft/labeled-response-0.2": "draft/label" diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py index 9577bcc1..12abc144 100644 --- a/src/utils/irc/__init__.py +++ b/src/utils/irc/__init__.py @@ -260,7 +260,7 @@ def parse_ctcp(s: str) -> typing.Optional[CTCPMessage]: class IRCBatch(object): def __init__(self, identifier: str, batch_type: str, args: typing.List[str], tags: typing.Dict[str, str]={}): - self.id = identifier + self.identifier = identifier self.type = batch_type self.args = args self.tags = tags @@ -301,5 +301,12 @@ class MessageTag(object): key = list(set([s])&self._names) return key[0] if key else None +class BatchType(object): + def __init__(self, name: typing.Optional[str], draft_name: str=None): + self._names = set([name, draft_name]) + def match(self, type: str) -> typing.Optional[str]: + t = list(set([type])&self._names) + return t[0] if t else None + def hostmask_match(hostmask: str, pattern: str) -> bool: return fnmatch.fnmatchcase(hostmask, pattern) |
