Add IRCServer.has_capability and use it throughout line_handler
This commit is contained in:
parent
7c654b4475
commit
7a3db82300
4 changed files with 6 additions and 4 deletions
|
@ -38,7 +38,7 @@ def handle_353(event):
|
|||
modes.add(event["server"].prefix_symbols[nickname[0]])
|
||||
nickname = nickname[1:]
|
||||
|
||||
if "userhost-in-names" in event["server"].agreed_capabilities:
|
||||
if event["server"].has_capability("userhost-in-names"):
|
||||
hostmask = utils.irc.seperate_hostmask(nickname)
|
||||
nickname = hostmask.nickname
|
||||
user = event["server"].get_user(hostmask.nickname)
|
||||
|
|
|
@ -29,8 +29,8 @@ def handle_005(events, event):
|
|||
isupport[key] = None
|
||||
event["server"].isupport.update(isupport)
|
||||
|
||||
if "NAMESX" in isupport and not "multi-prefix" in event[
|
||||
"server"].agreed_capabilities:
|
||||
if "NAMESX" in isupport and not event["server"].has_capability(
|
||||
"multi-prefix"):
|
||||
event["server"].send("PROTOCTL NAMESX")
|
||||
|
||||
if "PREFIX" in isupport:
|
||||
|
|
|
@ -2,7 +2,7 @@ from src import utils
|
|||
|
||||
def _from_self(server, direction, prefix):
|
||||
if direction == utils.Direction.SEND:
|
||||
if "echo-message" in server.agreed_capabilities:
|
||||
if server.has_capability("echo-message"):
|
||||
return None
|
||||
else:
|
||||
return True
|
||||
|
|
|
@ -282,6 +282,8 @@ class Server(IRCObject.Object):
|
|||
return self.send(utils.irc.protocol.capability_end())
|
||||
def send_authenticate(self, text: str) -> IRCLine.SentLine:
|
||||
return self.send(utils.irc.protocol.authenticate(text))
|
||||
def has_capability(self, capability: str) -> bool:
|
||||
return capability in self.agreed_capabilities
|
||||
|
||||
def waiting_for_capabilities(self) -> bool:
|
||||
return bool(len(self._capabilities_waiting))
|
||||
|
|
Loading…
Reference in a new issue