示例#1
0
 async def help(self, ctx):
     try:
         disc = f"\n**NOTE**: You can find the arguments a command supports by typing the command with `args` at the end.\n**Example**: `{ctx.prefix}player ARGS`\n"
         intro = "Surviv Stat Bot Commands!\nThe Game is playable at https://surviv.io/."
         info_command_desc = f"ℹ️ `{ctx.prefix}info` - Returns some information on the game surviv.io.\n"
         melee_command_desc = f"🔪 `{ctx.prefix}melee` - Returns stats for a melee weapon in surviv.io.\n"
         link_command_desc = f"🔗 `{ctx.prefix}link` - Returns a party link for surviv.io that expires in 7 seconds.\n"
         ping_command_desc = f"🏓 `{ctx.prefix}ping` - Gets the current latency of the bot.\n"
         gun_command_desc = f"\U0001F52B `{ctx.prefix}gun` - Returns stats for a gun in surviv.io.\n"
         player_command_desc = f"⛹ `{ctx.prefix}player` - Returns stats for a player in surviv.io.\n"
         twitch_command_desc = f"🕹️ `{ctx.prefix}twitch` - Returns the top streamers currently streaming surviv.io.\n"
         update_command_desc = f"🆕 `{ctx.prefix}update` - Returns the current update in surviv.io.\n"
         website_command_desc = f"🔗`{ctx.prefix}website` - Link to the website.\n"
         supportserver_command_desc = f"🔗`{ctx.prefix}support` - Link to the support server.\n"
         surviv_regions_command_desc = f"🌎 `{ctx.prefix}regions` - All of the surviv.io regions.\n"
         ad_command_desc = f"Your Server Could be here! Join the support server for more info.\n"
         embed = discord.Embed(
             title=
             "<:survivio:787315420074868768> Surviv.io Commands <:survivio:787315420074868768>",
             description=
             f"{disc}\n{intro}\n\n{info_command_desc}{melee_command_desc}{ping_command_desc}{gun_command_desc}{player_command_desc}{twitch_command_desc}{update_command_desc}{ surviv_regions_command_desc}{supportserver_command_desc}",
             color=self.color)
         embed.set_footer(
             text=f"{self.name} Dashboard requested by {ctx.message.author}",
             icon_url=ctx.author.avatar_url)
         await ctx.send(embed=embed)
         StreamLogger.log(
             f'{ctx.message.author} ran {self.name} Command successfully.')
     except Exception as e:
         WarningLogger.log(
             f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
         )
示例#2
0
    def startup(self):
        """" Startup bot and load all cogs """
        try:
            os.remove('cogs/__pycache__')
        except FileNotFoundError:
            WarningLogger.log('Could not remove __pycache__ (did not exist).')

        for game in os.listdir('cogs'):  # load all cogs
            for cog in os.listdir('cogs/' + game):
                if cog.endswith('.py') and cog not in self.dont_load[
                        game]:  # don't load cogs if they're in don't load
                    try:
                        self.load_extension("cogs." + game + '.' + cog[:-3])
                        AssessLogger.log(
                            f'Successfully loaded {cog} extension from {game} folder.'
                        )
                    except Exception as e:
                        error_state = 'Could not load cog: {} from {} folder. Raised {}'
                        if not str(e).endswith(
                                '.'
                        ):  # tiny tidbit to make logs a bit more cleaner
                            error_state += '.'
                        ErrorLogger.log(error_state.format(cog, game, str(e)))
                        AssessLogger.log(
                            'Encountered Error: Could not load Cog.')
                        wrapup_all()
                elif cog == '__pycache__':
                    shutil.rmtree(f'cogs/{game}/{cog}')
                else:
                    AssessLogger.log(
                        f'Not loading {cog} cog from {game} folder.')
        print('All Cogs Loaded.')
