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/mute.py
Luke Rogers ffbeab7e14 PEP-8
2012-03-23 13:00:22 +13:00

74 lines
1.7 KiB
Python
Executable file

from util import hook
muted = []
def mute_target(target):
""" mutes someone """
target = target.lower()
muted.append(target)
def unmute_target(target):
""" unmutes someone """
target = target.lower()
muted.remove(target)
def is_muted(target):
""" checks of someone is muted """
target = target.lower()
if target in muted:
return True
else:
return False
@hook.sieve
def mutesieve(bot, input, func, type, args):
""" blocks input from muted channels/users """
# don't block input to event hooks
if type == "event":
return input
if is_muted(input.chan) or is_muted(input.nick):
if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute":
return input
else:
return None
return input
@hook.command(autohelp=False)
def listmuted(inp, bot=None):
".listmuted -- Lists muted users/channels."
if muted:
return "Muted users/channels are: " + ", ".join(muted)
else:
return "No users are currently muted."
@hook.command(adminonly=True)
def mute(inp, input=None, db=None):
".mute <channel/user> -- Makes the bot ignore <channel/user>."
target = inp
if is_muted(target):
input.notice("%s is already muted." % target)
else:
mute_target(target)
input.notice("%s has been muted." % target)
@hook.command(adminonly=True)
def unmute(inp, input=None, db=None):
".unmute <channel/user> -- Makes the bot listen to <channel/user>."
target = inp
if is_muted(target):
unmute_target(target)
input.notice("%s has been unmuted." % target)
return
else:
input.notice("%s is not muted." % target)
return