async def leave_chan(user: Player, p: bytes) -> None: name = (reader.handle_packet(p, (("chan", osuTypes.string),)))["chan"] if name in ["#highlight", "#userlog"] or not name.startswith("#"): # osu why!!! return if name == "#spectator": if user.spectating is not None: uid = user.spectating.id elif user.spectators: uid = user.id else: return # not spectating chan = glob.channels.get(f"#spec_{uid}") elif name == "#multiplayer": if not user.match: return m = user.match.id chan = glob.channels.get(f"#multi_{m}") elif name == "#clan": if not user.clan: return chan = user.clan.chan else: chan = glob.channels.get(name) if not chan: return if user not in chan.players: return user.leave_chan(chan) chan_leave = writer.channelInfo(chan) for ( o ) in ( chan.players ): # TODO: playerlist instances for channels/multiplayer rooms etc..? o.enqueue(chan_leave)
async def leave_chan(user: Player, p: bytes) -> None: name = (reader.handle_packet(p, (('chan', osuTypes.string),)))['chan'] if name in ['#highlight', '#userlog'] or not name.startswith('#'): # osu why!!! return if name == '#spectator': if user.spectating is not None: uid = user.spectating.id elif user.spectators: uid = user.id else: return # not spectating chan = glob.channels.get(f'#spec_{uid}') elif name == '#multiplayer': if not user.match: return m = user.match.id chan = glob.channels.get(f'#multi_{m}') elif name == '#clan': if not user.clan: return chan = user.clan.chan else: chan = glob.channels.get(name) if not chan: return if user not in chan.players: return user.leave_chan(chan) chan_leave = writer.channelInfo(chan) for o in chan.players: #TODO: playerlist instances for channels/multiplayer rooms etc..? o.enqueue(chan_leave)