Ejemplo n.º 1
0
async def stats(cmd, message, args):
    out = sigma_stats(cmd.bot)

    out_txt = codeblock('\n'.join(out), syntax='haskell')

    stats_msg = await cmd.bot.send_message(message.channel, out_txt)
    await asyncio.sleep(60)
    await cmd.bot.delete_message(message)
    await cmd.bot.delete_message(stats_msg)
Ejemplo n.º 2
0
async def wiki(cmd, message, args):
    q = ' '.join(args).lower()

    result = wikipedia.summary(q)

    if result is not None:
        if len(result) >= 650:
            result = result[:650] + ' ...'

        out_text = 'Your search results for {:s}:\n{:s}'.format(
            code(q), codeblock(result))
    else:
        out_text = 'Nothing could be found...'

    await cmd.bot.send_message(message.channel, out_text)
Ejemplo n.º 3
0
async def pmredirect(ev, message, args):
    cid = ev.bot.user.id
    author = message.author

    if not message.server:
        if author.id == cid or author.id in permitted_id:
            return
        else:
            ev.log.info('User {:s} [{:s}] sent a private message.'.format(
                author.name, author.id))

            # very expensive operation
            for user in ev.bot.get_all_members():
                if user.id == permitted_id[0]:
                    private_msg_to_owner = await ev.bot.start_private_message(
                        user=user)
                    msg = '**{:s}** (ID: {:s}):\n{:s}\n'
                    await ev.bot.send_message(
                        private_msg_to_owner,
                        msg.format(author.name, author.id,
                                   codeblock(message.content)))
                    break
Ejemplo n.º 4
0
 def help(self):
     usage = self.usage
     return 'Usage: {:s}\n{:s}'.format(
             code(usage), codeblock(self.desc))
Ejemplo n.º 5
0
 def help(self):
     usage = self.usage.format(pfx=self.prefix, cmd=self.name)
     return 'Usage: {:s}\n{:s}'.format(
         code(usage), codeblock(self.desc))