示例#1
0
 async def sue(self, context):
     """Sue somebody.
     
     Modifiers:
     all|list|stats|records : Display stats from previous cases."""
     bot = self.bot
     m = context.message
     
     # Modifiers
     q = basics.contentq(m.content,split=False)
     q, all = basics.subcommands(context, q,["all|list|stats|records"])
     if all != None:
         lines = [["User"] + list(Sue.getstats(bot, m.author).keys())]
         pages = []
         something = False
         n = 0
         #for a in range(8):
         if m.guild.id in bot.suepoints.keys():
             for k,i in bot.suepoints[m.guild.id].items():
                 u = m.guild.get_member(k)
                 if u == None:
                     continue
                 l = []
                 for k,i in Sue.getstats(bot, u).items():
                     l.append(str(i))
                 lines.append([basics.truename(bot, u)] + l)
                 something = True
         if not something:
             await talking.reply(context,"There aren't any stats on this server.")
         else:
             align = ["l"]
             l = aesthetic.chart(lines,linelimit=20,align=["l"] + (["r"] * (len(lines[0])-1)))
             for n,x in enumerate(l):
                 pages.append(f"__**Suing Stats**__ (Page {n+1}/{len(l)})\n{x}")
             rm = PageMessage(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, userids = [m.author.id], pages=pages, context=context)
         return
     
     # Make sure there's a mention
     if len(m.mentions) == 0:
         await talking.reply(context,"You need to specify who you want to sue!")
         return
     
     # Initialize stuff
     if m.guild.id not in bot.suepoints.keys():
         bot.suepoints[m.guild.id] = {}
     for uid in [m.author.id,m.mentions[0].id]:
         if uid not in bot.suepoints[m.guild.id].keys():
             bot.suepoints[m.guild.id][uid] = {}
             for a in ["suer","suee"]:
                 for b in ["win","lose"]:
                     bot.suepoints[m.guild.id][uid][a + b] = 0
     basics.save(self.bot, "suepoints")
                     
     reason = basics.mentionlesscontent(basics.contentq(m.content,split=False))
     if reason == "":
         reason = "(No reason.)"
     
     suemsg = await talking.say(context,"­",nowebhook=True)
     rm = Sue(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, suer=m.author, suee=m.mentions[0], reason=reason, context=context)
示例#2
0
    async def pinthat(self, context):
        """Pins a message containing what you wrote."""
        q = basics.contentq(context.message.content, split=False)
        bot = self.bot
        m = context.message

        bot.dontpinthat.append(context.message.id)

        pinmsg = await utility.referencemessage(context)
        if pinmsg == None:
            return

        if pinmsg.id in bot.dontpinthat:
            msg = await talking.reply(context, "EAT A DICK")
            bot.dontpinthat.append(msg.id)
        else:
            try:
                await pinmsg.pin()
            except:
                await talking.reply(
                    context,
                    "Unable to pin. Maybe there's no more room for pins?")
            else:
                await AchievementBrowser.ach_check(
                    bot, pinmsg.author, m.channel, "pin",
                    [pinmsg, m])  # Getting your message pinned
                await AchievementBrowser.ach_check(
                    bot, m.author, pinmsg.channel, "pinner",
                    [pinmsg, m])  # Pinning someone else's message
示例#3
0
    async def petition(self, context):
        """Start a petition with the given title.

        People can "sign" the petition by hitting a pen reaction, adding their name to a list.

        Modifiers:
        nounsign|noundo : Disables unsigning.
        EMOJI : Replaces the pen with that emoji."""
        bot = self.bot
        q = basics.contentq(context.message.content, split=False)
        q, undo, match = basics.subcommands(context, q,
                                            ["nounsign|noundo", r".*?"])

        if match != None:
            emoji = utility.get_emoji(self.bot, match.group(1))
            if emoji == None:
                await talking.reply(
                    context, "{} isn't a valid emoji!".format(match.group(1)))
                return
        else:
            emoji = utility.get_emoji(self.bot,
                                      "<a:rolling:393641477068029953>")

        Petition(bot,
                 validfor=datetime.timedelta(minutes=60),
                 messagecount=1,
                 emoji=emoji,
                 q=q,
                 lit=await ccc.lit(context.message, binary=True),
                 context=context)
