diff options
| author | 2019-06-04 17:53:40 +0100 | |
|---|---|---|
| committer | 2019-06-04 17:54:19 +0100 | |
| commit | 2d46fe0cbf9a383038b8715b27cfa587e5a50ecf (patch) | |
| tree | 64a34a0b8aaf1471a7b4b21420ae4a9760c727f1 /src/utils | |
| parent | Add new BatchType object, to match like how Capability and MessageTag do (diff) | |
| signature | ||
labels: Use BatchType to match, pass `lines` not `line`, batch ID isn't a label,
fire event on label response
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/irc/__init__.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py index 12abc144..c9b50c6c 100644 --- a/src/utils/irc/__init__.py +++ b/src/utils/irc/__init__.py @@ -275,11 +275,16 @@ class Capability(object): self._caps = set([name, draft_name]) self._on_ack_callbacks = [ ] # type: typing.List[typing.Callable[[], None]] + def available(self, capabilities: typing.Iterable[str] ) -> typing.Optional[str]: match = list(set(capabilities)&self._caps) return match[0] if match else None + def match(self, capability: str) -> typing.Optional[str]: + cap = list(set([capability])&self._caps) + return cap[0] if cap else None + def copy(self): return Capability(*self._caps) @@ -297,8 +302,8 @@ class MessageTag(object): def get_value(self, tags: typing.Dict[str, str]) -> typing.Optional[str]: key = list(set(tags.keys())&self._names) return tags[key[0]] if key else None - def match(self, s: str) -> typing.Optional[str]: - key = list(set([s])&self._names) + def match(self, tag: str) -> typing.Optional[str]: + key = list(set([tag])&self._names) return key[0] if key else None class BatchType(object): |
