Ejemplo n.º 1
0
    async def join_channel(self, c: Channel) -> bool:
        """Attempt to add `self` to `c`."""
        if self in c:
            # user already in the channel.
            if glob.config.debug:
                log(f'{self} was double-added to {c}.')

            return False

        if not self.priv & c.read:
            log(f'{self} tried to join {c} but lacks privs.')
            return False

        # lobby can only be interacted with while in mp lobby.
        if c._name == '#lobby' and not self.in_lobby:
            return False

        c.append(self)  # Add to channels
        self.channels.append(c)  # Add to player

        self.enqueue(packets.channelJoin(c.name))

        # update channel usercounts for all clients that can see.
        # for instanced channels, enqueue update to only players
        # in the instance; for normal channels, enqueue to all.
        targets = c.players if c.instance else glob.players

        for p in targets:
            p.enqueue(packets.channelInfo(*c.basic_info))

        if glob.config.debug:
            log(f'{self} joined {c}.')

        return True
Ejemplo n.º 2
0
    async def join_channel(self, c: Channel) -> bool:
        if self in c:
            # User already in the channel.
            await plog(f'{self} tried to double join {c}.')
            return False

        if not self.priv & c.read:
            await plog(f'{self} tried to join {c} but lacks privs.')
            return False

        # Lobby can only be interacted with while in mp lobby.
        if c._name == '#lobby' and not self.in_lobby:
            return False

        c.append(self)  # Add to channels
        self.channels.append(c)  # Add to player

        self.enqueue(await packets.channelJoin(c.name))

        # Update channel usercounts for all clients that can see.
        # For instanced channels, enqueue update to only players
        # in the instance; for normal channels, enqueue to all.
        targets = c.players if c.instance else glob.players

        for p in targets:
            p.enqueue(await packets.channelInfo(*c.basic_info))

        await plog(f'{self} joined {c}.')
        return True
Ejemplo n.º 3
0
    def join_channel(self, c: Channel) -> bool:
        if self in c:
            printlog(f'{self} tried to double join {c}.')
            return False

        if not self.priv & c.read:
            printlog(f'{self} tried to join {c} but lacks privs.')
            return False

        # Lobby can only be interacted with while in mp lobby.
        if c._name == '#lobby' and not self.in_lobby:
            return False

        c.append(self)  # Add to channels
        self.channels.append(c)  # Add to player

        self.enqueue(packets.channelJoin(c.name))
        printlog(f'{self} joined {c}.')
        return True