示例#4
0
 async def eighthippo(self, context):
     """Answers with a random hippo from our vast catalog."""
     q = basics.contentq(context.message.content, split=False)
     await talking.reply(
         context,
         'asked {}, I respond: {}'.format(basics.spitback(q),
                                          ccc.eighthippo(self.bot)))
示例#5
0
    async def input(self, context):
        """Inputs to certain commands.

        It'll be mentioned whenever you can use it. With nothing to input to, this command doesn't do anything."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        try:
            await m.delete()
        except:
            pass

        # Specific
        q, id = basics.subcommands(context, q, ["[0-9]+"])
        if id != None:
            id = int(id.group(1))

        # Default
        if id == None:
            bot.inputmenus_channelids.setdefault(m.channel.id, [])
            if len(bot.inputmenus_channelids) != 0:
                id = bot.inputmenus_channelids[m.channel.id][-1]

        # Go
        if id != None:
            m.content = q
            await bot.inputmenus_idim[int(id)].inputmessage(m)
示例#6
0
 async def eightmoji(self, context):
     """Picks one of our god-awful custom emojis."""
     q = basics.contentq(context.message.content, split=False)
     await talking.reply(
         context,
         'asked {}, I respond: {}'.format(basics.spitback(q),
                                          ccc.eightcustomemoji(self.bot)))
示例#7
0
    async def pointoutanickname(self, context):
        """Points out the nickname that a referenced message was posted under.

        Posts in all caps by default. Both modifiers remove this.

        Modifiers:
        quote|q : Changes the format to one additionally pointing out the content of the referenced message.
        ANYTHING : Changes the format to whatever was entered. The nickname is inserted at -s. If no -s are included, one is added to the end of your input.

        Rigged Aliases:
        quote : Uses the quote formatting.

        Meta:
        Use > as a modifier in order to use the default format without caps. It seemed more intuitive to have you trigger the ANYTHING this way than to have a seprate modifier."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)
        q, quote, custom = basics.subcommands(context,
                                              q, ["quote|q", ".*?"],
                                              riggedaliases=[{
                                                  "regex": r"quote",
                                                  "slot": 0,
                                                  "value": "quote"
                                              }])

        msg = await utility.referencemessage(context, s=q)
        if msg == None:
            return

        upper = False
        if quote is not None:
            post = f'"{msg.content}"\- -'
        elif custom is not None:
            post = custom.group(1)
            if re.search(r"(?<!\\)-", post) is None:
                while post.endswith("\\"):
                    post = post[:-1]
                post += "-"
        else:
            upper = True
            post = ">-"

        try:
            if upper:
                await talking.say(
                    context,
                    re.sub(r"(?<!\\)-", bot.thennicks[msg.channel.id][msg.id],
                           post).upper())
            else:
                await talking.say(
                    context,
                    re.sub(r"(?<!\\)-", bot.thennicks[msg.channel.id][msg.id],
                           post))
        except:
            await talking.reply(
                context,
                "I don't have a nickname associated with that message.")
        await AchievementBrowser.ach_check(bot, msg.author, m.channel, "polen",
                                           [])
示例#8
0
 async def eightuser(self, context):
     """Answers with a random medium+ priority member."""
     bot = self.bot
     EightUser(bot,
               validfor=datetime.timedelta(minutes=5),
               messagecount=1,
               q=basics.contentq(context.message.content, split=False),
               context=context)
示例#9
0
    async def eightanimal(self, context):
        """Answers with a random animal.

        Credit to https://a-z-animals.com/animals/, because I freaking stole their list(and took out some of the more obscure or redundant animals)"""
        q = basics.contentq(context.message.content, split=False)
        await talking.reply(
            context, 'asked {}, I respond: {}!'.format(basics.spitback(q),
                                                       ccc.eightanimal()))
示例#10
0
    async def dice(self, context):
        """Rolls dice.

        Defaults to two d6s.

        Modifiers:
        equaloutcome|eo : Every dice combination will only happen once before all possibilities are exhausted. """
        bot = self.bot
        Dice(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, q=basics.contentq(context.message.content,split=False),
                 context=context)
示例#11
0
    async def echo(self, context):
        """Does an echo effect on provided text."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        if not q:
            await talking.reply(context,"I need an input to work with!")
        else:
            await talking.say(context,ccc.echo(q))
示例#12
0
 async def eighttime(self, context):
     """Ansers with a random amount of time.
     
     Based on Micman's old ~rtime."""
     q = basics.contentq(context.message.content, split=False)
     numb = random.randint(1, 100)
     await talking.reply(
         context,
         'asked {}, I respond: {} {}!'.format(basics.spitback(q), numb,
                                              ccc.eighttime(numb != 1)))
