WHOIS should have nick, user/host/real are required, handle NOSUCHUSER
This commit is contained in:
parent
aea7cf792a
commit
06afec2738
2 changed files with 17 additions and 9 deletions
|
@ -439,7 +439,7 @@ class Server(IServer):
|
||||||
return None
|
return None
|
||||||
return MaybeAwait(_assure)
|
return MaybeAwait(_assure)
|
||||||
|
|
||||||
def send_whois(self, target: str) -> Awaitable[Whois]:
|
def send_whois(self, target: str) -> Awaitable[Optional[Whois]]:
|
||||||
folded = self.casefold(target)
|
folded = self.casefold(target)
|
||||||
fut = self.send(build("WHOIS", [target, target]))
|
fut = self.send(build("WHOIS", [target, target]))
|
||||||
|
|
||||||
|
@ -449,6 +449,7 @@ class Server(IServer):
|
||||||
obj = Whois()
|
obj = Whois()
|
||||||
while True:
|
while True:
|
||||||
line = await self.wait_for(Responses([
|
line = await self.wait_for(Responses([
|
||||||
|
ERR_NOSUCHUSER,
|
||||||
RPL_WHOISUSER,
|
RPL_WHOISUSER,
|
||||||
RPL_WHOISSERVER,
|
RPL_WHOISSERVER,
|
||||||
RPL_WHOISOPERATOR,
|
RPL_WHOISOPERATOR,
|
||||||
|
@ -459,9 +460,14 @@ class Server(IServer):
|
||||||
RPL_WHOISSECURE,
|
RPL_WHOISSECURE,
|
||||||
RPL_ENDOFWHOIS
|
RPL_ENDOFWHOIS
|
||||||
], params))
|
], params))
|
||||||
|
if line.command == ERR_NOSUCHUSER:
|
||||||
if line.command == RPL_WHOISUSER:
|
return None
|
||||||
obj.username, obj.hostname, _, obj.realname = line.params[2:]
|
elif line.command == RPL_WHOISUSER:
|
||||||
|
nick, user, host, _, real = line.params[1:]
|
||||||
|
obj.nickname = nick
|
||||||
|
obj.username = user
|
||||||
|
obj.hostname = host
|
||||||
|
obj.realname = real
|
||||||
elif line.command == RPL_WHOISIDLE:
|
elif line.command == RPL_WHOISIDLE:
|
||||||
obj.idle, signon, _ = line.params[2:]
|
obj.idle, signon, _ = line.params[2:]
|
||||||
obj.signon = int(signon)
|
obj.signon = int(signon)
|
||||||
|
|
|
@ -11,9 +11,11 @@ class Whois(object):
|
||||||
signon: Optional[int] = None
|
signon: Optional[int] = None
|
||||||
idle: Optional[int] = None
|
idle: Optional[int] = None
|
||||||
|
|
||||||
username: Optional[str] = None
|
channels: Optional[List[str]] = None
|
||||||
hostname: Optional[str] = None
|
|
||||||
realname: Optional[str] = None
|
nickname: str = ""
|
||||||
|
username: str = ""
|
||||||
|
hostname: str = ""
|
||||||
|
realname: str = ""
|
||||||
account: Optional[str] = None
|
account: Optional[str] = None
|
||||||
|
|
||||||
channels: Optional[List[str]] = None
|
|
||||||
|
|
Loading…
Reference in a new issue