aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/IRCServer.py5
-rw-r--r--src/utils/irc/__init__.py12
-rw-r--r--src/utils/irc/protocol.py9
3 files changed, 15 insertions, 11 deletions
diff --git a/src/IRCServer.py b/src/IRCServer.py
index c3a3e5ca..3f545c58 100644
--- a/src/IRCServer.py
+++ b/src/IRCServer.py
@@ -352,9 +352,10 @@ class Server(IRCObject.Object):
) -> IRCLine.Line:
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)
- 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,
batch.tags))
diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py
index 2da9db08..9c19f911 100644
--- a/src/utils/irc/__init__.py
+++ b/src/utils/irc/__init__.py
@@ -63,7 +63,7 @@ class IRCArgs(object):
def __getitem__(self, index) -> str:
return self._args[index]
-def _tag_str(tags: dict) -> str:
+def _tag_str(tags: typing.Dict[str, str]) -> str:
tag_str = ""
for tag, value in tags.items():
if tag_str:
@@ -77,7 +77,8 @@ def _tag_str(tags: dict) -> str:
class IRCParsedLine(object):
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._args = args
self.args = IRCArgs(args)
@@ -318,7 +319,8 @@ def parse_ctcp(s: str) -> typing.Optional[CTCPMessage]:
return None
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.type = batch_type
self.tags = tags
@@ -329,9 +331,9 @@ class IRCSendBatch(IRCBatch):
def _add_line(self, line: IRCParsedLine):
line.tags["batch"] = self.id
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))
- 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))
def trailing(s: str) -> str:
diff --git a/src/utils/irc/protocol.py b/src/utils/irc/protocol.py
index 96ea7247..2c57ad25 100644
--- a/src/utils/irc/protocol.py
+++ b/src/utils/irc/protocol.py
@@ -33,10 +33,10 @@ def part(channel_name: str, reason: str=None) -> 'utils.irc.IRCParsedLine':
def quit(reason: str=None) -> 'utils.irc.IRCParsedLine':
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':
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':
return utils.irc.IRCParsedLine("NOTICE", [target, message], tags=tags)
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 "")
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],
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)