示例#13
0
 async def eightxavier(self, context):
     """Answers with a random XRA ks mateline."""
     q = basics.contentq(context.message.content, split=False)
     await talking.reply(
         context,
         'asked {}, I respond: {}'.format(basics.spitback(q),
                                          ccc.eightxavier()),
         specificwebhook=
         ("Xavier",
          "https://cdn.discordapp.com/attachments/320713790771691530/536735846439845888/1502427950625.png"
          ))
示例#14
0
    async def eightlinefromsonic06(self, context):
        """Answers with a random line from Sonic 06.

        Credit to SONIC FANS ON SONIC WIKI"""
        bot = self.bot
        EightLineFromSonic06(bot,
                             validfor=datetime.timedelta(minutes=5),
                             messagecount=1,
                             q=basics.contentq(context.message.content,
                                               split=False),
                             context=context)
示例#15
0
 async def eightaudies(self, context):
     """Answers with a random XRA audie."""
     bot = self.bot
     m = context.message
     q = basics.contentq(m.content, split=False)
     audie = ccc.eightaudie()
     with open(f"audio/audies/{audie}.mp3", "rb") as f:
         await talking.reply(context,
                             'asked {}, I respond: #{}!'.format(
                                 basics.spitback(q), audie.title()),
                             file=f)
示例#16
0
    async def helpnew(self, context):
        bot = self.bot
        q = basics.contentq(context.message.content, split=False)
        #await talking.say(context,embed=await basics.help(context,q,False))

        Help(bot,
             validfor=datetime.timedelta(minutes=10),
             show=q,
             context=context)

        if context.message.author.id == bot.rnl.id and "GO" in context.message.content:
            await basics.updateglobalhelp(context)
示例#17
0
    async def emojibutton(self, context):
        """Generates replacement CSS for use in BD.

        Generates CSS that you can use to replace the default random emojis that you click on to open the emoji menu.
        List up to 55 image references."""
        q = basics.contentq(context.message.content)
        imgs = []
        base = 44

        # Valid length?
        if len(q) == 0:
            await talking.reply(
                context, "You need to make at least one image reference.")
            return
        if len(q) > 55:
            await talking.reply(
                context,
                f"You can't make more than 55 image references. You've made **{len(q)}**, currently."
            )
            return

        # Get images
        for y in q:
            imgfound = await utility.referenceimage(context, s=y)
            if imgfound != None:
                imgfound.thumbnail((base, base))
                imgfound.convert("RGBA")
                imgs.append(imgfound)
            else:
                return

        # Actual generation
        img = Image.new('RGBA', (base * 11, base * 5), (255, 255, 255, 0))
        n = 0
        print(imgs)
        for y in range(5):
            for x in range(11):
                xdif = base - imgs[n].width
                ydif = base - imgs[n].height
                img.paste(imgs[n],
                          (int((x * base) + xdif), int((y * base) + ydif),
                           int(x * base + xdif) + imgs[n].width,
                           int(y * base + ydif) + imgs[n].height))
                n += 1
                n %= len(imgs)

        print(img)
        urlmsg = await talking.reply(context, PIL=img)
        await talking.say(
            context, f"""```css
.sprite-2iCowe {{
    background-image: url({urlmsg.attachments[0].url});
}}```""")
示例#18
0
 async def masks(self, context):
     """Go away"""
     m = context.message
     q = basics.contentq(m.content, split=False)
     d={
         116718249567059974: ("https://cdn.discordapp.com/attachments/315666280185069568/703767537216651274/unknown.png", "Barely Allan"),
         134826546694193153: ("https://cdn.discordapp.com/attachments/204434027774476288/703769697895841922/im-173860.png", "Hai Chang"),
         112767329347104768: ("https://cdn.discordapp.com/attachments/315666280185069568/703777924519690320/unknown.png", "Teenage Edgy Blond Granny"),
         112814914019614720: (" https://cdn.discordapp.com/attachments/141764382513168384/703780828404121651/unknown.png", "Ophiuchus")
     }
     if m.author.id in d:
         await m.delete()
         await talking.say(context, q, specificwebhook=(d[m.author.id][1], d[m.author.id][0]))
