Exemplo n.º 1
0
    async def lookup(self, ctx, *, username):
        if not utils.is_valid_rsn(username):
            return await ctx.send(f"{username} is not a valid RSN")

        try:
            username_parsed = username.replace(" ", "_")
            intro_msg = await ctx.send("Searching for User... If there is no response, there was no account found.")
            user = Hiscores(username_parsed, 'N')

            skills_list = [ 'Attack',           'Hitpoints',    'Mining',
                            'Strength',         'Agility',      'Smithing',
                            'Defense',          'Herblore',     'Fishing',
                            'Ranged',           'Thieving',     'Cooking',
                            'Prayer',           'Crafting',     'Firemaking',
                            'Magic',            'Fletching',    'Woodcutting',
                            'Runecrafting',     'Slayer',       'Farming',
                            'Construction',     'Hunter',       'Total' ]

            embed = discord.Embed(title=username, description="OSRS Hiscores Lookup", color=0x00ff00)

            for skill in skills_list:
                embed.add_field(name=f"{skill} - {user.skill(skill.lower())}",
                                   value=f"EXP - {int(user.skill(skill.lower(), 'experience')):,d}",
                                   inline=True)

            await ctx.send(embed=embed)

        except Exception as e:
            await ctx.send("Something went terribly wrong. :(")
            raise e

        await intro_msg.delete()
Exemplo n.º 2
0
    async def predict(self, ctx, *, player_name):

        pending_msg = await ctx.send(
            "Searching the database for the predicted username.")
        await ctx.trigger_typing()

        if not utils.is_valid_rsn(player_name):
            if len(player_name) < 1:
                await ctx.send(f"Please enter a valid Runescape user name.")
                return
            else:
                await ctx.send(
                    f"{player_name} isn't a valid Runescape user name.")
                return

        async with self.bot.session.get(
                f"https://www.osrsbotdetector.com/api/site/prediction/{player_name}"
        ) as r:
            if r.status != 200:
                return await ctx.send(
                    f"I couldn't get a prediction for {player_name} :(")

            js = await r.json()

        name = js['player_name']
        prediction = js['prediction_label']
        player_id = js['player_id']
        confidence = js['prediction_confidence']
        secondaries = js['secondary_predictions']

        msg = cleandoc(f"""```diff
            + Name: {name}
            {utils.plus_minus(prediction, 'Real_Player')} Prediction: {prediction}
            {utils.plus_minus(confidence, 0.75)} Confidence: {confidence * 100:.2f}%
            + ID: {player_id}
            ============
            Prediction Breakdown
        """)

        msg += "\n"

        for predict in secondaries:
            msg += cleandoc(f"""
                {utils.plus_minus(predict[0], 'Real_Player')} {predict[0]}: {predict[1] * 100:.2f}%
            """)

            msg += "\n"

        msg += "```"

        await pending_msg.delete()
        await ctx.send(msg)
Exemplo n.º 3
0
    async def export_bans(self, ctx, playerName, filetype):
        discord_id = ctx.author.id

        if not utils.is_valid_rsn(playerName):
            return await ctx.send(f"{playerName} isn't a valid Runescape user name.")

        status = await discord_processing.get_player_verification_full_status(self.bot.session, playerName=playerName, token=token)

        try:
            owner_id = status[0]['Discord_id']
            verified = status[0]['Verified_status']
        except:
            return await ctx.send(f"Please verify your ownership of: '{playerName}'. Type `!link {playerName}' in this channel.")

        if discord_id != owner_id:
            return await ctx.send(f"Please verify your ownership of: '{playerName}'. Type `!link {playerName}' in this channel.")

        if verified == 0:
            return await ctx.send(f"You must complete the verification process for: '{playerName}'. Please check your DMs for a previously sent verification token.")

        info_msg = await ctx.send("Getting that data for you right now! One moment, please :)")

        async with self.bot.session.get(f"https://www.osrsbotdetector.com/api/discord/player_bans/{token}/{playerName}") as r:
            if r.status != 200:
                return await info_msg.edit(content=f"Could not grab the banned bots {filetype} file for {playerName}.")
            js = await r.json()

            df = pd.DataFrame(js)
            if filetype == 'excel':
                df.to_excel(f"{playerName}_bans.xlsx")
                filePath = f'{os.getcwd()}/{playerName}_bans.xlsx'
            else:
                df.to_csv(f"{playerName}_bans.csv")
                filePath = f'{os.getcwd()}/{playerName}_bans.csv'

            await ctx.author.send(file=discord.File(filePath))
            os.remove(filePath)
            await info_msg.edit(content=f"Your {filetype} file for {playerName} has been sent to your DMs.")
