Only request a CAP once. closes #66
This commit is contained in:
parent
d9321b87ec
commit
16b9361371
2 changed files with 14 additions and 4 deletions
|
@ -85,15 +85,15 @@ def cap(events, event):
|
|||
if subcommand == "ACK" or subcommand == "NAK":
|
||||
ack = subcommand == "ACK"
|
||||
for capability in capabilities:
|
||||
cap_obj = event["server"].capability_queue[capability]
|
||||
del event["server"].capability_queue[capability]
|
||||
cap_obj = event["server"].capabilities_requested[capability]
|
||||
del event["server"].capabilities_requested[capability]
|
||||
if ack:
|
||||
cap_obj.ack()
|
||||
else:
|
||||
cap_obj.nak()
|
||||
|
||||
if (event["server"].cap_started and
|
||||
not event["server"].capability_queue and
|
||||
not event["server"].capabilities_requested and
|
||||
not event["server"].waiting_for_capabilities()):
|
||||
event["server"].cap_started = False
|
||||
event["server"].send_capability_end()
|
||||
|
|
|
@ -28,6 +28,9 @@ class Server(IRCObject.Object):
|
|||
|
||||
self.capability_queue = {
|
||||
} # type: typing.Dict[str, utils.irc.Capability]
|
||||
self.capabilities_requested = {
|
||||
} # type: typing.Dict[str, utils.irc.Capability]
|
||||
|
||||
self._capabilities_waiting = set([]) # type: typing.Set[str]
|
||||
self.agreed_capabilities = set([]) # type: typing.Set[str]
|
||||
self.server_capabilities = {} # type: typing.Dict[str, str]
|
||||
|
@ -283,11 +286,18 @@ class Server(IRCObject.Object):
|
|||
def send_capibility_ls(self) -> IRCLine.SentLine:
|
||||
return self.send(utils.irc.protocol.capability_ls())
|
||||
def send_capability_queue(self):
|
||||
capability_queue = [cap for cap in self.capability_queue.keys()]
|
||||
capability_queue = list(self.capability_queue.keys())
|
||||
|
||||
for i in range(0, len(capability_queue), 10):
|
||||
capability_batch = capability_queue[i:i+10]
|
||||
|
||||
for cap_name in capability_batch:
|
||||
cap = self.capability_queue[cap_name]
|
||||
del self.capability_queue[cap_name]
|
||||
self.capabilities_requested[cap_name] = cap
|
||||
|
||||
self.send_capability_request(" ".join(capability_batch))
|
||||
|
||||
def send_capability_request(self, capability: str) -> IRCLine.SentLine:
|
||||
return self.send(utils.irc.protocol.capability_request(capability))
|
||||
def send_capability_end(self) -> IRCLine.SentLine:
|
||||
|
|
Loading…
Reference in a new issue