This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/ignore.py

75 lines
1.9 KiB
Python
Raw Normal View History

2012-03-24 04:42:08 +01:00
from util import hook
ignorelist = []
def ignore_target(target):
""" ignores someone """
target = target.lower()
ignorelist.append(target)
def unignore_target(target):
""" unignores someone """
target = target.lower()
ignorelist.remove(target)
def is_ignored(target):
""" checks of someone is ignored """
target = target.lower()
if target in ignorelist:
return True
else:
return False
@hook.sieve
def ignoresieve(bot, input, func, type, args):
""" blocks input from ignored channels/users """
# don't block input to event hooks
if type == "event":
return input
if is_ignored(input.chan) or is_ignored(input.nick) or is_ignored(input.host) or is_ignored(input.mask):
2012-03-24 04:42:08 +01:00
if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
return input
else:
return None
return input
@hook.command(autohelp=False)
def ignored(inp, notice=None, bot=None):
2012-03-31 01:52:51 +02:00
".ignored -- Lists ignored channels/users/hosts."
2012-03-24 04:42:08 +01:00
if ignorelist:
notice("Ignored channels/users/hosts are: %s" % ", ".join(ignorelist))
2012-03-24 04:42:08 +01:00
else:
notice("No channels/users/hosts are currently ignored.")
return
2012-03-24 04:42:08 +01:00
@hook.command(adminonly=True)
def ignore(inp, input=None, notice=None):
2012-03-31 02:26:38 +02:00
".ignore <channel|user|host> -- Makes the bot ignore <channel|user|host>."
2012-03-24 04:42:08 +01:00
target = inp
if is_ignored(target):
notice("%s is already ignored." % target)
else:
ignore_target(target)
notice("%s has been ignored." % target)
2012-04-02 05:57:00 +02:00
return
2012-03-24 04:42:08 +01:00
@hook.command(adminonly=True)
def unignore(inp, input=None, notice=None):
2012-03-31 02:26:38 +02:00
".unignore <channel|user|host> -- Makes the bot listen to <channel|user|host>."
2012-03-24 04:42:08 +01:00
target = inp
if is_ignored(target):
unignore_target(target)
notice("%s has been unignored." % target)
else:
notice("%s is not ignored." % target)
2012-04-02 05:57:00 +02:00
return
2012-03-31 01:58:12 +02:00