Request CAPs we support when we see them advertised with CAP NEW

(line_handler.py)
This commit is contained in:
jesopo 2019-02-08 17:30:07 +00:00
parent d3f23eafb8
commit 15ab772442

View file

@ -279,6 +279,9 @@ class Module(ModuleManager.BaseModule):
else: else:
event["server"].disconnect() event["server"].disconnect()
def _match_caps(self, cabilities):
return set(capabilities) & CAPABILITIES
# the server is telling us about its capabilities! # the server is telling us about its capabilities!
@utils.hook("raw.received.cap") @utils.hook("raw.received.cap")
def cap(self, event): def cap(self, event):
@ -290,10 +293,11 @@ class Module(ModuleManager.BaseModule):
event["server"].cap_started = True event["server"].cap_started = True
event["server"].server_capabilities.update(capabilities) event["server"].server_capabilities.update(capabilities)
if not is_multiline: if not is_multiline:
matched_capabilities = set(event["server" matched_caps = self._match_caps(
].server_capabilities.keys()) & CAPABILITIES list(event["server"].server_capbilities.keys()))
if matched_capabilities: if matched_capabilities:
event["server"].queue_capabilities(matched_capabilities) event["server"].queue_capabilities(matched_caps)
self._event(event, "cap.ls", self._event(event, "cap.ls",
capabilities=event["server"].server_capabilities, capabilities=event["server"].server_capabilities,
@ -305,8 +309,15 @@ class Module(ModuleManager.BaseModule):
event["server"].send_capability_end() event["server"].send_capability_end()
elif subcommand == "new": elif subcommand == "new":
event["server"].capabilities.update(set(capabilities.keys())) event["server"].capabilities.update(set(capabilities.keys()))
matched_caps = self._match_caps(list(capabilities.keys()))
event["server"].queue_capabilities(matched_caps)
self._event(event, "cap.new", server=event["server"], self._event(event, "cap.new", server=event["server"],
capabilities=capabilities) capabilities=capabilities)
if event["server"].has_capability_queue():
event["server"].send_capability_queue()
elif subcommand == "del": elif subcommand == "del":
event["server"].capabilities.difference_update(set( event["server"].capabilities.difference_update(set(
capabilities.keys())) capabilities.keys()))