示例#3
0
    async def update(self, ctx):
        try:
            conn = await aiosqlite.connect('data/rotating/surviv.db')
            c = await conn.cursor()
            await c.execute('select * from new')
            res = await c.fetchall()
            content = res[0][2]
            current_title = res[0][0]
            current_date = res[0][1]
            embed = discord.Embed(
                title=f'🆕  {current_title} ~ ({current_date}) 🆕 ',
                description=f'{content}',
                color=self.color)

            embed.set_footer(
                text=f"{self.name} requested by {ctx.message.author}",
                icon_url=ctx.author.avatar_url)
            await ctx.send(embed=embed)

            StreamLogger.log(
                f'{ctx.message.author} ran {self.name} Command successfully.')
            await conn.close()
        except Exception as e:
            try:
                await conn.close()
            except:
                pass
            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
            )
            error_embed = discord.Embed(
                description=
                f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`",
                color=self.color)
            await ctx.send(embed=error_embed)
示例#4
0
    async def support(self, ctx):
        """ Website Command  """
        try:
            await ctx.send(self.website)
        except Exception as e:

            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
            )
示例#5
0
    async def ping(self, ctx):
        """ Ping Command  """
        try:
            await ctx.send(f'Pong! {round(self.bot.latency * 1000)}ms')

        except Exception as e:

            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
            )
示例#6
0
 async def info(self, ctx):
     """ Info Command  """
     try:
         surviv_brief_desc = "\"Surviv.io is a popular top-down battle royale game in which players spawn on an island and gear up to fight each other to be the last one standing and win the chicken dinner. As well as having outstanding mechanics and game knowledge, players must choose from a variety of different weapons, skins, and equipments in order to outplay their opponents and survive.\" - **Surviv.io Wiki**\n\nYou can play at https://surviv.io/."
         embed = discord.Embed(description=f"**What is surviv.io?**\n\n{surviv_brief_desc}",
                               color = self.color)
         embed.set_footer(text=f"{self.name} requested by {ctx.message.author}", icon_url=ctx.author.avatar_url)
         await ctx.send(embed=embed) 
     except Exception as e:
         WarningLogger.log(f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}')
示例#7
0
    async def player(self, ctx, player_name):
        try:
            player_lowered = player_name.lower()
            player_payload = {
                "slug": f"{player_lowered}",
                "interval": "all",
                "mapIdFilter": "-1"
            }
            async with self._session.post(self.url,
                                          headers=self.headers,
                                          json=player_payload) as r:
                player_data = await r.json()
            if not player_data:  # no such player
                embed = discord.Embed(
                    description=
                    f"**{player_name}** is not a valid player of surviv.io.",
                    color=self.color)
                embed.set_footer(
                    text=f"{self.name} Stats requested by {ctx.message.author}",
                    icon_url=ctx.author.avatar_url)
                await ctx.send(embed=embed)
            else:
                kills = player_data["kills"]
                wins = player_data["wins"]
                games = player_data["games"]
                kg = player_data["kpg"]
                mostkills = max([i["mostKills"] for i in player_data["modes"]])
                maxDamage = max(
                    [i["mostDamage"] for i in player_data["modes"]])
                embed = discord.Embed(
                    title=f" **{player_data['username']}'s Stats**",
                    description=
                    f"**Wins**: {wins} \n **Kills**: {kills} \n **Games**: {games} \n **Kill Per Game Avg**: {kg} \n **Max Kills**: {mostkills} \n **Most Damage**: {maxDamage}",
                    color=self.color,
                )
                embed.set_footer(
                    text=f"{self.name} Stats requested by {ctx.message.author}",
                    icon_url=ctx.author.avatar_url)
                await ctx.send(embed=embed)

            StreamLogger.log(
                f'{ctx.message.author} ran {self.name} Command successfully.')

        except Exception as e:
            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
            )
            error_embed = discord.Embed(
                description=
                f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`",
                color=self.color)
            await ctx.send(embed=error_embed)
