From 8f552a7d6f3b52350bc9dc187d0fd20fe75da63a Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 7 Jun 2020 20:46:05 +0100 Subject: [PATCH] update ircstates to v0.9.18, catch ERR_NOSUCHSERVER (remote whois) --- ircrobots/server.py | 16 +++++++++++----- requirements.txt | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ircrobots/server.py b/ircrobots/server.py index 482361a..b57a2c6 100644 --- a/ircrobots/server.py +++ b/ircrobots/server.py @@ -439,17 +439,23 @@ class Server(IServer): return None return MaybeAwait(_assure) - def send_whois(self, target: str) -> Awaitable[Optional[Whois]]: - folded = self.casefold(target) - fut = self.send(build("WHOIS", [target, target])) + def send_whois(self, + target: str, + remote: bool=False + ) -> Awaitable[Optional[Whois]]: + args = [target] + if remote: + args.append(target) + fut = self.send(build("WHOIS", args)) async def _assure(): await fut - params = [ANY, Folded(folded)] + params = [ANY, Folded(self.casefold(target))] obj = Whois() while True: line = await self.wait_for(Responses([ ERR_NOSUCHNICK, + ERR_NOSUCHSERVER, RPL_WHOISUSER, RPL_WHOISSERVER, RPL_WHOISOPERATOR, @@ -460,7 +466,7 @@ class Server(IServer): RPL_WHOISSECURE, RPL_ENDOFWHOIS ], params)) - if line.command == ERR_NOSUCHNICK: + if line.command in [ERR_NOSUCHNICK, ERR_NOSUCHSERVER]: return None elif line.command == RPL_WHOISUSER: nick, user, host, _, real = line.params[1:] diff --git a/requirements.txt b/requirements.txt index 0879136..0c29d31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ anyio ==1.3.0 asyncio-throttle ==1.0.1 dataclasses ==0.6 -ircstates ==0.9.17 +ircstates ==0.9.18 async_stagger ==0.3.0 async_timeout ==3.0.1