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/op.py

182 lines
6.6 KiB
Python
Raw Normal View History

2012-04-02 05:53:16 +02:00
from util import hook
2012-04-02 06:30:04 +02:00
2013-08-06 00:56:44 +02:00
def mode_cmd(mode, text, inp, chan, conn, notice):
""" generic mode setting function """
split = inp.split(" ")
if split[0].startswith("#"):
channel = split[0]
target = split[1]
notice("Attempting to {} {} in {}...".format(text, target, channel))
2013-08-06 00:56:44 +02:00
conn.send("MODE {} {} {}".format(channel, mode, target))
2012-04-02 05:53:16 +02:00
else:
2013-08-06 00:56:44 +02:00
channel = chan
target = split[0]
notice("Attempting to {} {} in {}...".format(text, target, channel))
2013-08-06 00:56:44 +02:00
conn.send("MODE {} {} {}".format(channel, mode, target))
2012-04-02 05:53:16 +02:00
2013-09-04 12:30:04 +02:00
def mode_cmd_no_target(mode, text, inp, chan, conn, notice):
""" generic mode setting function without a target"""
split = inp.split(" ")
if split[0].startswith("#"):
channel = split[0]
notice("Attempting to {} {}...".format(text, channel))
conn.send("MODE {} {}".format(channel, mode))
else:
channel = chan
notice("Attempting to {} {}...".format(text, channel))
conn.send("MODE {} {}".format(channel, mode))
2013-08-06 00:56:44 +02:00
@hook.command(permissions=["op_ban", "op"])
2012-04-02 06:30:04 +02:00
def ban(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""ban [channel] <user> -- Makes the bot ban <user> in [channel].
If [channel] is blank the bot will ban <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("+b", "ban", inp, chan, conn, notice)
2012-04-02 06:30:04 +02:00
2013-08-06 00:56:44 +02:00
@hook.command(permissions=["op_ban", "op"])
2012-04-02 06:30:04 +02:00
def unban(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""unban [channel] <user> -- Makes the bot unban <user> in [channel].
If [channel] is blank the bot will unban <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("-b", "unban", inp, chan, conn, notice)
@hook.command(permissions=["op_quiet", "op"])
def quiet(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""quiet [channel] <user> -- Makes the bot quiet <user> in [channel].
If [channel] is blank the bot will quiet <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("+q", "quiet", inp, chan, conn, notice)
@hook.command(permissions=["op_quiet", "op"])
def unquiet(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""unquiet [channel] <user> -- Makes the bot unquiet <user> in [channel].
If [channel] is blank the bot will unquiet <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("-q", "unquiet", inp, chan, conn, notice)
@hook.command(permissions=["op_voice", "op"])
def voice(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""voice [channel] <user> -- Makes the bot voice <user> in [channel].
If [channel] is blank the bot will voice <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("+v", "voice", inp, chan, conn, notice)
@hook.command(permissions=["op_voice", "op"])
def devoice(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""devoice [channel] <user> -- Makes the bot devoice <user> in [channel].
If [channel] is blank the bot will devoice <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("-v", "devoice", inp, chan, conn, notice)
@hook.command(permissions=["op_op", "op"])
def op(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""op [channel] <user> -- Makes the bot op <user> in [channel].
If [channel] is blank the bot will op <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("+o", "op", inp, chan, conn, notice)
@hook.command(permissions=["op_op", "op"])
def deop(inp, conn=None, chan=None, notice=None):
2013-09-04 12:30:04 +02:00
"""deop [channel] <user> -- Makes the bot deop <user> in [channel].
If [channel] is blank the bot will deop <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
mode_cmd("-o", "deop", inp, chan, conn, notice)
@hook.command(permissions=["op_topic", "op"])
def topic(inp, conn=None, chan=None):
2013-09-04 12:30:04 +02:00
"""topic [channel] <topic> -- Change the topic of a channel."""
2013-08-06 00:56:44 +02:00
split = inp.split(" ")
if split[0].startswith("#"):
message = " ".join(split[1:])
chan = split[0]
out = "TOPIC {} :{}".format(chan, message)
2012-04-02 06:30:04 +02:00
else:
2013-08-06 00:56:44 +02:00
message = " ".join(split)
out = "TOPIC {} :{}".format(chan, message)
2012-04-02 06:30:04 +02:00
conn.send(out)
2012-04-02 18:17:55 +02:00
2013-08-06 00:56:44 +02:00
@hook.command(permissions=["op_kick", "op"])
def kick(inp, chan=None, conn=None, notice=None):
2013-09-04 12:30:04 +02:00
"""kick [channel] <user> [reason] -- Makes the bot kick <user> in [channel]
If [channel] is blank the bot will kick the <user> in
the channel the command was used in."""
2013-08-06 00:56:44 +02:00
split = inp.split(" ")
if split[0].startswith("#"):
channel = split[0]
target = split[1]
if len(split) > 2:
reason = " ".join(split[2:])
out = "KICK {} {}: {}".format(channel, target, reason)
else:
out = "KICK {} {}".format(channel, target)
2012-04-02 06:30:04 +02:00
else:
2013-08-06 00:56:44 +02:00
channel = chan
target = split[0]
if len(split) > 1:
reason = " ".join(split[1:])
2013-09-05 00:30:58 +02:00
out = "KICK {} {} :{}".format(channel, target, reason)
2013-08-06 00:56:44 +02:00
else:
out = "KICK {} {}".format(channel, target)
notice("Attempting to kick {} from {}...".format(target, channel))
conn.send(out)
2013-08-10 00:23:16 +02:00
2013-09-04 12:30:04 +02:00
2013-08-10 00:23:16 +02:00
@hook.command(permissions=["op_rem", "op"])
2013-09-04 12:30:04 +02:00
def remove(inp, chan=None, conn=None):
"""remove [channel] [user] -- Force a user to part from a channel."""
2013-08-10 00:23:16 +02:00
split = inp.split(" ")
if split[0].startswith("#"):
message = " ".join(split[1:])
chan = split[0]
out = "REMOVE {} :{}".format(chan, message)
else:
message = " ".join(split)
out = "REMOVE {} :{}".format(chan, message)
conn.send(out)
@hook.command(permissions=["op_mute", "op"], autohelp=False)
def mute(inp, conn=None, chan=None, notice=None):
"""mute [channel] -- Makes the bot mute a channel..
If [channel] is blank the bot will mute
the channel the command was used in."""
mode_cmd_no_target("+m", "mute", inp, chan, conn, notice)
@hook.command(permissions=["op_mute", "op"], autohelp=False)
def unmute(inp, conn=None, chan=None, notice=None):
"""mute [channel] -- Makes the bot mute a channel..
If [channel] is blank the bot will mute
the channel the command was used in."""
mode_cmd_no_target("-m", "unmute", inp, chan, conn, notice)
2013-09-05 01:51:42 +02:00
@hook.command(permissions=["op_lock", "op"], autohelp=False)
def lock(inp, conn=None, chan=None, notice=None):
"""lock [channel] -- Makes the bot lock a channel.
If [channel] is blank the bot will mute
the channel the command was used in."""
mode_cmd_no_target("+i", "lock", inp, chan, conn, notice)
2013-09-05 01:51:42 +02:00
@hook.command(permissions=["op_lock", "op"], autohelp=False)
def unlock(inp, conn=None, chan=None, notice=None):
"""unlock [channel] -- Makes the bot unlock a channel..
If [channel] is blank the bot will mute
the channel the command was used in."""
2013-11-12 07:06:06 +01:00
mode_cmd_no_target("-i", "unlock", inp, chan, conn, notice)