Exemplo n.º 4
0
    async def kc(self, ctx, *, player_name=None):
        await ctx.trigger_typing()
        if not player_name:
            linkedAccounts = await discord_processing.get_linked_accounts(
                self.bot.session, ctx.author.id, token)

            if not linkedAccounts:
                embed = discord.Embed(description=cleandoc(f"""
                        Please include a player name or use the !link command to pair an OSRS account.
                        Once you have paired at least one account you will no longer need to type a name.
                    """))

                return await ctx.send(embed=embed)

            async with self.bot.session.get(
                    url=
                    "https://www.osrsbotdetector.com/api/stats/contributions/",
                    json=json.dumps(linkedAccounts)) as r:
                if r.status != 200:
                    return await ctx.send(
                        f"Couldn't grab the !kc for {ctx.author.display_name}")

                js = await r.json()

            manual_reports = int(js['manual']['reports'])
            manual_bans = int(js['manual']['bans'])
            manual_incorrect = int(js['manual']['incorrect_reports'])

            total_reports = int(js['total']['reports'])
            total_bans = int(js['total']['bans'])
            total_possible_bans = int(js['total']['possible_bans'])

            embed = discord.Embed(title=f"{ctx.author.display_name}'s Stats",
                                  color=0x00ff00)

        elif utils.is_valid_rsn(player_name):
            async with self.bot.session.get(
                    f"https://www.osrsbotdetector.com/api/stats/contributions/{player_name}"
            ) as r:
                if r.status != 200:
                    return await ctx.send(
                        f"Couldn't grab the !kc for {player_name}")

                js = await r.json()

            manual_reports = int(js['manual']['reports'])
            manual_bans = int(js['manual']['bans'])
            manual_incorrect = int(js['manual']['incorrect_reports'])

            total_reports = int(js['total']['reports'])
            total_bans = int(js['total']['bans'])
            total_possible_bans = int(js['total']['possible_bans'])

            embed = discord.Embed(title=f"{player_name}'s Stats",
                                  color=0x00ff00)
        else:
            return await ctx.send(
                f"{player_name} isn't a valid Runescape user name.")

        if manual_reports == 0:
            report_accuracy = None
        elif manual_incorrect == 0:
            report_accuracy = 100.00
        else:
            report_accuracy = round(
                (manual_bans / (manual_bans + manual_incorrect)) * 100, 2)

        embed.add_field(name="Reports Submitted:",
                        value=f"{total_reports:,d}",
                        inline=False)
        embed.add_field(name="Possible Bans:",
                        value=f"{total_possible_bans:,d}",
                        inline=False)
        embed.add_field(name="Confirmed Bans:",
                        value=f"{total_bans:,d}",
                        inline=False)

        if report_accuracy is not None:
            embed.add_field(name="Manual Flags:",
                            value=f"{manual_reports:,d}",
                            inline=False)
            embed.add_field(name="Manual Flag Accuracy:",
                            value=f"{report_accuracy}%",
                            inline=False)

        embed.set_thumbnail(
            url=
            "https://user-images.githubusercontent.com/5789682/117364618-212a3200-ae8c-11eb-8b42-9ef5e225930d.gif"
        )

        if total_reports == 0:
            embed.set_footer(
                text=
                "If you have the plugin installed but are not seeing your KC increase\nyou may have to disable Anonymous Mode in your plugin settings.",
                icon_url=
                "https://raw.githubusercontent.com/Bot-detector/bot-detector/master/src/main/resources/warning.png"
            )

        await ctx.send(embed=embed)