# -*- coding: utf-8 -*- """ ======================================================== IRC3 Disregard Plugin (Flood-Based Message Suppression) ======================================================== This plugin listens for messages from a **target user** and floods the channel with **empty messages** to suppress visibility of their messages. Features: - **Admin-controlled** disregard system. - **Flood-based suppression** (sends invisible characters). - **Command to start/stop disregarding users**. Commands: !disregard -> Starts disregarding the specified user. !stopdisregard -> Stops disregarding the current user. Usage: - The bot **detects messages** from the target nick and **floods** the chat. - The bot **stops flooding** when the target is removed. """ import asyncio import irc3 from irc3.plugins.command import command @irc3.plugin class DisregardPlugin: """A plugin that disregards a user by flooding the chat with empty messages.""" def __init__(self, bot: irc3.IrcBot): """ Initialize the DisregardPlugin. Args: bot (irc3.IrcBot): The IRC bot instance. """ self.bot = bot self.target = None # The nick to disregard self.flood_count = 25 # Number of empty messages to send per detection self.flood_message = '\u00A0\u2002\u2003' * 50 # Invisible characters @irc3.event(irc3.rfc.PRIVMSG) async def on_privmsg(self, mask, event, target, data): """ Listens for messages and floods the channel if the sender is the target nick. Args: mask (str): Contains info about the sender (mask.nick is the sender's nick). event (str): The IRC event type. target (str): The channel or user receiving the message. data (str): The message content. """ if self.target and mask.nick.lower() == self.target.lower(): self.bot.log.info(f"Flooding {target} due to message from {self.target}.") # Async flooding to avoid blocking for _ in range(self.flood_count): self.bot.privmsg(target, self.flood_message) await asyncio.sleep(0.1) # Prevents immediate rate-limiting @command(permission='admin', public=True) def disregard(self, mask, target, args): """ Set a target nick to disregard (flood when they send messages). Usage: %%disregard Args: mask (str): Sender mask. target (str): The channel where the command was sent. args (dict): Command arguments. Returns: str: Confirmation message. """ user = args.get('') if not user: return "Usage: !disregard " self.target = user.lower() self.bot.privmsg(target, f"Now disregarding {user}. Their messages will trigger empty floods.") self.bot.log.info(f"Started disregarding {user}.") @command(permission='admin', public=True) def stopdisregard(self, mask, target, args): """ Stop disregarding the current target nick. Usage: %%stopdisregard Args: mask (str): Sender mask. target (str): The channel where the command was sent. args (dict): Command arguments. Returns: str: Confirmation message. """ if self.target: self.bot.privmsg(target, f"Stopped disregarding {self.target}.") self.bot.log.info(f"Stopped disregarding {self.target}.") self.target = None else: self.bot.privmsg(target, "No target is currently being disregarded.")