Don't pass None
around as tag default, fix some missing return type args
This commit is contained in:
parent
3f8ac871ed
commit
577fae7cea
3 changed files with 15 additions and 11 deletions
|
@ -352,9 +352,10 @@ class Server(IRCObject.Object):
|
||||||
) -> IRCLine.Line:
|
) -> IRCLine.Line:
|
||||||
return self.send(utils.irc.protocol.whox(mask, filter, fields, label))
|
return self.send(utils.irc.protocol.whox(mask, filter, fields, label))
|
||||||
|
|
||||||
def make_batch(self, identifier: str, batch_type: str, tags: dict=None):
|
def make_batch(self, identifier: str, batch_type: str,
|
||||||
|
tags: typing.Dict[str, str]={}) -> utils.irc.IRCSendBatch:
|
||||||
return utils.irc.IRCSendBatch(identifier, batch_type, tags)
|
return utils.irc.IRCSendBatch(identifier, batch_type, tags)
|
||||||
def send_batch(self, batch: utils.irc.IRCSendBatch):
|
def send_batch(self, batch: utils.irc.IRCSendBatch) -> IRCLine.Line:
|
||||||
self.send(utils.irc.protocol.batch_start(batch.id, batch.type,
|
self.send(utils.irc.protocol.batch_start(batch.id, batch.type,
|
||||||
batch.tags))
|
batch.tags))
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class IRCArgs(object):
|
||||||
def __getitem__(self, index) -> str:
|
def __getitem__(self, index) -> str:
|
||||||
return self._args[index]
|
return self._args[index]
|
||||||
|
|
||||||
def _tag_str(tags: dict) -> str:
|
def _tag_str(tags: typing.Dict[str, str]) -> str:
|
||||||
tag_str = ""
|
tag_str = ""
|
||||||
for tag, value in tags.items():
|
for tag, value in tags.items():
|
||||||
if tag_str:
|
if tag_str:
|
||||||
|
@ -77,7 +77,8 @@ def _tag_str(tags: dict) -> str:
|
||||||
|
|
||||||
class IRCParsedLine(object):
|
class IRCParsedLine(object):
|
||||||
def __init__(self, command: str, args: typing.List[str],
|
def __init__(self, command: str, args: typing.List[str],
|
||||||
prefix: IRCHostmask = None, tags: dict = None):
|
prefix: IRCHostmask=None,
|
||||||
|
tags: typing.Dict[str, str]={}):
|
||||||
self.command = command
|
self.command = command
|
||||||
self._args = args
|
self._args = args
|
||||||
self.args = IRCArgs(args)
|
self.args = IRCArgs(args)
|
||||||
|
@ -318,7 +319,8 @@ def parse_ctcp(s: str) -> typing.Optional[CTCPMessage]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class IRCBatch(object):
|
class IRCBatch(object):
|
||||||
def __init__(self, identifier: str, batch_type: str, tags: dict=None):
|
def __init__(self, identifier: str, batch_type: str, tags:
|
||||||
|
typing.Dict[str, str]={}):
|
||||||
self.id = identifier
|
self.id = identifier
|
||||||
self.type = batch_type
|
self.type = batch_type
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
|
@ -329,9 +331,9 @@ class IRCSendBatch(IRCBatch):
|
||||||
def _add_line(self, line: IRCParsedLine):
|
def _add_line(self, line: IRCParsedLine):
|
||||||
line.tags["batch"] = self.id
|
line.tags["batch"] = self.id
|
||||||
self.lines.append(line)
|
self.lines.append(line)
|
||||||
def message(self, target: str, message: str, tags: dict=None):
|
def message(self, target: str, message: str, tags: dict={}):
|
||||||
self._add_line(utils.irc.protocol.message(target, message, tags))
|
self._add_line(utils.irc.protocol.message(target, message, tags))
|
||||||
def notice(self, target: str, message: str, tags: dict=None):
|
def notice(self, target: str, message: str, tags: dict={}):
|
||||||
self._add_line(utils.irc.protocol.notice(target, message, tags))
|
self._add_line(utils.irc.protocol.notice(target, message, tags))
|
||||||
|
|
||||||
def trailing(s: str) -> str:
|
def trailing(s: str) -> str:
|
||||||
|
|
|
@ -33,10 +33,10 @@ def part(channel_name: str, reason: str=None) -> 'utils.irc.IRCParsedLine':
|
||||||
def quit(reason: str=None) -> 'utils.irc.IRCParsedLine':
|
def quit(reason: str=None) -> 'utils.irc.IRCParsedLine':
|
||||||
return utils.irc.IRCParsedLine("QUIT", [reason] if reason else [])
|
return utils.irc.IRCParsedLine("QUIT", [reason] if reason else [])
|
||||||
|
|
||||||
def message(target: str, message: str, tags: dict=None
|
def message(target: str, message: str, tags: typing.Dict[str, str]={}
|
||||||
) -> 'utils.irc.IRCParsedLine':
|
) -> 'utils.irc.IRCParsedLine':
|
||||||
return utils.irc.IRCParsedLine("PRIVMSG", [target, message], tags=tags)
|
return utils.irc.IRCParsedLine("PRIVMSG", [target, message], tags=tags)
|
||||||
def notice(target: str, message: str, tags: dict=None
|
def notice(target: str, message: str, tags: typing.Dict[str, str]={}
|
||||||
) -> 'utils.irc.IRCParsedLine':
|
) -> 'utils.irc.IRCParsedLine':
|
||||||
return utils.irc.IRCParsedLine("NOTICE", [target, message], tags=tags)
|
return utils.irc.IRCParsedLine("NOTICE", [target, message], tags=tags)
|
||||||
def tagmsg(target, tags: dict) -> 'utils.irc.IRCParsedLine':
|
def tagmsg(target, tags: dict) -> 'utils.irc.IRCParsedLine':
|
||||||
|
@ -81,9 +81,10 @@ def whox(mask: str, filter: str, fields: str, label: str=None
|
||||||
flags = "%s%%%s%s" % (filter, fields, ","+label if label else "")
|
flags = "%s%%%s%s" % (filter, fields, ","+label if label else "")
|
||||||
return utils.irc.IRCParsedLine("WHO", [mask, flags])
|
return utils.irc.IRCParsedLine("WHO", [mask, flags])
|
||||||
|
|
||||||
def batch_start(identifier: str, batch_type: str, tags: dict=None):
|
def batch_start(identifier: str, batch_type: str, tags: typing.Dict[str, str]={}
|
||||||
|
) -> 'utils.irc.IRCParsedLine':
|
||||||
return utils.irc.IRCParsedLine("BATCH", ["+%s" % identifier, batch_type],
|
return utils.irc.IRCParsedLine("BATCH", ["+%s" % identifier, batch_type],
|
||||||
tags=tags)
|
tags=tags)
|
||||||
|
|
||||||
def batch_end(identifier: str, tags: dict=None):
|
def batch_end(identifier: str, tags: typing.Dict[str, str]={}):
|
||||||
return utils.irc.IRCParsedLine("BATCH", ["-%s" % identifier], tags=tags)
|
return utils.irc.IRCParsedLine("BATCH", ["-%s" % identifier], tags=tags)
|
||||||
|
|
Loading…
Reference in a new issue