示例#1
0
    def automod_caught_message(self, streamer: Streamer, info,
                               mod_action: ModAction,
                               embed: disnake.Embed) -> disnake.Embed:
        ignore_message = False
        user = info["message"]["sender"]["login"]
        user_escaped = user.lower().replace('_', '\_')
        embed.title = f"{mod_action.value.replace('_', ' ').title()}"
        embed.color = self.colour.red
        embed.add_field(
            name="Flagged Account",
            value=
            f"[{user_escaped}](<https://www.twitch.tv/popout/{streamer.username}/viewercard/{user_escaped}>)",
            inline=True)
        embed.add_field(
            name="Content Classification",
            value=
            f"{info['content_classification']['category'].title()} level {info['content_classification']['level']}",
            inline=True)
        text_fragments = []
        topics = []
        for fragment in info["message"]["content"]["fragments"]:
            if fragment != {}:
                for topic in fragment.get("automod", {}).get("topics",
                                                             {}).keys():
                    if topic not in topics:
                        topics.append(topic.replace("_", " "))
                if fragment.get("text", None) is not None:
                    text_fragments.append(fragment.get("text", None))

        text_fragments = list(
            dict.fromkeys(text_fragments)
        )  #Remove duplicates from topics and text fragments, they're pointless
        topics = list(dict.fromkeys(topics))
        embed.add_field(
            name="Text fragments",
            value=
            f"`{', '.join([f.strip(' ') for f in text_fragments]).strip(', ')}`"
        )
        embed.add_field(name="Topics",
                        value=f"`{', '.join(topics).strip(', ')}`")
        if info["status"] == "PENDING":
            embed.colour = self.colour.yellow
            if "automod_caught_message" not in streamer.action_whitelist and streamer.action_whitelist != []:
                ignore_message = True
        elif info["status"] == "ALLOWED":
            if "automod_allowed_message" not in streamer.action_whitelist and streamer.action_whitelist != []:
                ignore_message = True
            embed.colour = self.colour.green
        elif info["status"] == "DENIED":
            if "automod_denied_message" not in streamer.action_whitelist and streamer.action_whitelist != []:
                ignore_message = True
            embed.colour = self.colour.red
        else:
            if "automod_caught_message" not in streamer.action_whitelist and streamer.action_whitelist != []:
                ignore_message = True
        if info["status"] != "PENDING":
            embed.title = embed.title.replace("Caught", info["status"].title())
        return ignore_message, embed
示例#2
0
    async def is_gurkan(self, ctx: Context, *,
                        user: Optional[Union[Member, str]]) -> None:
        """
        The gurkanrate of the user and whether the user is a gurkan is sent in an embed,\
        the color depending on how high the rate is.

        Can be used on other members, or even text.
        """
        if not isinstance(user, str):
            user = user.display_name if user else ctx.author.display_name

        gurk_state = gurkan_check(user)
        gurk_rate = gurkan_rate(user)
        rate_embed = Embed(description=f"{user}'s gurk rate is {gurk_rate}%")

        if not gurk_state:
            color = Colours.soft_red
            title = f"{Emojis.invalid_emoji} Not gurkan"
        else:
            color = Colours.green
            title = f"{Emojis.cucumber_emoji} Gurkan"

        rate_embed.color = color
        rate_embed.title = title

        await ctx.send(embed=rate_embed)
示例#3
0
    async def gurkan_count(self, ctx: Context) -> None:
        """
        Goes through a list of all the members and uses regex to check if the member is a gurkan.

        Sends the count of total Gurkans in the server,\
        and the percentage of the gurkans to the server members.
        """
        members = ctx.guild.members
        gurkans = sum(gurkan_check(member.display_name) for member in members)
        rate = round((gurkans / len(members)) * 100)

        count_emb = Embed()

        if rate == 100:
            title = f"Whoa!! All {gurkans} members are gurkans!"
            color = Colours.green

        elif rate == 0:
            title = "No one is a gurkan?! That's lame."
            color = Colours.soft_red

        else:
            rate_m = [RATE_DICT[r] for r in RATE_DICT if rate in r][0]

            title = f"{Emojis.cucumber_emoji} {gurkans} members"
            color = Colours.green
            description = f"About {rate}% ({gurkans}/ {len(members)}) of members are gurkans, that's {rate_m}"

        count_emb.title = title
        count_emb.color = color
        count_emb.description = description

        await ctx.send(embed=count_emb)
示例#4
0
 def vip(self, streamer: Streamer, info, mod_action: ModAction,
         embed: disnake.Embed) -> disnake.Embed:
     embed = self.set_user_attrs(streamer, info, mod_action, embed)
     embed.title = embed.title.replace('Vip',
                                       'VIP')  #Capitalize VIP for the looks
     embed.colour = self.colour.green
     return True, embed
示例#5
0
 def set_user_attrs(self, streamer: Streamer, info, mod_action: ModAction,
                    embed: disnake.Embed) -> disnake.Embed:
     user = info["target_user_login"] or info['args'][0]
     user_escaped = user.lower().replace('_', '\_')
     embed.title = f"Mod {mod_action.value.replace('_', ' ').title()} Action"
     #embed.description=f"[Review Viewercard for User](<https://www.twitch.tv/popout/{streamer.username}/viewercard/{user.lower()}>)"
     embed.color = self.colour.red
     embed.add_field(
         name="Flagged Account",
         value=
         f"[{user_escaped}](<https://www.twitch.tv/popout/{streamer.username}/viewercard/{user_escaped}>)",
         inline=True)
     return embed
示例#6
0
 def unvip(self, streamer: Streamer, info, mod_action: ModAction,
           embed: disnake.Embed) -> disnake.Embed:
     embed = self.set_user_attrs(streamer, info, mod_action, embed)
     embed.title = embed.title.replace('Unvip', 'UnVIP')
     return embed
示例#7
0
 def vip_added(self, streamer: Streamer, info, mod_action: ModAction,
               embed: disnake.Embed) -> disnake.Embed:
     embed = self.set_user_attrs(streamer, info, mod_action, embed)
     embed.title = embed.title.replace('Vip', 'VIP')
     embed.colour = self.colour.green
     return embed
示例#8
0
 def unmod(self, streamer: Streamer, info, mod_action: ModAction,
           embed: disnake.Embed) -> disnake.Embed:
     embed = self.set_user_attrs(streamer, info, mod_action, embed)
     embed.title = "Moderator Removed Action"
     return embed
示例#9
0
 def mod(self, streamer: Streamer, info, mod_action: ModAction,
         embed: disnake.Embed) -> disnake.Embed:
     embed = self.set_user_attrs(streamer, info, mod_action, embed)
     embed.title = "Moderator Added Action"  #Use a custom title for adding/removing mods for looks
     embed.colour = self.colour.green
     return embed
示例#10
0
 def set_chatroom_attrs(self, mod_action: ModAction,
                        embed: disnake.Embed) -> disnake.Embed:
     embed.title = self._chatroom_actions[mod_action]
     embed.color = self.colour.yellow
     return embed
示例#11
0
 def set_terms_attrs(self, mod_action: ModAction,
                     embed: disnake.Embed) -> disnake.Embed:
     embed.title = f"Mod {mod_action.value.replace('_', ' ').title()} Action"
     embed.color = self.colour.red
     return embed