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]
|
2013-08-06 12:31:06 +02:00
|
|
|
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]
|
2013-08-06 12:31:06 +02:00
|
|
|
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-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):
|
2012-05-16 05:07:27 +02:00
|
|
|
"ban [channel] <user> -- Makes the bot ban <user> in [channel]. "\
|
2012-04-02 06:30:04 +02:00
|
|
|
"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):
|
2012-05-16 05:07:27 +02:00
|
|
|
"unban [channel] <user> -- Makes the bot unban <user> in [channel]. "\
|
2012-04-02 06:30:04 +02:00
|
|
|
"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):
|
|
|
|
"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."
|
|
|
|
mode_cmd("+q", "quiet", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_quiet", "op"])
|
|
|
|
def unquiet(inp, conn=None, chan=None, notice=None):
|
|
|
|
"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."
|
|
|
|
mode_cmd("-q", "unquiet", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_voice", "op"])
|
|
|
|
def voice(inp, conn=None, chan=None, notice=None):
|
|
|
|
"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."
|
|
|
|
mode_cmd("+v", "voice", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_voice", "op"])
|
|
|
|
def devoice(inp, conn=None, chan=None, notice=None):
|
|
|
|
"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."
|
|
|
|
mode_cmd("-v", "devoice", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_op", "op"])
|
|
|
|
def op(inp, conn=None, chan=None, notice=None):
|
|
|
|
"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."
|
|
|
|
mode_cmd("+o", "op", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_op", "op"])
|
|
|
|
def deop(inp, conn=None, chan=None, notice=None):
|
|
|
|
"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."
|
|
|
|
mode_cmd("-o", "deop", inp, chan, conn, notice)
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command(permissions=["op_topic", "op"])
|
|
|
|
def topic(inp, conn=None, chan=None):
|
|
|
|
"topic [channel] <topic> -- Change the topic of a channel."
|
|
|
|
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):
|
|
|
|
"kick [channel] <user> [reason] -- Makes the bot kick <user> in [channel] "\
|
|
|
|
"If [channel] is blank the bot will kick the <user> in "\
|
2012-04-02 06:30:04 +02:00
|
|
|
"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:])
|
|
|
|
out = "KICK {} {}: {}".format(channel, target, reason)
|
|
|
|
else:
|
|
|
|
out = "KICK {} {}".format(channel, target)
|
|
|
|
|
|
|
|
notice("Attempting to kick {} from {}...".format(target, channel))
|
2013-08-06 12:31:06 +02:00
|
|
|
conn.send(out)
|
2013-08-10 00:23:16 +02:00
|
|
|
|
|
|
|
@hook.command(permissions=["op_rem", "op"])
|
|
|
|
def remove(inp, chan=None, conn=None, notice=None):
|
|
|
|
"remove [channel] [user] -- Force a user to part from a channel."
|
|
|
|
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)
|