当前位置: 首页>>代码示例>>Python>>正文


Python User.compareRanks方法代码示例

本文整理汇总了Python中user.User.compareRanks方法的典型用法代码示例。如果您正苦于以下问题:Python User.compareRanks方法的具体用法?Python User.compareRanks怎么用?Python User.compareRanks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.User的用法示例。


在下文中一共展示了User.compareRanks方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unspecified_user_rank

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
def test_unspecified_user_rank():
    with pytest.raises(UnSpecifiedUserRankException):
        User.compareRanks('^', '*')

    try:
        User.compareRanks('^', '*')
    except UnSpecifiedUserRankException as e:
        assert str(e) == 'Unsupported user class:^'
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:10,代码来源:test_user.py

示例2: _success

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
    def _success(self, room, user, args):
        """ Returns a success response to the user.

        Successfully returns the expected response from the user based on the args.

        Args:
            room: Room, room this command was evoked from.
            user: User, user who evoked this command.
            args: list of str, any sequence of parameters which are supplied to this command
        Returns:
            ReplyObject
        """
        gameid = args[0]
        show_image = args[-1] == 'showimage' if args else False
        game_url = 'https://store.steampowered.com/app/{}'.format(gameid) 
        steaminfo = {'appids': gameid}
        r = requests.get('http://store.steampowered.com/api/appdetails', params=steaminfo)
        game_data = r.json()[gameid]['data']
        header_image, name, description = game_data['header_image'], game_data['name'], game_data['short_description']
        width, height = OnlineImage.get_image_info(header_image)
        if User.compareRanks(room.rank, '*') and show_image:
            res = ReplyObject(('/addhtmlbox <div id="gameinfo"> <img src="{}" height="{}" width="{}"></img> <p>Name: <a href="{}"> {}</a></p> <p>Description: {} </p> </div>').format(header_image, height, width, game_url, name, description), True, True)
            print(res.text)
            return res
        else:
            return ReplyObject('Name: {} Link: Description: {}'.format(name, game_url, description), True)
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:28,代码来源:Steam.py

示例3: response

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
    def response(self, room, user, args):
        """ Returns a response to the user.

        Args:
            room: Room, room this command was evoked from.
            user: User, user who evoked this command.
            args: list of str, any sequence of parameters which are supplied to this command
        Returns:
            ReplyObject
        """
        if len(args) == 1 and args[0] == 'help':
            return self._help(room, user, args)
        elif len(args) > 1 and args[0] != 'showimage':
            return self._error(room, user, 'too_many_args')
        elif len(args) == 1 and args[0] == 'showimage' and room.isPM:
            return self._error(room, user, 'show_image_pms')
        elif len(args) == 1 and args[0] == 'showimage' and not User.compareRanks(room.rank, '*'):
            return self._error(room, user, 'insufficient_room_rank')
        else:
            return self._success(room, user, args)
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:22,代码来源:Putnam.py

示例4: _success

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
    def _success(self, room, user, args):
        """ Returns a success response to the user.

        Successfully returns the expected response from the user based on the args.

        Args:
            room: Room, room this command was evoked from.
            user: User, user who evoked this command.
            args: list of str, any sequence of parameters which are supplied to this command
        Returns:
            ReplyObject
        """
        uploaded_image_data = self.handle_request(args[0])
        uploaded_image = uploaded_image_data[0]
        uploaded_image_dims = uploaded_image_data[1]

        show_image = args[-1] == 'showimage'
        if User.compareRanks(room.rank, '*') and show_image:
            # don't render to 100% of screen because latex renders badly
            return ReplyObject('/addhtmlbox <img src="{url}" height="{height}" width="{width}"></img>'.format(
                url=uploaded_image, height=uploaded_image_dims[1], width=uploaded_image_dims[0]), True, True)
        else:
            return ReplyObject(uploaded_image, True)
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:25,代码来源:Latex.py

示例5: response

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
    def response(self, room, user, args):
        """ Returns a response to the user.

        Args:
            room: Room, room this command was evoked from.
            user: User, user who evoked this command.
            args: list of str, possible args are showimage, and help
        Returns:
            ReplyObject
        """
        print(args)
        if len(args) == 1 and args[0] == 'help':
            return self._help(room, user, args)
        # error checking
        elif len(args) == 0:
            return self._error(room, user, 'insufficient_args')
        # handling addpackage command and latex command
        elif(len(args) == 2 and args[1] == 'addpackage' and user.hasRank('#')
             and not self.validate_package_install(args[0])):
            return self._error(room, user, 'invalid_package_install')
        elif len(args) == 2 and args[1] == 'addpackage' and not user.hasRank('#'):
            return self._error(room, user, 'insufficient_user_rank')
        elif(len(args) == 2 and args[1] == 'addpackage' and user.hasRank('#')
             and self.validate_package_install(args[0])):
            return self._success_add_package(room, user, args)
        elif len(args) >= 1 and not self.validate_request(args[0]):
            return self._error(room, user, 'invalid_latex_expression')
        elif len(args) == 2 and args[1] == 'showimage' and room.isPM:
            return self._error(room, user, 'show_image_pms')
        elif len(args) == 2 and args[1] == 'showimage' and not User.compareRanks(room.rank, '*'):
            return self._error(room, user, 'insufficient_room_rank')
        else:
            try:
                return self._success(room, user, args)
            except subprocess.CalledProcessError:
                return self._error(room, user, 'internal_error')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:38,代码来源:Latex.py

示例6: botHasBanPermission

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def botHasBanPermission(self):
     return User.compareRanks(self.rank, '@')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:room.py

示例7: userHasPermission

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def userHasPermission(self, user, rank):
     return self.isOwner(user.id) or User.compareRanks(user.rank, rank)
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py

示例8: canHtml

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def canHtml(self, room):
     return User.compareRanks(room.rank, '*')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py

示例9: canStartTour

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def canStartTour(self, room):
     return User.compareRanks(room.rank, '@')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py

示例10: canBan

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def canBan(self, room):
     return User.compareRanks(room.rank, '@')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py

示例11: canPunish

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def canPunish(self, room):
     return User.compareRanks(room.rank, '%')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py

示例12: canHTMLBox

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import compareRanks [as 别名]
 def canHTMLBox(self, room):
     return User.compareRanks(room.rank, '*')
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:4,代码来源:robot.py


注:本文中的user.User.compareRanks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。