renamed mute.py to ignore.py
This commit is contained in:
parent
cb33198bfb
commit
ac9e567eaf
2 changed files with 73 additions and 73 deletions
73
plugins/ignore.py
Executable file
73
plugins/ignore.py
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
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):
|
||||||
|
if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
|
||||||
|
return input
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return input
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(autohelp=False)
|
||||||
|
def ignored(inp, bot=None):
|
||||||
|
".ignored -- Lists ignored channels/users."
|
||||||
|
if ignorelist:
|
||||||
|
return "Ignored channels/users are: " + ", ".join(ignorelist)
|
||||||
|
else:
|
||||||
|
return "No channels/users are currently ignored."
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(adminonly=True)
|
||||||
|
def ignore(inp, input=None, notice=None):
|
||||||
|
".ignore <channel/user> -- Makes the bot ignore <channel/user>."
|
||||||
|
target = inp
|
||||||
|
|
||||||
|
if is_ignored(target):
|
||||||
|
notice("%s is already ignored." % target)
|
||||||
|
else:
|
||||||
|
ignore_target(target)
|
||||||
|
notice("%s has been ignored." % target)
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command(adminonly=True)
|
||||||
|
def unignore(inp, input=None, notice=None):
|
||||||
|
".unignore <channel/user> -- Makes the bot listen to <channel/user>."
|
||||||
|
target = inp
|
||||||
|
|
||||||
|
if is_ignored(target):
|
||||||
|
unignore_target(target)
|
||||||
|
notice("%s has been unignored." % target)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
notice("%s is not ignored." % target)
|
||||||
|
return
|
|
@ -1,73 +0,0 @@
|
||||||
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 channels/users."
|
|
||||||
if muted:
|
|
||||||
return "Muted channels/users are: " + ", ".join(muted)
|
|
||||||
else:
|
|
||||||
return "No channels/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
|
|
Reference in a new issue