예제 #1
0
    async def get_player(self, login=None, pk=None, lock=True):
        """
		Get player by login or primary key.

		:param login: Login.
		:param pk: Primary Key identifier.
		:param lock: Lock for a sec when receiving.
		:return: Player or exception if not found
		:rtype: pyplanet.apps.core.maniaplanet.models.Player
		"""
        try:
            if login:
                return await Player.get_by_login(login)
            elif pk:
                return await Player.get(pk=pk)
            else:
                raise PlayerNotFound('Player not found.')
        except DoesNotExist:
            if lock:
                await asyncio.sleep(4)
                return await self.get_player(login=login, pk=pk, lock=False)
            else:
                raise PlayerNotFound('Player not found.')
예제 #2
0
	async def kick_player(self, player, data, **kwargs):
		try:
			if data.login not in self.instance.player_manager.online_logins:
				raise PlayerNotFound()

			kick_player = await self.instance.player_manager.get_player(data.login)
			message = '$ff0Admin $fff{}$z$s$ff0 has kicked $fff{}$z$s$ff0.'.format(player.nickname, kick_player.nickname)
			await self.instance.gbx.multicall(
				self.instance.gbx('Kick', data.login),
				self.instance.chat(message)
			)
		except PlayerNotFound:
			message = '$i$f00Unknown login!'
			await self.instance.chat(message, player)
예제 #3
0
파일: player.py 프로젝트: w1lla/PyPlanet
 async def ignore_player(self, player, data, **kwargs):
     try:
         if data.login not in self.instance.player_manager.online_logins:
             raise PlayerNotFound()
         mute_player = await self.instance.player_manager.get_player(
             data.login)
         if mute_player.level >= player.level:
             raise PermissionError()
         message = '$ff0Admin $fff{}$z$s$ff0 has muted $fff{}$z$s$ff0.'.format(
             player.nickname, mute_player.nickname)
         await self.instance.gbx.multicall(
             self.instance.gbx('Ignore', data.login),
             self.instance.chat(message))
     except PlayerNotFound:
         message = '$i$f00Unknown login!'
         await self.instance.chat(message, player)
     except PermissionError:
         message = '$i$f00Can\'t perform this action on an admin at the same or higher level as you!'
         await self.instance.chat(message, player)