aboutsummaryrefslogtreecommitdiff
path: root/src/IRCServer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/IRCServer.py')
-rw-r--r--src/IRCServer.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/IRCServer.py b/src/IRCServer.py
index 3a4ff182..e6c08ee6 100644
--- a/src/IRCServer.py
+++ b/src/IRCServer.py
@@ -17,6 +17,7 @@ class Server(IRCObject.Object):
self.id = id
self.alias = alias
self.connection_params = connection_params
+ self.connected = False
self.name = None # type: typing.Optional[str]
self.version = None # type: typing.Optional[str]
@@ -30,7 +31,7 @@ class Server(IRCObject.Object):
self._capabilities_waiting = set([]) # type: typing.Set[str]
self.agreed_capabilities = set([]) # type: typing.Set[str]
self.server_capabilities = {} # type: typing.Dict[str, str]
- self.batches = {} # type: typing.Dict[str, IRCLine.ParsedLine]
+ self.batches = {} # type: typing.Dict[str, utils.irc.IRCBatch]
self.cap_started = False
self.users = {} # type: typing.Dict[str, IRCUser.User]
@@ -239,9 +240,6 @@ class Server(IRCObject.Object):
if lines:
self.ping_sent = False
- now = datetime.datetime.utcnow()
- self.set_setting("last-read",
- utils.iso8601_format(now, milliseconds=True))
return lines
def send(self, line_parsed: IRCLine.ParsedLine):
@@ -250,6 +248,8 @@ class Server(IRCObject.Object):
self.events.on("preprocess.send").on(line_parsed.command
).call_unsafe(server=self, line=line_parsed)
+ self.events.on("preprocess.send").call_unsafe(server=self,
+ line=line_parsed)
line = line_parsed.format()
line_obj = IRCLine.SentLine(datetime.datetime.utcnow(), self.hostmask(),
@@ -285,9 +285,12 @@ class Server(IRCObject.Object):
def send_authenticate(self, text: str) -> IRCLine.SentLine:
return self.send(utils.irc.protocol.authenticate(text))
def has_capability(self, capability: utils.irc.Capability) -> bool:
- return bool(capability.available(self.agreed_capabilities))
+ return bool(self.available_capability(capability))
def has_capability_str(self, capability: str) -> bool:
return capability in self.agreed_capabilities
+ def available_capability(self, capability: utils.irc.Capability
+ ) -> typing.Optional[str]:
+ return capability.available(self.agreed_capabilities)
def waiting_for_capabilities(self) -> bool:
return bool(len(self._capabilities_waiting))
@@ -360,15 +363,3 @@ class Server(IRCObject.Object):
def send_whox(self, mask: str, filter: str, fields: str, label: str=None
) -> IRCLine.SentLine:
return self.send(utils.irc.protocol.whox(mask, filter, fields, label))
-
- 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) -> IRCLine.SentLine:
- self.send(utils.irc.protocol.batch_start(batch.id, batch.type,
- batch.tags))
-
- for line in batch.lines:
- self.send(line)
-
- return self.send(utils.irc.protocol.batch_end(batch.id))