コード例 #1
0
    def join_chan(self, chan: Channel) -> None:
        if self in chan.players:
            return

        chan.add_player(self)
        self.channels.append(chan)

        self.enqueue(writer.channelJoin(chan.name))
        for o in chan.players:
            o.enqueue(writer.channelInfo(chan))

        info(f"{self.name} joined channel {chan.name}")
コード例 #2
0
    def leave_chan(self, chan: Channel) -> None:
        if not glob.channels.get(chan.name) or self not in chan.players:
            return

        chan.remove_player(self)
        self.channels.remove(chan)

        self.enqueue(writer.channelKick(chan.name))
        for o in chan.players:
            o.enqueue(writer.channelInfo(chan))

        info(f"{self.name} left channel {chan.name}")
コード例 #3
0
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)
コード例 #4
0
ファイル: bancho.py プロジェクト: cmyui/Asahi
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)
コード例 #5
0
    def remove_spectator(self, user: "******") -> None:
        self.spectators.remove(user)
        user.spectating = None

        spec = glob.channels.get(f"#spec_{self.id}")

        user.leave_chan(spec)

        if not self.spectators:
            self.leave_chan(spec)
        else:
            cinfo = writer.channelInfo(spec)
            for u in self.spectators:
                u.enqueue(writer.spectatorLeft(user.id))
                u.enqueue(cinfo)

            self.enqueue(cinfo)

        self.enqueue(writer.hostSpectatorLeft(user.id))
        info(f"{user.name} stopped spectating {self.name}.")
コード例 #6
0
    def remove_spectator(self, user: '******') -> None:
        self.spectators.remove(user)
        user.spectating = None

        spec = glob.channels.get(f'#spec_{self.id}')

        user.leave_chan(spec)

        if not self.spectators:
            self.leave_chan(spec)
        else:
            cinfo = writer.channelInfo(spec)
            for u in self.spectators:
                u.enqueue(writer.spectatorLeft(user.id))
                u.enqueue(cinfo)

            self.enqueue(cinfo)

        self.enqueue(writer.hostSpectatorLeft(user.id))
        log(f'{user.name} stopped spectating {self.name}.', Ansi.LBLUE)
コード例 #7
0
ファイル: bancho.py プロジェクト: cmyui/Asahi
        data = bytearray(writer.userID(p.id)) # initiate login by providing the user's id
        data += writer.protocolVersion(19) # no clue what this does
        data += writer.banchoPrivileges(p.client_priv | ClientPrivileges.Supporter)
        data += writer.userPresence(p) + writer.userStats(p) # provide user & other user's presence/stats (for f9 + user stats)
        data += writer.channelInfoEnd() # no clue what this does either
        data += writer.menuIcon() # set main menu icon
        data += writer.friends(p.friends) # send user friend list
        data += writer.silenceEnd(p.silence_end)

        # get channels from cache and send to user
        for chan in glob.channels.values():
            if chan.auto:
                p.join_chan(chan)
                data += writer.channelJoin(chan.name) # only join user to channel if the channel is meant for purpose

            data += writer.channelInfo(chan) # regardless of whether the channel should be auto-joined we should make the client aware of it

        # add user to cache?
        glob.players.append(p)

        if not p.restricted:
            glob.players.enqueue(writer.userPresence(p) + writer.userStats(p))

        for o in glob.players:
            data += writer.userPresence(o) + writer.userStats(o) # enqueue every other logged in user to this user

        if p.clan:
            p.join_chan(p.clan.chan)

            # doesnt join_chan func already handle this? lol i dont remember ill check tomorrow
            data += writer.channelJoin(p.clan.chan.name)