예제 #1
0
 async def start(self, ctx):
     """Starts the server."""
     em = discord.Embed()
     server = 1
     if ctx.channel.id == 793632795598913546:
         server = 2
     try:
         attempt = hit_endpoint('start', server)
     except Exception as e:
         em.title = 'Command error'
         em.colour = 0xFF0000
         em.description = 'Something went wrong'
         print(f'Error while starting freedom-0{server}: {e}')
         await ctx.send(embed=em)
     else:
         if 'error' in attempt.lower():
             em.title = 'Command error'
             em.colour = 0xFF0000
             em.description = f'freedom-0{server}: {attempt}'
             await ctx.send(embed=em)
         else:
             em.title = 'Success'
             em.colour = 0x00FF00
             em.description = f'freedom-0{server}: {attempt}'
             await ctx.send(embed=em)
예제 #2
0
 async def stop(self, ctx):
     """Stops the server."""
     em = discord.Embed()
     server = 1
     if ctx.channel.id == 793632795598913546:
         server = 2
     try:
         tempem = discord.Embed()
         tempem.title = "Command sending"
         tempem.description = "Please stand by this could take a minute"
         tempem.colour = 0xFFFF00
         tempm = await ctx.send(embed=tempem)
         attempt = hit_endpoint('stop', server, timeout=30)
     except Exception as e:
         await tempm.delete()
         em.title = 'Command error'
         em.colour = 0xFF0000
         em.description = 'Something went wrong'
         print(f'Error while stopping freedom-0{server}: {e}')
         await ctx.send(embed=em)
     else:
         await tempm.delete()
         if 'error' in attempt.lower():
             em.title = 'Command error'
             em.colour = 0xFF0000
             em.description = f'freedom-0{server}: {attempt}'
             await ctx.send(embed=em)
         else:
             em.title = 'Success'
             em.colour = 0x00FF00
             em.description = f'freedom-0{server}: {attempt}'
             await ctx.send(embed=em)
예제 #3
0
 async def uptime(self, ctx):
     """Returns the uptime of the VPS."""
     em = discord.Embed()
     em.title = 'VPS Uptime Information'
     try:
         attempt = hit_endpoint('uptime')
     except Exception as e:
         em.title = 'Command error'
         em.colour = 0xFF0000
         print(f'Error while getting VPS Uptime: {e}')
         em.description = f'Something went wrong'
     else:
         em.description = attempt
     await ctx.send(embed=em)
예제 #4
0
async def on_message(message):
    if isinstance(message.channel, discord.channel.DMChannel):
        print(f'{message.author} DM: {message.content}')
        return
    elif message.guild and message.author is message.guild.me and message.channel.id == bot.reports_channel_id:
        await message.add_reaction(clipboard)
    elif message.type == discord.MessageType.new_member:
        if re.search('discord\.gg\/[a-zA-z0-9\-]{1,16}', message.author.name.lower()) or re.search(
                'discordapp\.com\/invite\/[a-z0-9]+/ig', message.author.name.lower()):
            await message.author.ban(reason="Name is an invite link.")
            await message.delete()
    bypass_roles = [bot.discord_admin, bot.discord_mod]
    bypass = False
    if message.author != bot.user:
        for role in message.author.roles:
            if role.id in bypass_roles:
                bypass = True

        asked_for_ip = re.search("(((give *(me)?)|(wh?at'? *i?s?))( *the)?( *server)? *ip)|(ip\?)",
                                 message.content.lower())
        if asked_for_ip is not None:
            print("THE IP IS GAY")
            em = discord.Embed(
                title='Server IP',
                colour=0xA84300,
                description='play.totalfreedom.me'
            )
            await message.channel.send(embed=em)

        if bot.auto_restart:
            server_chats = [bot.server_chat, bot.server_chat_2]
            for server in range(1, 3):
                if message.channel.id == server_chats[server]:
                    if not get_server_status(server):
                        em = discord.Embed()
                        em.title = 'Automatic restart'
                        attempt = hit_endpoint('start', server)
                        if attempt == "ERROR - There is an instance of the server already running. Make sure it is " \
                                      "killed first and try again":
                            hit_endpoint('stop', server)
                            hit_endpoint('stop', server)
                            hit_endpoint('start', server)
                            em.colour = 0x00FF00
                            em.description = 'Server has been automatically restarted.'
                        else:
                            em.colour = 0x00FF00
                            em.description = 'Server has been automatically started.'
                        await message.channel.send(embed=em)

    if 'Server has started' in message.content:  # Telnet reconnect script
        try:
            bot.telnet_object.connect()
        except Exception as err:
            print(f'Failed to reconnect telnet: {err}')
            time.sleep(5)
            try:
                bot.telnet_object.connect()
            except Exception as fuckup:
                print(
                    f'Second attempt failed to reconnect telnet: {fuckup}')
        try:
            bot.telnet_object_2.connect()
        except Exception as err:
            print(f'Failed to reconnect telnet 2: {err}')
            time.sleep(5)
            try:
                bot.telnet_object_2.connect()
            except Exception as fuckup:
                print(
                    f'Second attempt failed to reconnect telnet 2: {fuckup}')
    if not bypass:
        if re.search('discord\.gg\/[a-zA-z0-9\-]{1,16}', message.content) or re.search(
                'discordapp\.com\/invite\/[a-z0-9]+/ig', message.content):
            await message.delete()
            await message.channel.send(f"{message.author.mention} do not post invite links to other discord servers.")

    await bot.process_commands(message)