52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
![]() |
import irc3
|
||
|
from irc3.plugins.command import command
|
||
|
|
||
|
@irc3.plugin
|
||
|
class DisregardPlugin:
|
||
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
|
self.target = None # The nick to disregard
|
||
|
self.flood_count = 25 # Number of empty messages to send
|
||
|
|
||
|
@irc3.event(irc3.rfc.PRIVMSG)
|
||
|
def on_privmsg(self, mask, event, target, data):
|
||
|
"""
|
||
|
Listens for messages and floods the channel with empty messages
|
||
|
if the message is from the target nick.
|
||
|
|
||
|
:param mask: Contains info about the sender (mask.nick is the sender's nick)
|
||
|
:param target: The channel or user receiving the message
|
||
|
:param data: The text of the message
|
||
|
"""
|
||
|
if self.target and mask.nick == self.target:
|
||
|
for _ in range(self.flood_count):
|
||
|
self.bot.privmsg(target, '\u00A0\u2002\u2003' * 50)
|
||
|
|
||
|
@command(permission='admin', public=True)
|
||
|
def disregard(self, mask, target, args):
|
||
|
"""
|
||
|
Set the target nick to disregard.
|
||
|
|
||
|
%%disregard <nick>
|
||
|
"""
|
||
|
user = args.get('<nick>')
|
||
|
if not user:
|
||
|
self.bot.privmsg(target, "Usage: !disregard <nick>")
|
||
|
return
|
||
|
|
||
|
self.target = user
|
||
|
self.bot.privmsg(target, f"Now disregarding {user}. Their messages will trigger empty floods.")
|
||
|
|
||
|
@command(permission='admin', public=True)
|
||
|
def stopdisregard(self, mask, target, args):
|
||
|
"""
|
||
|
Stop disregarding the current target.
|
||
|
|
||
|
%%stopdisregard
|
||
|
"""
|
||
|
if self.target:
|
||
|
self.bot.privmsg(target, f"Stopped disregarding {self.target}.")
|
||
|
self.target = None
|
||
|
else:
|
||
|
self.bot.privmsg(target, "No target is currently being disregarded.")
|