示例#19
0
    async def reactionchart(self, context):
        """Displays who reacted with what to a message."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        mfrom = await utility.referencemessage(context)
        if mfrom == None:
            return

        ReactionChart(bot,
                      validfor=datetime.timedelta(minutes=5),
                      foreignmessages=[mfrom],
                      context=context)
示例#20
0
 async def reload(self, context):
     module = basics.contentq(context.message.content,split=False)
     try:
         try:
             self.bot.unload_extension(module)
         except:
             pass
         await asyncio.sleep(1)
         self.bot.load_extension(module)
     except Exception as e:
         await talking.say(context,'Ouch.\n{}: {}'.format(type(e).__name__, e))
     else:
         await talking.say(context,'Okay, {} reloaded.'.format(module))
         print("{0} reloaded.".format(module))
示例#21
0
    async def choose(self, context):
        """Chooses randomly from a set.

        Choices are separated by semicolons.

        Modifiers:
        NUMBER : Changes the weight of the entry. Default weight is 1.
        + : The entry will always be picked.
        - : The entry will never be picked.
        t : The entry will instead set a title.
        These are all applied to an individual entries, and are mutually exclusive."""
        bot = self.bot
        Choose(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, q=basics.contentq(context.message.content,split=False),
                 context=context)
示例#22
0
async def referenceimage(context, displayerror=True, s=None, returnurl=False):
    from modules.talking import reply
    from modules.basics import contentq
    bot = context.bot
    m = context.message
    defaults = False
    if s == None:
        defaults = True
        s = contentq(m.content, split=False)

    i = None

    if not i:
        i = re.search(r"\bhttps?:\/\/[^ ]*\b", s)
        if i:
            i = i.group(0)

    if not i:
        u = re.search(r"<@!?(\d+)>", s)
        print(1)
        if u:
            print(2)
            u = bot.get_user(int(u.group(1)))
            if u:
                print(3)
                i = str(u.avatar_url)

    if not i:
        if context.message.attachments:
            i = context.message.attachments[0].url

    if not i:
        i = get_emoji_url(bot, s)

    if i:
        if returnurl:
            return i
        else:
            return imagefromurl(i)

    # F**k
    if displayerror:
        if defaults:
            await reply(context,
                        "I couldn't figure out what you were referring to.")
        else:
            await reply(context,
                        f"I couldn't figure out what `{s}` is referring to.")
    return None
示例#23
0
 async def eightcolor(self, context):
     """Answers with a random color."""
     q = basics.contentq(context.message.content, split=False)
     m = context.message
     color = ccc.eightcolor()
     image = Image.new('RGBA', (100, 100), (0, 0, 0, 0))
     draw = ImageDraw.Draw(image, mode="RGBA")
     draw.ellipse((0, 0, 99, 99), fill="#000")
     border = 8
     draw.ellipse((border, border, 99 - border, 99 - border), fill=color)
     image = image.resize((25, 25), Image.ANTIALIAS)
     await talking.reply(context,
                         'asked {}, I respond: {}!'.format(
                             basics.spitback(q), ccc.eightcolor()),
                         PIL=image)
示例#24
0
    async def hugemoji(self, context):
        """Shows full size emojis.

        Lists emoji URLs based on what you give it, separated by spaces."""
        q = basics.contentq(context.message.content)
        emoji = []
        for y in q:
            emojifound = utility.get_emoji_url(self.bot, y)
            if emojifound != None:
                emoji.append(emojifound)
        if emoji == []:
            await talking.reply(
                context, "I wasn't able to match any emojis in your message.")
        else:
            await talking.reply(context, "\n" + "\n".join(emoji))
示例#25
0
    async def eightball(self, context):
        """Randomly answers yes or no.

        Modifiers:
        yes|yeah|ya|yeh|ye|yup|y|no|nah|nope|n|NUMBER(\||/|;|:)NUMBER : Forces all yeses, all nos, or a yes:no ratio.
        
        Rigged Aliases:
        8yes, 8yeah, 8ya, 8yeh, 8ye, 8yup, 8y, yes, yeah, ya, yeh, ye, yup, y : Forces all yeses.
        8no, 8nah, 8nope, 8n, no, nah, nope, n : Forces all nos."""
        bot = self.bot
        EightBall(bot,
                  validfor=datetime.timedelta(minutes=5),
                  messagecount=1,
                  q=basics.contentq(context.message.content, split=False),
                  context=context)
示例#26
0
    async def flockofinvites(self, context):
        """Gets invites based on your input.

        Gets invites to all servers in which you and the bot have the ability to get invites, and your input is somewhere in the server name.
        Lists off all the matched servers before posting them so that you don't accidentally invite to somewhere you wanted private.
        The invites last ten minutes.

        Modifiers:
        regex : Searches with regex instead."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)
        q, regex = basics.subcommands(context, q, ["regex"])

        if not regex:
            q = re.escape(q)

        try:
            q = re.compile(q)
        except:
            await talking.reply(
                context,
                "That's not valid regex, ya dingus. This might help: <https://regexr.com/>"
            )
        else:
            sl = []
            for s in bot.guilds:
                for u in s.members:
                    if u.id == context.author.id:
                        break
                else:
                    continue

                if (u.guild_permissions.administrator or u.guild_permissions.create_instant_invite) and (
                    s.me.guild_permissions.administrator or s.me.guild_permissions.create_instant_invite) and \
                    re.search(q, s.name):
                    sl.append(s)

            sl.sort(key=lambda x: x.name)
            # sls = []
            # for s in sl:
            #     sls.append(s.name)
            FlockOfInvites(bot,
                           validfor=datetime.timedelta(minutes=5),
                           messagecount=1,
                           userids=[m.author.id],
                           sl=sl,
                           context=context)
