Add new BatchType object, to match like how Capability and MessageTag do
This commit is contained in:
parent
8dbae6a5e9
commit
2470c1ec03
2 changed files with 9 additions and 1 deletions
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue