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)
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)
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
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
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
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