add send_nick() - optionally await success
This commit is contained in:
parent
c06068bf2c
commit
6b2b3d71c8
1 changed files with 20 additions and 0 deletions
|
@ -295,6 +295,26 @@ class Server(IServer):
|
||||||
return False
|
return False
|
||||||
# /CAP-related
|
# /CAP-related
|
||||||
|
|
||||||
|
def send_nick(self, new_nick: str) -> Awaitable[bool]:
|
||||||
|
fut = self.send(build("NICK", [new_nick]))
|
||||||
|
async def _assure() -> bool:
|
||||||
|
await fut
|
||||||
|
line = await self.wait_for({
|
||||||
|
Response("NICK", [Folded(new_nick)], source=SELF),
|
||||||
|
Responses([
|
||||||
|
ERR_BANNICKCHANGE,
|
||||||
|
ERR_NICKTOOFAST,
|
||||||
|
ERR_CANTCHANGENICK
|
||||||
|
], [ANY]),
|
||||||
|
Responses([
|
||||||
|
ERR_NICKNAMEINUSE,
|
||||||
|
ERR_ERRONEUSNICKNAME,
|
||||||
|
ERR_UNAVAILRESOURCE
|
||||||
|
], [ANY, Folded(new_nick)])
|
||||||
|
})
|
||||||
|
return line.command == "NICK"
|
||||||
|
return MaybeAwait(_assure)
|
||||||
|
|
||||||
def send_join(self,
|
def send_join(self,
|
||||||
name: str,
|
name: str,
|
||||||
key: Optional[str]=None
|
key: Optional[str]=None
|
||||||
|
|
Loading…
Add table
Reference in a new issue