Exemplo n.º 1
0
    async def rating(self, ctx, platform: valid_platform, *, username):
        """Returns player ratings.

        `<platform>` - The platform of the player to get the SRs for.
        `<username>` - The username of the player to get the SRs for.

        Platforms:
        - pc, bnet
        - playstation, ps, psn, ps4, ps5, play
        - xbox, xbl
        - nintendo-switch, nsw, switch

        Username:
        - pc: BattleTag (format: name#0000)
        - playstation: Online ID
        - xbox: Gamertag
        - nintendo-switch: Nintendo Network ID
        """
        profile = Profile(platform, username, ctx=ctx)
        await profile.compute_data()
        if profile.is_private():
            embed = profile.embed_private()
        else:
            embed = await profile.embed_ratings()
        await ctx.send(embed=embed)
Exemplo n.º 2
0
 async def show_stats_for(self, ctx, hero, platform, username):
     profile = Profile(platform, username, ctx=ctx)
     await profile.compute_data()
     if profile.is_private():
         embed = profile.embed_private()
     else:
         embed = profile.embed_stats(hero)
     await self.bot.paginate(embed, ctx=ctx)
Exemplo n.º 3
0
    async def summary(self, ctx: "Context", member: discord.Member = None) -> None:
        """Provides summarized stats for a profile.

        `[member]` - The mention or the ID of a Discord member.

        If no member is given, the stats returned will be yours.
        """
        member = member or ctx.author
        message = "Select a profile to view the summary for."
        record = await choose_profile(ctx, message, member)
        profile = Profile(ctx=ctx, record=record)
        await profile.compute_data()
        if profile.is_private():
            embed = profile.embed_private()
        else:
            embed = profile.embed_summary()
        await ctx.send(embed=embed)
Exemplo n.º 4
0
    async def rating(self, ctx: "Context", member: discord.Member = None) -> None:
        """Provides SRs information for a profile.

        `[member]` - The mention or the ID of a Discord member.

        If no member is given, the ratings returned will be yours.
        """
        member = member or ctx.author
        message = "Select a profile to view the skill ratings for."
        record = await choose_profile(ctx, message, member)
        profile = Profile(ctx=ctx, record=record)
        await profile.compute_data()
        if profile.is_private():
            embed = profile.embed_private()
        else:
            embed = await profile.embed_ratings(save=True, profile_id=profile.id)
            # only update the nickname if the profile matches the one
            # selected for that purpose
            query = "SELECT * FROM nickname WHERE profile_id = $1;"
            flag = await self.bot.pool.fetchrow(query, profile.id)
            if flag and member.id == ctx.author.id:
                await Nickname(ctx, profile=profile).update()
        await ctx.send(embed=embed)
Exemplo n.º 5
0
    async def nickname(self, ctx: "Context") -> None:
        """Shows or remove your SRs in your nickname.

        The nickname can only be set in one server. It updates
        automatically whenever `profile rating` is used and the
        profile selected matches the one set for the nickname.
        """
        nick = Nickname(ctx)
        if not await nick.exists():
            if not await ctx.prompt("This will display your SRs in your nickname."):
                return

            if ctx.guild.me.top_role < ctx.author.top_role:
                return await ctx.send(
                    "This server's owner needs to move the `OverBot` role higher, so I will "
                    "be able to update your nickname. If you are this server's owner, there's "
                    "not way for me to change your nickname, sorry!"
                )

            message = "Select a profile to use for the nickname SRs."
            record = await choose_profile(ctx, message, ctx.author)
            profile = Profile(ctx=ctx, record=record)
            nick.profile = profile

            if profile.is_private():
                return await ctx.send(embed=profile.embed_private())

            try:
                await nick.set_or_remove(profile_id=profile.id)
            except Exception as e:
                await ctx.send(e)
        else:
            if await ctx.prompt("This will remove your SR in your nickname."):
                try:
                    await nick.set_or_remove(remove=True)
                except Exception as e:
                    await ctx.send(e)
Exemplo n.º 6
0
    def __init__(self, host, profile, verbose, desperate):
        self.plugins = self.load_plugins()
        self.host = host
        self.results = Results()
        self.cache = Cache()
        self.profile = Profile(profile)
        self.colorizer = Color()
        self.logs = Log()
        self.verbose = verbose

        self.check_url()
        self.redirect()
        self.cache.set_host(self.host)

        if desperate:
            self.desperate = Desperate()
        else:
            self.desperate = None
Exemplo n.º 7
0
def create_profile(name, elo, constant=False, history=[]):
    profile = Profile(name, elo, constant, history)
    profiles[name] = profile