示例#1
0
文件: base.py 项目: ViRb3/ovisbot
        async def status(ctx):
            """
            Shows any ongoing, scheduled, finished CTFs in the server.
            """
            status_response = ""
            ctfs = sorted([c for c in ctx.guild.categories],
                          key=lambda x: x.created_at)
            for ctf in ctfs:
                try:
                    ctf_doc = CTF.objects.get({"name": ctf.name})
                except CTF.DoesNotExist:
                    continue
                    # await ctx.channel.send(f"{ctf.name} was not in the DB")
                ctfrole = discord.utils.get(ctx.guild.roles,
                                            name="Team-" + ctf.name)
                status_response += ctf_doc.status(len(ctfrole.members))

            if len(status_response) == 0:
                status_response = "CTF list is empty!"
                await ctx.channel.send(status_response)
                return

            for chunk in chunkify(status_response, 1900):
                emb = discord.Embed(description=chunk, colour=4387968)
                await ctx.channel.send(embed=emb)
示例#2
0
 async def status(self, ctx):
     """
     Returns a list of ongoing challenges in the ctf
     """
     channel_name = str(ctx.channel.category)
     ctf = CTF.objects.get({"name": channel_name})
     summary_chunks = chunkify(ctf.challenge_summary(), 1700)
     for chunk in summary_chunks:
         emb = discord.Embed(description=chunk, colour=4387968)
         await ctx.channel.send(embed=emb)
示例#3
0
    async def rotn(self, ctx, shift, *params):
        '''
        Returns the ROT-n encoding of a message.
        '''
        msg = ' '.join(params)
        out = 'Original message:\n' + msg
        if shift == "*":
            for s in range(1, 14):
                out += f'\n=[ ROT({s}) ]=\n'
                out += rotn_helper(s, msg)
        else:
            shift = int(shift)
            shifted_str = rotn_helper(shift, msg)

            out += f'\n=[ ROT({shift}) ]=\n'
            out += 'Encoded message:\n' + shifted_str

        for chunk in chunkify(out, 1700):
            await ctx.send("".join(["```", chunk, "```"]))