예제 #1
0
    def _generate_user_values(self, name: str):
        """
        Internal function. Generates random user values, stores them in the Firebase server, and then returns the new values. Does not check if the values already exist, use with caution.

        Arguments:
            name (str): The name to store the generated values under. Should be indentical to it's search_target designation

        Returns (dict): The generated values as a dictionary. Generated values are: BDE (int), ranking (int), and vore (bool)
        """
        data = {
            "bde": random.randint(1, 100),
            "ranking": random.randint(1, 10),
            "vore": bool(random.randint(0, 1)),
        }

        # Store generated values
        db.collection('rankings').document(name).set(data)

        # Returns the generated values
        return data
예제 #2
0
    async def load_player_info(self):
        """
        Loads player information from the Firestore server.

        Returns (dict): Player information
        """

        try:
            doc_ref = db.collection(u'fight').document(self.id)
            self._player_data = doc_ref.get().to_dict()
        except:
            await self._generate_player_info()
예제 #3
0
    async def rank(self, ctx, *, target=None):
        """
        Ranks a user on a scale of one to ten.
        """
        # Check if allowed channel
        if not allowed_channel(ctx):
            return

        # Exceptions
        if target is None:
            await ctx.send("I can't rank nothing")
            return
        elif re.match(r"(^|\s|.)@everyone($| $| .)", target, re.IGNORECASE):
            await ctx.send("I'm onto your schemes")
            return
        elif target.isnumeric():
            await ctx.send("I'd give " + target + " a(n) " + target +
                           " out of " + target)
            return

        # Assign search target and displayed target
        if re.match(r"(^|\s|.)me($| $| .)", target, re.IGNORECASE):
            search_target = str(ctx.author.id)
            target = "you"
        elif re.match(
                r"/(?=^.*" + str(ctx.author.display_name) + r".*$).*/gim",
                target, re.IGNORECASE):
            search_target = str(ctx.author.id)
            target = "you"
        elif re.match(r"(<@|<@!)[0-9]+(>)", target, re.IGNORECASE):
            search_target = str(ctx.message.mentions[0].id)
        else:
            search_target = target

        # Load results
        doc_ref = db.collection(u'rankings').document(search_target)
        results = doc_ref.get().to_dict()

        if not results:
            results = self._generate_user_values(search_target)

        if target == 8 or target == 11:
            await ctx.send(
                f"I'd give {target} an {results['ranking']} out of 10")
        else:
            await ctx.send(
                f"I'd give {target} a {results['ranking']} out of 10")
예제 #4
0
    async def vore(self, ctx, *, target=None):
        """
        Says if the user vores or gets vored
        """
        # Check if allowed channel
        if not allowed_channel(ctx):
            return

        # Exceptions
        if target is None:
            await ctx.send("I can't vore nothing")
            return
        elif re.match(r"(^|\s|.)@everyone($| $| .)", target, re.IGNORECASE):
            await ctx.send("I'm onto your schemes")
            return

        # Assign search target and displayed target
        if re.match(r"(^|\s|.)me($| $| .)", target, re.IGNORECASE):
            search_target = str(ctx.author.id)
            target = str(ctx.author.display_name)
        elif re.match(
                r"/(?=^.*" + str(ctx.author.display_name) + r".*$).*/gim",
                target, re.IGNORECASE) or re.match(r"(<@|<@!)[0-9]+(>)",
                                                   target, re.IGNORECASE):
            search_target = str(ctx.author.id)
            target = str(ctx.author.display_name)
        elif re.match(r"(<@|<@!)[0-9]+(>)", target, re.IGNORECASE):
            search_target = str(ctx.message.mentions[0].id)
        else:
            search_target = target

        # Load results
        doc_ref = db.collection(u'rankings').document(search_target)
        results = doc_ref.get().to_dict()

        if not results:
            results = self._generate_user_values(search_target)

        if results["vore"] == "1":
            await ctx.send(str(target) + " vores")
        else:
            await ctx.send(str(target) + " gets vored")