Ejemplo n.º 1
0
        async def func(self, ctx):
            text = util.strip_command(ctx)

            # Parse and process arguments from the command string
            args, text, err = Arguments.from_string(text,
                                                    spout.signature,
                                                    greedy=False)
            if err.terminal:
                await ctx.send(embed=err.embed(f'`{spout.name}`'))
                return
            args, err2 = await args.determine(ctx.message)
            text, err3 = await text.evaluate(ctx.message)
            err.extend(err2, 'arguments')
            err.extend(err3, 'input string')
            if err.terminal:
                await ctx.send(embed=err.embed(f'`{spout.name}`'))
                return

            try:
                # Apply the spout to what remains of the argstr
                await spout.function(self.bot, ctx.message, [text], **args)
            except Exception as e:
                err = ErrorLog()
                err(
                    f'With args {" ".join( f"`{p}`={args[p]}" for p in args )}:\n\t{e.__class__.__name__}: {e}',
                    True)
                await ctx.send(embed=err.embed(f'`{spout.name}`'))
Ejemplo n.º 2
0
 async def play(self, ctx):
     '''Set the currently played game.'''
     game = util.strip_command(ctx)
     if game == '':
         await self.bot.change_presence(activity=None)
     else:
         await self.bot.change_presence(activity=discord.Game(name=game))
Ejemplo n.º 3
0
        async def func(self, ctx):
            text = util.strip_command(ctx)

            # Parse and process arguments from the command string
            args, _, err = Arguments.from_string(text,
                                                 source.signature,
                                                 greedy=True)
            if err.terminal:
                await ctx.send(embed=err.embed(f'`{source.name}`'))
                return
            args, err2 = await args.determine(ctx.message)
            err.extend(err2, 'arguments')
            if err.terminal:
                await ctx.send(embed=err.embed(f'`{source.name}`'))
                return

            try:
                # Apply the source with the given arguments
                text = '\n'.join(await source(ctx.message, args))
                await ctx.send(text)
            except Exception as e:
                err = ErrorLog()
                err(
                    f'With args {" ".join( f"`{p}`={args[p]}" for p in args )}:\n\t{e.__class__.__name__}: {e}',
                    True)
                await ctx.send(embed=err.embed(f'`{source.name}`'))
Ejemplo n.º 4
0
 async def dril(self, ctx):
     '''Search for a dril (@wint) tweet matching a query (or a random one if no query is given).'''
     query = util.strip_command(ctx)
     if query == '':
         tweet = tweets.dril.random()
     else:
         tweet = choose(tweets.dril.search(query, 8))
     await ctx.send(tweet['href'])
Ejemplo n.º 5
0
 async def JERKCITY(self, CTX):
     '''SEARCH FOR A JERKCITY COMIC BASED ON TITLE OR DIALOGUE (OR NO QUERY FOR A RANDOM ONE)'''
     QUERY = util.strip_command(CTX)
     if QUERY == '':
         ISSUE = JERKCITY.GET_RANDOM()
     else:
         ISSUE = JERKCITY.SEARCH(QUERY)
     await CTX.send(ISSUE.URL())
Ejemplo n.º 6
0
 async def derek(self, ctx):
     '''Search for a derek (@eedrk) tweet matching a query (or a random one if no query is given).'''
     query = util.strip_command(ctx)
     if query == '':
         tweet = tweets.derek.random()
     else:
         tweet = choose(tweets.derek.search(query, 8))
     # TODO: output as faux tweet embed, since these are HISTORY
     await ctx.send(tweet['text'])
Ejemplo n.º 7
0
 async def futurama(self, ctx):
     '''Search for a Futurama screencap and caption matching a query (or a random one if no query is given).'''
     query = util.strip_command(ctx)
     if query == '':
         im, cap = futurama.random()
     else:
         im, cap = futurama.search(query)
     await ctx.send(im)
     await ctx.send(cap)
Ejemplo n.º 8
0
 async def simpsons(self, ctx):
     '''Search for a Simpsons screencap and caption matching a query (or a random one if no query is given).'''
     query = util.strip_command(ctx)
     if query == '':
         im, cap = simpsons.random()
     else:
         im, cap = simpsons.search(query)
     await ctx.send(im)
     await ctx.send(cap)
Ejemplo n.º 9
0
 async def kill(self, ctx):
     '''Kill someone'''
     subject = util.strip_command(ctx)
     if subject.lower() in ["yourself", "self", "myself", "rezbot"]:
         if permissions.has(ctx.author.id, permissions.owner):
             await ctx.send('killing self.')
             await self._die()
         else:
             await ctx.send('no')
     else:
         await ctx.send('killed {0}'.format(ctx.author.name if (
             subject == "me") else subject))
Ejemplo n.º 10
0
 async def youtube(self, ctx):
     '''Get a random caption from a youtube video from a list of saved youtube videos'''
     query = util.strip_command(ctx)
     if query.strip() in ['', 'help']:
         await ctx.send(info_string)
     elif query.strip().lower() == 'random':
         cap, url = youtubeCaps.get_random()
         await ctx.send(url)
         await ctx.send(cap)
     else:
         try:
             cap, url = youtubeCaps.search(query)
             await ctx.send(url)
             await ctx.send(cap)
         except IndexError:
             await ctx.send(
                 'no results found for search "{}".'.format(query))
Ejemplo n.º 11
0
 async def echo(self, ctx):
     '''Repeat your message in a code block (for emoji related purposes).'''
     await ctx.send('`{}`'.format(util.strip_command(ctx)))
Ejemplo n.º 12
0
 async def drump(self, ctx):
     query = util.strip_command(ctx)
     if query == '': tweet = tweets.dril.random()
     else: tweet = choose(tweets.dril.search(query, 8))
     embed = BotCommands.trump_embed(tweet['text'])
     await ctx.send(embed=embed)
Ejemplo n.º 13
0
 async def func(self, ctx):
     text = util.strip_command(ctx)
     proc = SourceProcessor(ctx.message)
     text = await proc.evaluate_composite_source(text)
     await spout.as_command(self.bot, ctx.message, text)
Ejemplo n.º 14
0
 async def func(self, ctx):
     text = util.strip_command(ctx)
     proc = SourceProcessor(ctx.message)
     text = await proc.evaluate_composite_source(text)
     text = '\n'.join(await source(ctx.message, text))
     await ctx.send(text)