handle failure in send_joins()
This commit is contained in:
parent
8c514a956e
commit
9d4572edcc
1 changed files with 39 additions and 7 deletions
|
@ -29,6 +29,18 @@ THROTTLE_RATE = 4 # lines
|
||||||
THROTTLE_TIME = 2 # seconds
|
THROTTLE_TIME = 2 # seconds
|
||||||
PING_TIMEOUT = 60 # seconds
|
PING_TIMEOUT = 60 # seconds
|
||||||
|
|
||||||
|
JOIN_ERR_FIRST = [
|
||||||
|
ERR_NOSUCHCHANNEL,
|
||||||
|
ERR_BADCHANNAME,
|
||||||
|
ERR_UNAVAILRESOURCE,
|
||||||
|
ERR_TOOMANYCHANNELS,
|
||||||
|
ERR_BANNEDFROMCHAN,
|
||||||
|
ERR_INVITEONLYCHAN,
|
||||||
|
ERR_BADCHANNELKEY,
|
||||||
|
ERR_NEEDREGGEDNICK,
|
||||||
|
ERR_THROTTLE
|
||||||
|
]
|
||||||
|
|
||||||
class Server(IServer):
|
class Server(IServer):
|
||||||
_reader: ITCPReader
|
_reader: ITCPReader
|
||||||
_writer: ITCPWriter
|
_writer: ITCPWriter
|
||||||
|
@ -355,11 +367,31 @@ class Server(IServer):
|
||||||
channels: List[Channel] = []
|
channels: List[Channel] = []
|
||||||
|
|
||||||
while folded_names:
|
while folded_names:
|
||||||
line = await self.wait_for(
|
line = await self.wait_for({
|
||||||
Response(RPL_CHANNELMODEIS, [ANY, ANY])
|
Response(RPL_CHANNELMODEIS, [ANY, ANY]),
|
||||||
)
|
Responses(JOIN_ERR_FIRST, [ANY, ANY]),
|
||||||
|
Response(ERR_USERONCHANNEL, [ANY, SELF, ANY]),
|
||||||
|
Response(ERR_LINKCHANNEL, [ANY, ANY, ANY])
|
||||||
|
})
|
||||||
|
|
||||||
folded = self.casefold(line.params[1])
|
chan: Optional[str] = None
|
||||||
|
if line.command == RPL_CHANNELMODEIS:
|
||||||
|
chan = line.params[1]
|
||||||
|
elif line.command in JOIN_ERR_FIRST:
|
||||||
|
chan = line.params[1]
|
||||||
|
elif line.command == ERR_USERONCHANNEL:
|
||||||
|
chan = line.params[2]
|
||||||
|
elif line.command == ERR_LINKCHANNEL:
|
||||||
|
#XXX i dont like this
|
||||||
|
chan = line.params[2]
|
||||||
|
await self.wait_for(
|
||||||
|
Response(RPL_CHANNELMODEIS, [ANY, Folded(chan)])
|
||||||
|
)
|
||||||
|
channels.append(self.channels[self.casefold(chan)])
|
||||||
|
continue
|
||||||
|
|
||||||
|
if chan is not None:
|
||||||
|
folded = self.casefold(chan)
|
||||||
if folded in folded_names:
|
if folded in folded_names:
|
||||||
folded_names.remove(folded)
|
folded_names.remove(folded)
|
||||||
channels.append(self.channels[folded])
|
channels.append(self.channels[folded])
|
||||||
|
|
Loading…
Reference in a new issue