示例#8
0
 async def gun(self, ctx, *args):
     gun = ' '.join(args).strip()
     if gun == '':
         gun = "''"
     try:
         conn = await aiosqlite.connect('data/rotating/surviv.db')
         c = await conn.cursor()
         await c.execute('select * from guns')
         res = await c.fetchall()
         for t in res:
             if gun.lower() == t[0].lower():
                 break
         if t[0].lower() != gun.lower():
             guns = [i for i in list(zip(*res))[0]]
             embed = discord.Embed(
                 description=
                 f"\"**{gun}**\" is not a valid gun in **surviv.io**\n\n**Valid Guns**: {', '.join(guns)}",
                 color=self.color,
             )
             embed.set_footer(
                 text=f"{self.name} Stats requested by {ctx.message.author}",
                 icon_url=ctx.author.avatar_url)
             await ctx.send(embed=embed)
         else:
             embed = discord.Embed(
                 title=f"{t[0]} Stats",
                 description=
                 f"**Bullet Damage**: {t[1]} \n **Shot Spread**: {t[2]} \n **Reload Time**: {t[3]} \n **Firing Delay**: {t[4]}",
                 color=self.color,
             )
             embed.set_footer(
                 text=f"{self.name} Stats requested by {ctx.message.author}",
                 icon_url=ctx.author.avatar_url)
             await ctx.send(embed=embed)
         StreamLogger.log(
             f'{ctx.message.author} ran {self.name} Command successfully.')
         await conn.close()
     except Exception as e:
         try:
             await conn.close()
         except:
             pass
         WarningLogger.log(
             f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
         )
示例#9
0
 async def help(self, ctx):
     try:
         disc = f"\n**NOTE**: You can find the arguments a command supports by typing the command with `args` at the end.\n**Example**: `{ctx.prefix}player`\n"
         intro = "The Riptide Bot supports commands for the game **surviv.io**.\nThe Game is playable at https://surviv.io/."
         info_command_desc  = f"ℹ `{ctx.prefix}info` - Returns some information on the game surviv.io.\n"
         melee_command_desc = f"🔪 `{ctx.prefix}melee` - Returns stats for a melee weapon in surviv.io.\n"
         link_command_desc = f"🔗 `{ctx.prefix}link` - Returns a party link for surviv.io that expires in 7 seconds.\n"
         gun_command_desc = f"\U0001F52B `{ctx.prefix}gun` - Returns stats for a gun in surviv.io.\n"
         player_command_desc = f"⛹ `{ctx.prefix}player` - Returns stats for a player in surviv.io.\n"
         twitch_command_desc = f"🕹️ `{ctx.prefix}twitch` - Returns the top streamers currently streaming surviv.io.\n"
         update_command_desc = f"🆕 `{ctx.prefix}update` - Returns the current update in surviv.io.\n" 
         embed = discord.Embed(title="<:surviv:743213975889641575>  Surviv.io Commands  <:surviv:743213975889641575>",
                               description = f"{disc}\n{intro}\n\n{info_command_desc}{melee_command_desc}{link_command_desc}{gun_command_desc}{player_command_desc}{twitch_command_desc}{update_command_desc}",
                               color=self.color)
         embed.set_footer(text=f"{self.name} Dashboard requested by {ctx.message.author}", icon_url=ctx.author.avatar_url)
         await ctx.send(embed=embed)
         StreamLogger.log(f'{ctx.message.author} ran {self.name} Command successfully.')
     except Exception as e:
         WarningLogger.log(f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}')
