channeltrack doesn't track topic because RPL_TOPIC is processed before user_join
When joining a channel with asyncio, it looks like the RPL_TOPIC (332) event and the RPL_TOPICWHOTIME (333) events are getting dispatched before the user_join event despite the JOIN message happening before RPL_TOPIC.
Sample logger output:
DEBUG:PyIRC.io.asyncio:OUT: JOIN #corvids
DEBUG:PyIRC.io.asyncio:IN: :crowbot!~crowbot@crowbot JOIN #corvids * :I am a test, pls ignore :)
DEBUG:PyIRC.io.asyncio:IN: :joestar.interlinked.me 332 crowbot #corvids :Not to be confused with #crows
DEBUG:PyIRC.io.asyncio:IN: :joestar.interlinked.me 333 crowbot #corvids raven!~lee@interlinked/netadmin/bird/raven :1612672221
DEBUG:PyIRC.io.asyncio:IN: :joestar.interlinked.me 353 crowbot @ #corvids :crowbot!~crowbot@Interlinked-hp5hq6.nej9.ot32.acqjve.IP ~@raven!~lee@interlinked/netadmin/bird/raven ~@crow!~lucius@interlinked/netadmin/bird/raven @ChanServ!ChanServ@services.interlinked.me
DEBUG:PyIRC.io.asyncio:IN: :joestar.interlinked.me 366 crowbot #corvids :End of /NAMES list.
DEBUG:PyIRC.extensions.channeltrack:RPL_TOPIC for unknown channel: #corvids
DEBUG:PyIRC.extensions.channeltrack:Topic time for unknown channel: #corvids
DEBUG:PyIRC.extensions.channeltrack:Received user_join for nick crowbot, channel #corvids
DEBUG:PyIRC.extensions.channeltrack:Adding channel: #corvids
I see two possible solutions:
- Make the user_join event processed synchronously, or
- Make channeltrack track topics received from RPL_TOPIC and timestamps from RPL_TOPICWHOTIME even for channels that aren't yet in self.channels, then add them to the Channel objects when they're created from the user_join event