From 2470c1ec03cad2f7eeb2575dd1c5d3052c948c5e Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 4 Jun 2019 17:51:55 +0100 Subject: Add new BatchType object, to match like how Capability and MessageTag do --- src/utils/irc/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/utils/irc/__init__.py') 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) -- cgit v1.3.1-10-gc9f91