dotastats.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:MangoByte 作者: mdiller 项目源码 文件源码
def get_check_steamid(player, ctx, mention=False, no_error=False):
    is_author = player is None
    if is_author:
        player = ctx.message.author

    try:
        player = int(player)
    except (ValueError, TypeError):
        pass # This either this is a discord user or an invalid argument


    if isinstance(player, int):
        if player > 76561197960265728:
            player -= 76561197960265728

        # Don't have to rate limit here because this will be first query ran
        player_info = await opendota_query(f"/players/{player}")

        if player_info.get("profile") is None:
            raise UserError("Either this person doesn't play dota, or they haven't enabled public match data")
        if mention:
            return player, f"[{player_info['profile']['personaname']}](https://www.opendota.com/players/{player})"
        else:
            return player

    if not isinstance(player, discord.User):
        try:
            player = await commands.MemberConverter().convert(ctx, str(player))
        except commands.BadArgument:
            if no_error:
                return None
            raise UserError("Ya gotta @mention a user who has been linked to a steam id, or just give me a their steam id")

    userinfo = botdata.userinfo(player.id)
    if userinfo.steam32 is None:
        if no_error:
            return None
        if is_author:
            raise SteamNotLinkedError()
        else:
            raise SteamNotLinkedError(player)

    if mention:
        return userinfo.steam32, player.mention
    else:
        return userinfo.steam32
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号