Exemplo n.º 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
Exemplo n.º 2
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
Exemplo n.º 3
0
    async def fetch_xkcd_comics(self, ctx: Context,
                                comic: Optional[str]) -> None:
        """
        Getting an xkcd comic's information along with the image.

        To get a random comic, don't type any number as an argument. To get the latest, type 'latest'.
        """
        embed = Embed(title=f"XKCD comic '{comic}'")

        embed.colour = Colours.soft_red

        if comic and (comic := re.match(COMIC_FORMAT, comic)) is None:
            embed.description = (
                "Comic parameter should either be an integer or 'latest'.")
            await ctx.send(embed=embed)
            return
Exemplo n.º 4
0
    def add_permitted_term(self, streamer: Streamer, info,
                           mod_action: ModAction,
                           embed: disnake.Embed) -> disnake.Embed:
        embed = self.set_terms_attrs(mod_action, embed)
        embed.colour = self.colour.green
        embed.add_field(name="Added by", value=f"{info['requester_login']}")
        if "`" in info["text"]:
            embed.add_field(name="Term",
                            value=f"```{info['text']}```",
                            inline=False)
        else:
            embed.add_field(name="Term",
                            value=f"`{info['text']}`",
                            inline=False)
        embed.add_field(name="From Automod", value=f"`{info['from_automod']}`")
        if info["expires_at"] != "":
            d = datetime.strptime(info["expires_at"][:-4] + "Z",
                                  "%Y-%m-%dT%H:%M:%S.%fZ")
            epoch = d.timestamp() + 1 - datetime.utcnow().timestamp()
            days = int(str(epoch // 86400).split('.')[0])
            hours = int(str(epoch // 3600 % 24).split('.')[0])
            minutes = int(str(epoch // 60 % 60).split('.')[0])
            seconds = int(str(epoch % 60).split('.')[0])

            full = []
            if days != 0:
                full.append(f"{days}d")
            if hours != 0:
                full.append(f"{hours}h")
            if minutes != 0:
                full.append(f"{minutes}m")
            if seconds != 0:
                full.append(f"{seconds}s")

            expiry = ''.join(full)
            embed.add_field(
                name="Expires in",
                value=
                f"{expiry} (<t:{int(epoch+datetime.now().timestamp())}:R>)")
        else:
            embed.add_field(name="Expires in", value="Permanent")

        embed.remove_field(1)
        return embed
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
0
 def unban(self, streamer: Streamer, info, mod_action: ModAction,
           embed: disnake.Embed) -> disnake.Embed:
     embed.colour = self.colour.green
     return self.set_user_attrs(streamer, info, mod_action, embed)
Exemplo n.º 8
0
 def approve_unban_request(self, streamer: Streamer, info,
                           mod_action: ModAction,
                           embed: disnake.Embed) -> disnake.Embed:
     embed.colour = self.colour.green
     return self.set_appeals_attrs(streamer, info, mod_action, embed)