示例#27
0
    async def audies(self, context):
        """Uploads a chosen audie.
        
        Modifiers:
        all|list : Display all audies."""
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=True)
        audies = ccc.allaudies()
        # print(len(audies))

        if len(q) == 0:
            await talking.reply(
                context,
                f"Please specify an audie! Use `s!audie [list]` for a list.")
            return
        q, all = basics.subcommands(context, q[0], ["all|list"])
        q = re.sub(r"[^A-Za-z0-9]", "", q)

        if all != None:
            pages = []
            n = 0
            #for a in range(8):
            page = []
            for b in range(19 * 8):
                page.append([])
                for c in range(4):
                    page[-1].append(audies[n])
                    n += 1
            for n, x in enumerate(
                    aesthetic.chart(page, header=False, linelimit=19)):
                pages.append(f"__**Audie List**__ (Page {n+1}/8)\n{x}")
            rm = PageMessage(bot,
                             validfor=datetime.timedelta(minutes=5),
                             messagecount=1,
                             userids=[m.author.id],
                             pages=pages,
                             context=context)
            #utility.add_reaction_menu(bot,rm)
            #bot.ongoingreactionmenus.append(new)
            #new.test()
            #basics.save(bot,"ongoingreactionmenus")
        elif q.lower() not in audies:
            await talking.reply(
                context, f"There's no audie called {basics.spitback(q)}.")
        else:
            with open(f"audio/audies/{q}.mp3", "rb") as f:
                await talking.say(context, f"#{q.title()}", file=f)
示例#28
0
    async def hey(self, context):
        """\*touches your shoulder* Hey.

        Says "Hey" five times using an imitation webhook of five random people on the server. Don't leave it blank and instead of "Hey" the webhooks will say whatever you provided."""
        m = context.message
        bot = self.bot

        l = list(m.guild.members)
        random.shuffle(l)

        q = basics.contentq(m.content,split=False)
        if not q:
            q = "Hey"

        for u in l[:5]:
            await talking.say(context,q,specificwebhook=(u.display_name, u.avatar_url))
示例#29
0
    async def reactionreactions(self, context):
        """Allows you to react to reactions. Sorta.

        Use a message reference to pick a message, then """
        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        mfrom = await utility.referencemessage(context)
        if mfrom == None:
            return

        ReactionReactions(bot,
                          validfor=datetime.timedelta(minutes=10),
                          foreignmessages=[mfrom],
                          context=context)
示例#30
0
    async def imitate(self, context):
        """Lets you post webhook messages.

        Provide an Image Reference for the avatar, nickname, and message body, in that order, separated by semicolons."""
        m = context.message
        q = basics.contentq(m.content, split=False)

        q = q.split(";", 2)
        if len(q) < 3:
            await talking.reply(context,
                                "I need an Image Reference for the avatar, nickname, and message body, in that order, separated by semicolons.")
        else:
            url = await utility.referenceimage(context, s=q[0], returnurl=True)
            if not url:
                return
            await talking.say(context, q[2], specificwebhook=(q[1], url))