also query MODE +beIq on JOIN, don't hold the thread for ENDOFWHO

This commit is contained in:
jesopo 2020-09-29 12:14:15 +00:00
parent cdad0895e1
commit 99254abc9c

View file

@ -165,6 +165,13 @@ class Server(IServer):
if line.command == "PING": if line.command == "PING":
await self.send(build("PONG", line.params)) await self.send(build("PONG", line.params))
elif line.command == RPL_ENDOFWHO:
chan = self.casefold(line.params[1])
if (self._pending_who and
self._pending_who[0] == chan):
self._pending_who.pop()
await self._next_who()
elif emit is not None: elif emit is not None:
if emit.command == "001": if emit.command == "001":
await self.send(build("WHO", [self.nickname])) await self.send(build("WHO", [self.nickname]))
@ -185,11 +192,15 @@ class Server(IServer):
elif emit.command == "JOIN": elif emit.command == "JOIN":
if emit.self and not emit.channel is None: if emit.self and not emit.channel is None:
await self.send(build("MODE", [emit.channel.name])) chan = emit.channel.name_lower
await self.send(build("MODE", [chan]))
self._pending_who.append(emit.channel.name) modes = "".join(self.isupport.chanmodes.a_modes)
await self.send(build("MODE", [chan, f"+{modes}"]))
self._pending_who.append(chan)
if len(self._pending_who) == 1: if len(self._pending_who) == 1:
await self._serial_who() await self._next_who()
await self.line_read(line) await self.line_read(line)
@ -203,17 +214,13 @@ class Server(IServer):
batch = channels[i:i+batch_n] batch = channels[i:i+batch_n]
await self.send(build("JOIN", [",".join(batch)])) await self.send(build("JOIN", [",".join(batch)]))
async def _serial_who(self): async def _next_who(self):
while self._pending_who: if self._pending_who:
next = self._pending_who.popleft() chan = self._pending_who[0]
if self.isupport.whox: if self.isupport.whox:
await self.send(self.prepare_whox(next)) await self.send(self.prepare_whox(chan))
else: else:
await self.send(build("WHO", [next])) await self.send(build("WHO", [chan]))
end = Response(RPL_ENDOFWHO, [ANY, Folded(next)])
line = await self.wait_for(end)
async def _read_line(self, timeout: float) -> Optional[Line]: async def _read_line(self, timeout: float) -> Optional[Line]:
while True: while True: