示例#1
0
    def __init__(self, bot, **kwargs):
        Rerollable.__init__(self, bot, **kwargs)
        # Setup
        options = []
        totalrate = 0
        title = None
        for x in self.q.split(";"):
            rate = 1
            forced = False
            x, sub = basics.subcommands(self.context, x, [r"\d+|\+|-|t"])

            if sub != None:
                sub = sub.group(1)
                if sub == "t":
                    title = x
                    continue
                elif sub == "-":
                    rate = 0
                elif sub == "+":
                    forced = True
                else:
                    rate = int(sub)

            options.append({"s": x, "chance": rate, "forced": forced})
            totalrate += rate
        defaults = {"options": options, "totalrate": totalrate, "title": title}
        DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
示例#2
0
 def __init__(self, bot, **kwargs):
     Rerollable.__init__(self, bot, **kwargs)
     # Setup
     self.q, eo = basics.subcommands(self.context, self.q,
                                     [r"equaloutcome|eo"])
     defaults = {"die": [6], "outcomes": [], "eo": eo}
     DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
示例#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 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)
示例#5
0
    def __init__(self, bot, **kwargs):
        Rerollable.__init__(self, bot, **kwargs)
        self.q, ratio = basics.subcommands(
            self.context,
            self.q,
            [r"yes|yeah|ya|yeh|ye|yup|y|no|nah|nope|n|(\d)(?:\||\/|;|:)(\d)"],
            riggedaliases=[{
                "regex": r"8?(yes|yeah|ya|yeh|ye|yup|y)",
                "slot": 0,
                "value": "y"
            }, {
                "regex": r"8?(no|nah|nope|n)",
                "slot": 0,
                "value": "n"
            }])

        if ratio:
            if ratio.group(1).startswith("y"):
                y = 1
                n = 0
            elif ratio.group(1).startswith("n"):
                y = 0
                n = 1
            else:
                y = int(ratio.group(2))
                n = int(ratio.group(3))
        else:
            y = 1
            n = 1
        defaults = {"q": self.q, "yesratio": y, "noratio": n}
        kwargs["q"] = self.q
        DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
示例#6
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",
                                           [])
示例#7
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)
示例#8
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)
示例#9
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)
示例#10
0
    async def achievements(self, context):
        """Opens an achievement display menu.

        Mention someone to see their achievements instead.

        Modifiers:
        top|list|high|rank|ranks : Show a scoreboard. """
        bot = self.bot
        m = context.message
        q = basics.contentq(context.message.content, split=False)

        q, top, transfer = basics.subcommands(
            context, q, ["top|list|high|rank|ranks", "transfer"])

        if top != None:
            achievements = AchievementBrowser.getachievements()
            embed = discord.Embed(title="Achievement Scoreboard", type="rich")
            cap = 0
            for x in achievements:
                if x["special"] == False:
                    cap += 1
            raredict = {}
            highdict = {}
            for s in [m.guild.id, "global"]:
                for k in self.bot.ach_tracking[s].keys():
                    u = context.message.guild.get_member(k)
                    if u != None:
                        score = 0
                        icons = ""
                        for n, x in enumerate(achievements):
                            if x["icon"] not in raredict.keys():
                                raredict[x["icon"]] = 0
                            if n in self.bot.ach_tracking[s][k].keys(
                            ) and x["special"] == False:
                                if False not in self.bot.ach_tracking[s][k][n]:
                                    score += 1
                                    icons += x["icon"]
                                    raredict[x["icon"]] += 1
                        highdict.setdefault(u.id, [u, 0, ""])
                        highdict[u.id][1] += score
                        highdict[u.id][2] += icons
            high = list(highdict.values())

            rarelist = []
            for k in raredict.keys():
                rarelist.append([k, raredict[k]])
            rarelist = sorted(rarelist, key=lambda x: x[1])
            # await mf.say(context,str(rarelist))

            high = sorted(high, key=lambda x: x[1])[::-1]
            high = high
            # print(high)
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")

            lol = [[
                "User",
                aesthetic.hoveremoji("Bar"), "Progress", "%", "Rarest"
            ]]
            for n, x in enumerate(high):
                lol.append([])
                u = x[0]
                limit = 16
                if len(basics.truename(bot, u)) > limit:
                    lol[-1].append(basics.truename(bot, u)[:limit - 1] + "…")
                else:
                    lol[-1].append(basics.truename(bot, u))

                prog = x[1] / cap
                lol[-1].append(ccc.bar(bot, 1, prog, "mini"))
                lol[-1].append(f"{x[1]}/{cap}")
                lol[-1].append(f"{math.floor(prog * 100)}%")

                rares = ""
                addedrares = 0
                for y in rarelist:
                    if y[0] in x[2]:
                        rares += y[0]
                        addedrares += 1
                    if addedrares == 6:
                        break
                lol[-1].append(rares)

            s = "You don't have any achievements."
            for x in range(0, len(high)):
                if high[x][0] == context.message.author and high[x][1] != 0:
                    s = "You're ranked #{}.".format(x + 1)

            SortableChart(bot,
                          validfor=datetime.timedelta(minutes=5),
                          context=context,
                          lol=lol,
                          align=["l", "l", "unwrap", "l", "l", "unwrap"],
                          addnumbers=True)

            return
        elif transfer != None and context.message.author == bot.rnl:
            tracking = pickle.load((open(
                'C:\\Users\\Zachary\\Desktop\\kkk\\Non-GML\\ButtBot\\epicord-bot-master\\saveach_tracking.txt',
                'rb')))

            count = pickle.load((open(
                'C:\\Users\\Zachary\\Desktop\\kkk\\Non-GML\\ButtBot\\epicord-bot-master\\saveach_tracking_count.txt',
                'rb')))

            achievements = AchievementBrowser.getachievements()

            for u in tracking.keys():
                for n, x in enumerate(tracking[u]):
                    for baseserver in [
                            bot.epicord,
                            bot.get_guild(403747701566734336)
                    ]:
                        server = "global" if achievements[n][
                            "global"] else baseserver.id
                        if baseserver.get_member(int(u)) == None:
                            continue
                        bot.ach_tracking.setdefault(server, {})
                        bot.ach_tracking[server].setdefault(int(u), {})
                        bot.ach_tracking[server][int(u)].setdefault(n, [])
                        edit = bot.ach_tracking[server][int(u)][n]
                        for nn in range(len(achievements[n]["check"])):
                            if len(edit) < nn + 1:
                                edit.append(False)
                            #
                            # print()
                            # print(edit)
                            # print(edit[nn])
                            # print(tracking[u])
                            # print(tracking[u][n])
                            # print(tracking[u][n][nn])
                            # print()
                            edit[nn] = tracking[u][n][nn] or edit[nn]

                            if u in count:
                                if (n, nn) in count[u]:
                                    bot.ach_tracking_count.setdefault(
                                        server, {})
                                    bot.ach_tracking_count[server].setdefault(
                                        int(u), {})
                                    bot.ach_tracking_count[server][int(
                                        u)].setdefault((n, nn), 0)

                                    editc = bot.ach_tracking_count[server][int(
                                        u)]

                                    editc[(n, nn)] = ccc.highest(
                                        [count[u][(n, nn)], editc[(n, nn)]])

            await talking.say(context, "cool")
            basics.save(bot, "ach_tracking")
            basics.save(bot, "ach_tracking_count")
            return
        ####################################THE REAL DEAL!

        AchievementBrowser(bot,
                           validfor=datetime.timedelta(minutes=10),
                           context=context)
示例#11
0
    async def cyclecomic(self, context):
        """Cycle comic manager.

        Cyclecomics being comics where, repeatedly, one person adds two panels, and then shows only the newest panel to another person. Then they add two panels and pass on only the last panel, and so on.

        Modifiers:
        new|create|add : Create a new cyclecomic.
        join|enter : Add yourself to a previously created cyclecomic.
        upload|panel|append : Add a panel to a cyclecomic on which it's your turn.
        pass|give : Make it somebody else's turn on a cycleomic on which it's your turn.
        view|show|release|spew|display : Display a completed cyclecomic.
        """
        async def SAVETODICT_give(self):
            await talking.say(
                self.context,
                f"Hey loser. You've been passed this panel ||{self.url} || by {basics.truename(self.bot,context.message.author)} as part of {q}.",
                channel=self.passonto)
            self.bot.cyclecomics[self.q]["turn"] = self.passonto.id
            basics.save(self.bot, "cyclecomics")
            self.message = "Okay, done."

        async def SAVETODICT_upload(self):
            self.bot.cyclecomics[q]["panelurls"].append(self.image)
            self.bot.cyclecomics[q]["panelcreators"].append(
                self.context.message.author.id)
            basics.save(bot, "cyclecomics")
            await talking.reply(
                context,
                f"Okay, {self.image} has been added. I'm saving the URL, not the actual image. I'm also not your mom(unless you want me to be <:blob_wink:423672830316511232>), so I'm not adding a failsafe if you delete the message and thus an attached image. It'll just not show up and you'll lose all your friends."
            )

        async def SAVETODICT_view(self):
            for n, x in enumerate(self.bot.cyclecomics[self.q]["panelurls"]):
                await talking.say(
                    self.context,
                    f"Panel {n+1}, by <@{self.bot.cyclecomics[self.q]['panelcreators'][n]}>.\n{x}"
                )
                await asyncio.sleep(30)

        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        q, new, join, upload, give, view = basics.subcommands(
            context, q, [
                r"new|create|add", r"join|enter", r"upload|panel|append",
                r"pass|give", r"view|show|release|spew|display"
            ])

        refnum = " ".join(q.split(" ")[1:])
        q = q.split(" ")[0]
        qcaps = q
        q = q.lower()

        current = bot.cyclecomics

        if new is not None:
            for k, i in current.items():
                if i["owner"] == m.author.id != bot.rnl.id:
                    await talking.reply(
                        context,
                        "You can only create one cyclecomic at a time per server to prevent spam."
                    )
                    return
            if not q:
                await talking.reply(
                    context,
                    'Add a nickname to this comic, so that it can be identified by something besides an autogenerated number. Like, I dunno. "penis" or "Chris" or something. Six characters max, limited to numbers, letters, and underscores.'
                )
            elif not re.match(r"^\w{1,6}$", q):
                await talking.reply(
                    context,
                    'Six characters max, limited to numbers, letters, and underscores.'
                )
            else:
                if q in current:
                    await talking.reply(
                        context, f"{basics.spitback(qcaps)} is taken already!")
                else:
                    current[q] = {
                        "owner": m.author.id,
                        "turn": m.author.id,
                        "creationtime": str(datetime.datetime.utcnow().date()),
                        "panelurls": [],
                        "panelcreators": [],
                        "users": [m.author.id],
                        "qcaps": qcaps,
                        "server": m.guild.id
                    }
                    await talking.reply(
                        context,
                        f"Okay, {basics.spitback(qcaps)} is now added. People can join using `s!cc [join]{current[q]['qcaps']}`"
                    )
                    basics.save(bot, "cyclecomics")
        elif join is not None:
            if not q:
                await talking.reply(
                    context,
                    "You need to specify which cyclecomic you want to join!")
            elif q not in current:
                await talking.reply(
                    context,
                    f"{basics.spitback(qcaps)} doesn't seem to exist.")
            elif m.author.id in current[q]["users"]:
                await talking.reply(context,
                                    "You're already in this cyclecomic!")
            else:
                current[q]["users"].append(m.author.id)
                basics.save(bot, "cyclecomics")
                await talking.reply(
                    context, "Coolio, you've been added to this cyclecomic.")
        elif upload is not None:
            if not q:
                await talking.reply(
                    context,
                    "You need to specify which cyclecomic you want to add a panel to!"
                )
            elif q not in current:
                await talking.reply(
                    context,
                    f"{basics.spitback(qcaps)} doesn't seem to exist.")
            elif m.author.id not in current[q]["users"]:
                await talking.reply(
                    context,
                    f"You aren't a member of this cyclecomic. You can join with `s!cc [join]{current[q]['qcaps']}`."
                )
            elif current[q]["turn"] != m.author.id:
                await talking.reply(context,
                                    f"It's not your turn on this cyclecomic.")
            else:
                image = await utility.referenceimage(context, returnurl=True)
                if image:
                    ConfirmMessage(
                        bot,
                        validfor=datetime.timedelta(minutes=5),
                        message=
                        f"Are you sure you want to add ||{image} || to {q}?",
                        image=image,
                        q=q,
                        yesscript=SAVETODICT_upload,
                        context=context)
        elif give is not None:
            if not q:
                await talking.reply(
                    context,
                    "You need to specify which cyclecomic you want to pass off on!"
                )
            elif q not in current:
                await talking.reply(
                    context,
                    f"{basics.spitback(qcaps)} doesn't seem to exist.")
            elif m.author.id not in current[q]["users"]:
                await talking.reply(
                    context,
                    f"You aren't a member of this cyclecomic. You can join with `s!cc [join]{current[q]['qcaps']}`."
                )
            elif current[q]["turn"] != m.author.id:
                await talking.reply(context,
                                    f"It's not your turn on this cyclecomic.")
            else:
                try:
                    server = bot.get_guild(current[q]['server'])
                    u = utility.get_member_or_user(
                        bot, server, current[q]['users'][int(refnum)])
                except:
                    await talking.reply(
                        context,
                        f"I couldn't figure out who {basics.spitback(refnum)} referred to. Use s!cc {current[q]['qcaps']} and give me the reference number of the peron you want to pass to."
                    )
                else:
                    if u.id == m.author.id:
                        await talking.reply(
                            context,
                            f"*You're* {basics.truename(bot,u)}, dummy!")
                    else:
                        if current[q]['panelurls']:
                            url = current[q]['panelurls'][-1]
                        else:
                            url = "I lied. I decieved you. Nothing has been added to this cyclecomic yet."
                        ConfirmMessage(
                            bot,
                            validfor=datetime.timedelta(minutes=5),
                            message=
                            f"Are you sure you want to pass ||{url} || to {basics.truename(bot,u)}?",
                            passonto=u,
                            url=url,
                            q=q,
                            yesscript=SAVETODICT_give,
                            context=context)
        elif view is not None:
            if not q:
                await talking.reply(
                    context,
                    "You need to specify which cyclecomic you want to show!")
            elif q not in current:
                await talking.reply(
                    context,
                    f"{basics.spitback(qcaps)} doesn't seem to exist.")
            elif m.author.id != current[q]["owner"]:
                await talking.reply(
                    context,
                    f"You don't own this cyclecomic, so you can't set it off.")
            else:
                ConfirmMessage(
                    bot,
                    validfor=datetime.timedelta(minutes=5),
                    message=
                    f"Are you sure you want to display the entirety of {q}? You can't turn back. It'll be EVERYWHERE.",
                    q=q,
                    yesscript=SAVETODICT_view,
                    context=context)
        else:
            if not q:
                s = "Here's a list of cyclecomics in this server. Specify one to get more info on it.\n`"
                for x in current.keys():
                    s += f"\n{x}"
                s += "`"
                await talking.reply(context, s)
            elif q not in current:
                await talking.reply(
                    context,
                    f"{basics.spitback(qcaps)} isn't a cyclecomic on this server."
                )
            else:
                lol = [["User", "Turn", "Owner", "Panels", "Ref. #", "Status"]]
                for n, x in enumerate(current[q]["users"]):
                    u = utility.get_member_or_user(bot, m.guild, x)
                    lol.append([
                        basics.truename(bot, u), u.id == current[q]["turn"],
                        u.id == current[q]["owner"],
                        current[q]["panelcreators"].count(u.id), n,
                        aesthetic.statusemoji(bot, u)
                    ])
                SortableChart(bot,
                              validfor=datetime.timedelta(minutes=5),
                              context=context,
                              lol=lol,
                              initialsort=[1, 0])
示例#12
0
    async def obamaresidue(self, context):
        """Shows how much Obama Residue you have. Mention somebody to check how much they have instead.

        Modifiers:
        all|max|now|top|list : Displays a chart of server-wide residue counts."""
        q = basics.contentq(context.message.content, split=False)
        q, max = basics.subcommands(context, q, [r"all|max|now|top|list"])
        bot = self.bot

        ot.otedit(self.bot,
                  context.message.author,
                  0,
                  False,
                  channel=context.message.channel)
        if max is not None:
            l = [["User", "Max", "Now", "Me", "Mentioned"]]
            for k in self.bot.obamaresidue[context.message.guild.id].keys():
                k = context.message.guild.get_member(k)
                if k is None:
                    continue
                ot.otedit(self.bot,
                          k,
                          0,
                          False,
                          channel=context.message.channel)
                if k != None:
                    l.append([
                        basics.truename(bot, k),
                        round(
                            self.bot.obamaresiduemax[context.message.guild.id][
                                k.id] / 1000, 3),
                        round(
                            self.bot.obamaresidue[context.message.guild.id][
                                k.id] / 1000,
                            3), k.id == context.message.author.id, k
                        in context.message.mentions
                    ])

            SortableChart(bot,
                          lol=l,
                          validfor=timedelta(minutes=5),
                          context=context,
                          initialsort=[4, 1, 2, 3, 5],
                          addnumbers=True,
                          resetnumbers={2, 3},
                          defaultreverse={2, 3, 4, 5})

            return
        target = context.message.author
        if len(context.message.mentions) > 0:
            target = context.message.mentions[0]
            ot.otedit(self.bot,
                      target,
                      0,
                      False,
                      channel=context.message.channel)

        if target == context.message.author:
            targetstr = "You currently have"
            targetstr2 = "Your"
        else:
            targetstr = "{} currently has".format(ccc.shownames(bot, target))
            targetstr2 = "Their"
        await talking.reply(
            context, "{} {} Obama Residue. {} all-time count is {}.".format(
                targetstr,
                round(self.bot.obamaresidue[target.guild.id][target.id] / 1000,
                      3), targetstr2,
                round(
                    self.bot.obamaresiduemax[target.guild.id][target.id] /
                    1000, 3)))
示例#13
0
    async def kothnew(self, context):
        """Makes you king. Or whatever.

        The king of the hill will get an automatic crown reaction to their messages. You can also become the queen/loli/furry/cheese, based on what alias you use. Or whatever you type after the command. Use [bot] to make the bot take it. After that, you can put an emoji in brackets to get any emoji.
        You get an increasingly sexy secondary reaction as you hit 15 minutes, two hours, six hours, and 24 hours uninterupted.
        You can view the top 10 with [top], [high], or [score]. You can use [long] to view the top 500. You can view everyone's best scores with [best], [one], or [records].
        See who's currently king and for how long with [time].
        When taking the hill, whoever is already on it gets 5 seconds to say something and defend their title. If you try to take it from somebody you didn't want to take it from, if you say . before they defend, it gets canceled.
        The command has a starting cooldown of 15 seconds. When the hill is defended successfully, and the attacker isn't the king, that cooldown is increased by half a second for the next 10 minutes.
        Scores earned after koth's death have a skull next to them. You can hide all the death scores with [legacy]."""
        bot = self.bot
        m = context.message

        q = basics.contentq(context.message.content)
        q, specialemoji = basics.subcommands(context, q, ["EMOJI"])

        words = " ".join(q)
        legacy = "[legacy]" in words
        if "[bs]" in words and context.message.author.id == self.bot.rnl.id:
            self.bot.koth = copy.deepcopy(self.bot.kothlast)
            basics.save(bot,"koth")
            await talking.reply(context, "Cool.")
            return

        if "[time]" in words:
            secs = (datetime.utcnow() - self.bot.koth[4]).seconds + (
                        (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60)
            mins = 0
            hours = 0
            while secs >= 60:
                mins += 1
                secs -= 60
            while mins >= 60:
                hours += 1
                mins -= 60
            await talking.reply(context,
                           "{} has been {} for the last {}, {}, and {}. If the hill was lost now, it would be worth {} pixels.".format(
                               self.bot.koth[1],
                               self.bot.koth[2],
                               ccc.pluralstr("hour", hours),
                               ccc.pluralstr("minute", mins),
                               ccc.pluralstr("second", secs),
                               koth.pixelcalc(self.bot.koth[4], datetime.utcnow()))
                           )
            return
        if "[top]" in words or "[high]" in words or "[score]" in words:
            embed = discord.Embed(title="King of the Hill Highscores", type="rich")
            high = self.bot.kothhigh[::-1][:10]
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")

            s = ""
            for x in range(0, len(high)):
                if legacy and high[x][4]:
                    continue
                u = self.bot.epicord.get_member(high[x][0])
                limit = 23
                if len(u.display_name) > limit:
                    name = u.display_name[:limit - 3] + "..."
                else:
                    name = "<@!" + high[x][0] + ">"
                if x <= 9:
                    s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                else:
                    s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n"
            embed.add_field(name="# User", value=s, inline=True)

            s = ""
            for x in high:
                if legacy and x[4]:
                    continue
                if x[2] == None:
                    emoji = "👑"
                elif len(x[2]) == 1:
                    emoji = x[2]
                else:
                    emoji = "<" + x[2] + ">"
                name = x[1]
                limit = 15
                if len(name) > limit:
                    name = name[:limit - 3] + "..."
                s += emoji + name + "\n"
            embed.add_field(name="Title", value=s, inline=True)

            s = ""
            for x in high:
                if legacy and x[4]:
                    continue
                seconds = x[3]
                emoji = "<:bl:230481089251115018>"
                if seconds > (60 * 60) * 24:
                    emoji = "<:tier4:348277627598929922>"
                elif seconds > (60 * 60) * 6:
                    emoji = "<:tier3:348279546765901826>"
                elif seconds > (60 * 60) * 2:
                    emoji = "<:tier2:348276583741521921>"
                elif seconds > 60 * 15:
                    emoji = "<:tier1:348266722526101505>"
                if x[4]:
                    emoji = "💀"
                minutes = 0
                while seconds >= 60:
                    seconds -= 60
                    minutes += 1
                hours = 0
                while minutes >= 60:
                    minutes -= 60
                    hours += 1
                minutes += round(seconds / 60, 2)
                s += emoji + str(hours) + " hours, " + str(minutes) + " min.\n"
            embed.add_field(name="Time", value=s, inline=True)

            s = "You don't have a score on this list."
            high = self.bot.kothhigh
            for x in range(0, len(high)):
                if high[x][0] == context.message.author.id:
                    s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
            embed.set_footer(text=s)

            await mf.say(context, embed=embed)
            return
        # WOAH MAMA
        if "[long]" in words:
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")
            msg = await talking.say(context, "­")
            for n in numbers + [":bn_up:328724374540779522", ":bn_do:328724374498836500"]:
                asyncio.ensure_future(self.bot.add_reaction(msg, n.replace("<", "").replace(">", "")))
            page = 0
            while True:
                embed = discord.Embed(title="Extended King of the Hill Highscores (Page {})".format(page + 1),
                                      type="rich")
                place = 0
                names = ["# User", "Title", "Time"]
                for place in range(0 + (page * 5), 5 + (page * 5)):
                    # print("uh")
                    high = self.bot.kothhigh[::-1][(place * 10):10 + (place * 10)]
                    s = ""
                    for x in range(0, len(high)):
                        if legacy and high[x][4]:
                            continue
                        u = context.message.guild.get_member(high[x][0])
                        if u == None:
                            u = self.bot.epicord.get_member(high[x][0])
                        limit = 16
                        if len(u.display_name) > limit:
                            name = u.display_name[:limit - 3] + "…"
                        else:
                            name = "<@!" + high[x][0] + ">"
                        if x + (place * 10) <= 9:
                            s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                        else:
                            s += "`" + str(x + 1 + (place * 10)) + ")`" + basics.useremoji(self.bot,
                                                                                       high[x][0]) + name + "\n"
                    embed.add_field(name=names[0], value=s, inline=True)

                    s = ""
                    for x in high:
                        if legacy and x[4]:
                            continue
                        if x[2] == None:
                            emoji = "👑"
                        elif len(x[2]) <= 10:
                            emoji = x[2]
                        else:
                            if utility.get_emoji(self.bot, x[2]) != None:
                                emoji = "<" + x[2] + ">"
                            else:
                                emoji = str(utility.get_emoji(self.bot, x[2].split(":")[1]))
                        name = x[1]
                        limit = 15
                        if len(name) > limit:
                            name = name[:limit - 3] + "…"
                        s += emoji + name + "\n"
                    embed.add_field(name=names[1], value=s, inline=True)

                    s = ""
                    for x in high:
                        if legacy and x[4]:
                            continue
                        seconds = x[3]
                        emoji = "<:bl:230481089251115018>"
                        if seconds > (60 * 60) * 24:
                            emoji = "<:tier4:348277627598929922>"
                        elif seconds > (60 * 60) * 6:
                            emoji = "<:tier3:348279546765901826>"
                        elif seconds > (60 * 60) * 2:
                            emoji = "<:tier2:348276583741521921>"
                        elif seconds > 60 * 15:
                            emoji = "<:tier1:348266722526101505>"
                        if x[4]:
                            emoji = "💀"
                        minutes = 0
                        while seconds >= 60:
                            seconds -= 60
                            minutes += 1
                        hours = 0
                        while minutes >= 60:
                            minutes -= 60
                            hours += 1
                        minutes += round(seconds / 60, 2)
                        s += emoji + str(hours) + "h, " + str(round(minutes, 2)) + "m\n"
                    embed.add_field(name=names[2], value=s, inline=True)

                    names = ["­", "­", "­"]

                s = "You don't have a score on this list."
                high = self.bot.kothhigh
                for x in range(0, len(high)):
                    if high[x][0] == context.message.author.id:
                        s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
                embed.set_footer(text=s)

                msg = await talking.edit(context, msg, embed=embed)

                def tempcheck(reaction, user):
                    return user.id != self.bot.me.id

                rea = await self.bot.wait_for_reaction(self.bot.buttons, message=msg, check=tempcheck, timeout=120)
                if rea == None:
                    await self.bot.clear_reactions(msg)
                    break
                else:
                    await self.bot.remove_reaction(msg, rea[0].emoji, rea[1])
                    if rea[0].emoji.name == "bn_up":
                        page -= 1
                    elif rea[0].emoji.name == "bn_do":
                        page += 1
                    else:
                        page = int(rea[0].emoji.name.replace("bn_", "")) - 1
                    if page == -1:
                        page = 9
                    elif page == 10:
                        page = 0
            return
        # WOAH MAMA again
        if "[best]" in words or "[one]" in words or "[records]" in words:
            embed = discord.Embed(title="Top King of the Hill Scores For Each Player", type="rich")
            high = self.bot.kothhigh[::-1]
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")
            playersshown = []

            s = ""
            s2 = ""
            s3 = ""
            for x in range(0, len(high)):
                if legacy and high[x][4]:
                    continue
                if high[x][0] not in playersshown:
                    playersshown.append(high[x][0])
                    u = context.message.server.get_member(high[x][0])
                    if u == None:
                        u = self.bot.epicord.get_member(high[x][0])
                    limit = 16
                    name = "<@!" + high[x][0] + ">"
                    if u != None:
                        if len(u.display_name) > limit:
                            name = u.display_name[:limit - 3] + "…"
                        else:
                            name = "<@!" + high[x][0] + ">"
                    if x <= 9:
                        s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                    else:
                        s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n"

                    if high[x][2] == None:
                        emoji = "👑"
                    elif len(high[x][2]) == 1:
                        emoji = high[x][2]
                    else:
                        emoji = str(utility.get_emoji(self.bot, high[x][2].split(":")[1]))
                    name = high[x][1]
                    limit = 15
                    if len(name) > limit:
                        name = name[:limit - 3] + "…"
                    s2 += emoji + name + "\n"

                    seconds = high[x][3]
                    emoji = "<:bl:230481089251115018>"
                    if seconds > (60 * 60) * 24:
                        emoji = "<:tier4:348277627598929922>"
                    elif seconds > (60 * 60) * 6:
                        emoji = "<:tier3:348279546765901826>"
                    elif seconds > (60 * 60) * 2:
                        emoji = "<:tier2:348276583741521921>"
                    elif seconds > 60 * 15:
                        emoji = "<:tier1:348266722526101505>"
                    if high[x][4]:
                        emoji = "💀"
                    minutes = 0
                    while seconds >= 60:
                        seconds -= 60
                        minutes += 1
                    hours = 0
                    while minutes >= 60:
                        minutes -= 60
                        hours += 1
                    minutes += round(seconds / 60, 2)
                    s3 += emoji + str(hours) + " hours, " + str(minutes) + " min.\n"
            embed.add_field(name="# User", value=s[:1024], inline=True)
            embed.add_field(name="Title", value=s2[:1024], inline=True)
            embed.add_field(name="Time", value=s3[:1024], inline=True)

            s = "You don't have a score on this list."
            high = self.bot.kothhigh
            for x in range(0, len(high)):
                if high[x][0] == context.message.author.id:
                    s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
            embed.set_footer(text=s)

            await talking.say(context, embed=embed)
            return

        if context.message.channel.id != "160197704226439168" and context.message.guild.id != self.bot.testserver.id:
            await talking.reply(context, "This only works in the bot channel.")
            return

        if context.message.author.bot:
            await talking.reply(context,
                           "Non-RSRB bots can't become king, because multiple people would be able to defend the hill.")
            return

        seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds
        if m.guild.id not in self.bot.kothcooldowndict.keys():
            self.bot.kothcooldowndict[m.guild.id] = 15
        if seconds < self.bot.kothcooldowndict[m.guild.id]:
            if m.guild.id not in self.bot.kothcooldownnotovertolddict.keys():
                self.bot.kothcooldownnotovertolddict[m.guild.id] = []
            if m.author.id not in self.bot.kothcooldownnotovertolddict[m.guild.id]:
                await talking.reply(context, "Please wait, the cooldown's not over yet.")
                self.bot.kothcooldownnotovertolddict[m.guild.id].append(m.author.id)
            else:
                await self.bot.delete_message(m)
            return
        self.bot.kothcooldownnotovertolddict[m.guild.id] = []

        bot = False
        if words.startswith("[bot]"):
            bot = True
            words = words[5:]

        specialemoji = None
        if words.startswith("[") and words.count("]") != 0:
            words = words.split("]")
            specialemoji = words[0][1:].replace("<", "").replace(">", "").strip()
            errorspecialemoji = str(specialemoji)
            words = "]".join(words[1:])
            msg = await self.bot.send_message(self.bot.testserver.get_channel("329187094620667906"), "hi")
            try:
                await self.bot.add_reaction(msg, specialemoji)
            except:
                specialemoji = str(utility.get_emoji(self.bot, specialemoji)).replace("<", "").replace(">", "")
                try:
                    await self.bot.add_reaction(msg, specialemoji)
                except:
                    await talking.reply(context, "`{}` is not a valid emoji!".format(errorspecialemoji))
                    return
        if specialemoji != None:
            if "hippofrumplequest" in specialemoji:
                await talking.reply(context, "no")
                return
            if "obama" in specialemoji:
                await talking.reply(context, "no")
                return

        self.bot.kothcooldown = datetime.utcnow()

        if seconds < 15:
            await talking.reply(context, "Please wait, the cooldown's not over yet.")
            return

        seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds

        u = self.bot.epicord.get_member(self.bot.koth[0])
        timestampmsg = await talking.say(context,
                                    u.mention + ": Quick! Fight off {} by saying something!\n{}: Say . if this was a mistake.".format(
                                        ccc.shownames(context.message.author), context.message.author.mention))
        statement = "doesn't defend the hill."
        if u.id != self.bot.me.id:
            def tempcheck(m):
                return m.author == u or (m.author == context.message.author and m.content == ".")

            reply = await self.bot.wait_for_message(timeout=15, author=None, channel=context.message.channel,
                                                    content=None, check=tempcheck)
            if reply != None and reply.author == context.message.author:
                await talking.reply(context, "Heh. Nice going, mate.")
                return
            statement = ""
            if reply == None:
                statement = "never defended the hill."
                # await mf.say(context,u.mention+", nice work. The hill is yours... for now.".format(mf.shownames(context.message.author)))
                # return
            else:
                seconds = (reply.timestamp - timestampmsg.timestamp).seconds
                if seconds <= 5:
                    await talking.say(context, u.mention + ", nice work. You've defended the hill with {} to spare.".format(
                        ccc.pluralstr("second", round(5 - seconds, 2))))
                    if context.message.author != u:
                        asyncio.ensure_future(mf.kothincreasecooldown(self.bot, m.guild.id))
                    return
                else:
                    statement = "attempted to defend the hill, but was late by {}.".format(
                        ccc.pluralstr("second", round(seconds - 5, 2)))

        self.bot.kothlast = copy.deepcopy(self.bot.koth)
        self.bot.kothcooldowndict[m.guild.id] = 15

        if self.bot.koth == "":
            self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), "king"]
            basics.save(bot,"koth")
        elif context.message.author.id == "238459957811478529" or context.message.author.id == "208304366719860737":
            await talking.reply(context, "F**K OFF!!!")
        elif context.message.guild != self.bot.epicord and context.message.guild != self.bot.testserver:
            await talking.reply(context, "You can't overthrow the {} in secret.".format(self.bot.koth[2]))
        else:
            if context.message.content[2] == "k":
                type = "king"
            if context.message.content[2] == "q":
                type = "queen"
            if context.message.content[2] == "l":
                type = "loli"
            if context.message.content[2] == "f":
                type = "furry"
            if context.message.content[2] == "c":
                type = "cheese"
            # if context.message.content[2]=="h":
            #    type = "hippo"
            if len(words) > 0:
                type = words.strip()

            if specialemoji != None:
                if ":markedforpinning:" in specialemoji:
                    await talking.reply(context, "F**K OFF!!!")
                    return

            # Save highscore stuff
            seconds = (datetime.utcnow() - self.bot.koth[4]).seconds
            seconds += (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60
            add = [self.bot.koth[0], self.bot.koth[2], self.bot.koth[3], seconds, True]
            added = False
            rank = 0
            for x in range(0, len(self.bot.kothhigh)):
                if add[3] < self.bot.kothhigh[x][3]:
                    added = True
                    rank = x
                    self.bot.kothhigh.insert(x, add)
                    break
            if added == False:
                rank = len(self.bot.kothhigh)
                self.bot.kothhigh.append(add)
            basics.save(bot,"kothhigh")

            emoji = ""
            if seconds > (60 * 60) * 24:
                emoji = "<:tier4:348277627598929922>"
            elif seconds > (60 * 60) * 6:
                emoji = "<:tier3:348279546765901826>"
            elif seconds > (60 * 60) * 2:
                emoji = "<:tier2:348276583741521921>"
            elif seconds > 60 * 15:
                emoji = "<:tier1:348266722526101505>"
            minutes = 0
            while seconds >= 60:
                seconds -= 60
                minutes += 1
            hours = 0
            while minutes >= 60:
                minutes -= 60
                hours += 1
            minutes += round(seconds / 60, 2)
            highs = emoji + str(hours) + " hours and " + str(minutes) + " minutes"
            try:
                highs = "\n\n<@{}> lasted {}, ranking at #{}. They've earned {} pixels for a total of {}.".format(
                    self.bot.koth[0], highs, len(self.bot.kothhigh) - rank,
                    koth.pixelcalc(self.bot.koth[4], datetime.utcnow()),
                    mf.pixeledit(self.bot, self.bot.koth[0], mf.pixelcalc(self.bot.koth[4], datetime.utcnow())))
            except:
                pass

            previouskoth = list(self.bot.koth)
            if bot == False:
                await talking.reply(context,
                               "<@{}> {} As such, you've become {} of the hill, overthrowing the previous {}!".format(
                                   self.bot.koth[0], statement, type, self.bot.koth[2]) + highs)

                self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), type,
                                 specialemoji, datetime.utcnow()]
            else:
                await talking.reply(context,
                               "<@{}> {} As such, the bot has become {} of the hill, overthrowing the previous {}!".format(
                                   self.bot.koth[0], statement, type, self.bot.koth[2]) + highs)
                # await mf.reply(context,"The bot has become {} of the hill, overthrowing <@{}>, the previous {}!".format(type,self.bot.koth[0],self.bot.koth[2])+highs)
                self.bot.koth = [self.bot.me.id, ccc.shownames(context.message.guild.me), type, specialemoji,
                                 datetime.utcnow()]

            basics.save(bot,"koth")
示例#14
0
    async def peeon(self, context):
        """Spray people.

        Shows a dickdick spraying various fluids on a mentioned user based on the alias used.

        Modifiers:
        cum|nut|j**z : Replace pee with cum.
        bleed|blood : Replace pee with blood.
        sweat : Replace pee with sweat.

        Rigged Aliases:
        cumon, nuton, jizzon : Replace pee with cum.
        bleedon : Replace pee with blood.
        sweaton : Replace pee with sweat."""

        bot = self.bot
        m = context.message
        q = basics.contentq(m.content, split=False)

        q, cum, bleed, sweat = basics.subcommands(context, q,
                                           [r"cum|nut|j**z", r"bleed|blood", r"sweat"],
                                           riggedaliases=[
                                               {
                                                   "regex": r"cumon|nuton|jizzon",
                                                   "slot": 0,
                                                   "value": "cum"
                                               },
                                               {
                                                   "regex": r"bleedon",
                                                   "slot": 1,
                                                   "value": "bleed"
                                               },
                                               {
                                                   "regex": r"sweaton",
                                                   "slot": 2,
                                                   "value": "sweat"
                                               }
                                           ])

        if len(context.message.mentions) == 0:
            await talking.reply(context, "You need to mention someone!")
            return

        s = "<:dickdicks1:275176074940252163><:dickdicks2:275176053947891714><:dickdicks3:275176078853537792>"
        emoji = basics.useremoji(bot, m.mentions[0])
        if cum:
            s += "<:liqMilk:273903113264693248>"
            fluid = "cum"
        elif bleed:
            s += "<:liqBlood:382341153699135488>"
            fluid = "blood"
        elif sweat:
            s += "💦"
            fluid = "sweat"
        else:
            s += "<:liqPee:273882459924594689>"
            fluid = "pee"

        msg = await talking.say(context, s + emoji)
        await AchievementBrowser.ach_check(bot, m.mentions[0], m.channel, "peetarget",
                           [fluid, context.message.author])
        await msg.add_reaction(basics.useremoji(bot, m.author)[1:-1])