示例#10
0
    async def twitch(self, ctx):
        try:
            async with self._session.get(self.url, headers=self.headers) as r:
                raw_json = await r.json()
                # parse json
                embed = discord.Embed(
                    title="Current Surviv Streamers",
                    description=
                    "[Surviv.io on Twitch!](https://www.twitch.tv/directory/game/surviv.io)",
                    color=self.color)
                for t in raw_json['twitch']:
                    embed.add_field(
                        name=f"Streamer: {t['name']}",
                        value=
                        f"Watch: [{t['title']}]({t['url']})\nViewers: `{t['viewers']}`",
                        inline=True)
                if not len(raw_json['twitch']):
                    embed = discord.Embed(
                        description=
                        "No Surviv Twitch Streamers are **currently streaming**.",
                        color=self.color)
                embed.set_footer(
                    text=
                    f"{self.name} Dashboard  requested by {ctx.message.author}",
                    icon_url=ctx.author.avatar_url)
                await ctx.send(embed=embed)
                StreamLogger.log(
                    f'{ctx.message.author} ran {self.name} Command successfully.'
                )

        except Exception as e:
            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}'
            )
            error_embed = discord.Embed(
                description=
                f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`",
                color=self.color)
            await ctx.send(embed=error_embed)
示例#11
0
 async def melee(self, ctx, *args):
     wep = ' '.join(args).strip()
     if wep == '':
         wep = "''"
     try:
         conn = await aiosqlite.connect('data/rotating/surviv.db')
         c = await conn.cursor()
         await c.execute('select * from melee')
         res = await c.fetchall()
         for t in res:
             if wep.lower() == t[0]:
                 break
         if t[0] != wep.lower():
             weps = [string.capwords(i) for i in list(zip(*res))[0]]
             embed = discord.Embed(
                 description=f'"**{wep}**" is not a valid melee weapon in **surviv.io**\n\n**Valid Weapons**: {", ".join(weps)}',
                 color=self.color,
             )
             embed.set_footer(text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url)
             await ctx.send(embed=embed)
         else:
             embed = discord.Embed(
                 title=f"{string.capwords(t[0])} Stats",
                 description=f"**Damage**: {t[2]} \n **Attack Radius**: {t[3]} \n **Equip Speed**: {t[1]} \n **Cooldown Time**: {t[4]} \n **Auto Attack**: {t[5]} \n",
                 color=self.color,
             )
             embed.set_footer(text=f"{self.name} Stats requested by {ctx.message.author}", icon_url=ctx.author.avatar_url)
             await ctx.send(embed=embed)
         StreamLogger.log(f'{ctx.message.author} ran {self.name} Command successfully.')
         await conn.close()
     except Exception as e:
         WarningLogger.log(f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {traceback.format_exc()}')
         try:
              await conn.close()
         except:
             pass
示例#12
0
    async def link(self, ctx):
        try:
            embed = discord.Embed(description="(1/5) **Starting Process** ...",
                                  color=self.color)
            status = await ctx.send(embed=embed)
            arsenic_session = await start_session(
                services.Geckodriver(),
                browsers.Firefox(),
            )
            embed = discord.Embed(description="(2/5) **Spawned Instance** ...",
                                  color=self.color)
            await status.edit(embed=embed)
            await arsenic_session.get(self.url)
            make_team_btn = await arsenic_session.get_element(
                '#btn-create-team')
            embed = discord.Embed(description="(3/5) **Locating target** ...",
                                  color=self.color)
            await status.edit(embed=embed)
            await make_team_btn.click()
            embed = discord.Embed(
                description="(4/5) **Retrieving Party Link** ...",
                color=self.color)
            await status.edit(embed=embed)
            await asyncio.sleep(
                2
            )  # add a small sleep delay for the party link to load up (a bit risky)
            party_url = await arsenic_session.get_url()
            embed = discord.Embed(
                description=
                f"**Party Link**: {party_url}\nLink Generator will leave in 7 seconds.",
                color=self.color)
            await status.edit(embed=embed)
            await asyncio.sleep(4)  # waits 7 seconds before leaving
            await status.edit(embed=discord.Embed(
                description=
                f"**Party Link**: {party_url}\nLink Generator is leaving soon ...",
                color=self.color))

            await asyncio.sleep(6)  # add more than 3 for extra time
            embed = discord.Embed(
                description=f"**Link Generator left.**\nOld Link: {party_url}",
                color=self.color)
            embed.set_footer(
                text=f"{self.name} requested by {ctx.message.author}",
                icon_url=ctx.author.avatar_url)
            await status.edit(embed=embed)
            StreamLogger.log(
                f'{ctx.message.author} ran {self.name} Command successfully.')
            await stop_session(arsenic_session)
        except Exception as e:
            try:
                await stop_session(arsenic_session)
            except:
                pass
            WarningLogger.log(
                f'{ctx.message.author} ran {self.name} Command unsuccessfully. Raised {e}'
            )
            error_embed = discord.Embed(
                description=
                f"**{self.name}** command did not run as expected.\nPlease log an issue with `{ctx.prefix}issue`",
                color=self.color)
            await ctx.send(embed=error_embed)