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

184 lines
5.7 KiB
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
# Shitty plugin made by iloveportalz0r
# Broken by The Noodle
# Improved by Lukeroge
2012-02-29 05:54:42 +01:00
# Further improved by neersighted
2011-11-20 10:23:31 +01:00
from util import hook
2012-02-29 06:09:40 +01:00
import sys
import subprocess
import time
2012-02-28 09:34:04 +01:00
@hook.command(autohelp=False)
2012-02-26 07:47:13 +01:00
def quit(inp, input=None, db=None, notice=None):
2012-02-29 06:09:40 +01:00
".quit [reason] -- Kills the bot, with [reason] as its quit message."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2012-02-26 07:47:13 +01:00
notice("Only bot admins can use this command!")
return
if inp:
2012-02-29 06:15:35 +01:00
input.conn.send("QUIT :Killed by " + input.nick + " (" + inp + ")")
2012-02-26 07:47:13 +01:00
else:
2012-02-29 06:15:35 +01:00
input.conn.send("QUIT :Killed by " + input.nick + " (no reason)")
2012-02-26 07:47:13 +01:00
time.sleep(3)
sys.exit()
2012-02-29 06:09:40 +01:00
2012-02-28 09:34:04 +01:00
@hook.command(autohelp=False)
def restart(inp, input=None, db=None, notice=None):
2012-02-29 06:09:40 +01:00
".restart [reason] -- Restarts the bot, with [reason] as its quit message."
2012-02-28 09:34:04 +01:00
if not input.nick in input.bot.config["admins"]:
notice("Only bot admins can use this command!")
return
if inp:
2012-02-29 06:15:35 +01:00
input.conn.send("QUIT :Restarted by " + input.nick + " (" + inp + ")")
2012-02-28 09:34:04 +01:00
else:
2012-02-29 06:15:35 +01:00
input.conn.send("QUIT :Restarted by " + input.nick + " (no reason)")
2012-02-28 09:34:04 +01:00
time.sleep(3)
2012-02-29 05:54:42 +01:00
subprocess.call(['lib/restart.py'])
2012-02-28 09:34:04 +01:00
sys.exit()
2012-02-29 06:09:40 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def join(inp, input=None, db=None, notice=None):
2012-02-28 03:03:43 +01:00
".join <channel> -- Joins <channel>."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2011-11-20 15:06:44 +01:00
notice("Attempting to join " + inp + "...")
2011-11-20 10:23:31 +01:00
input.conn.send("JOIN " + inp)
2012-02-26 07:47:13 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def cycle(inp, input=None, db=None, notice=None):
2012-02-28 03:03:43 +01:00
".cycle <channel> -- Cycles <channel>."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2011-11-20 15:06:44 +01:00
notice("Attempting to cycle " + inp + "...")
2011-11-20 10:23:31 +01:00
input.conn.send("PART " + inp)
input.conn.send("JOIN " + inp)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def part(inp, input=None, notice=None):
2012-02-28 03:03:43 +01:00
".part <channel> -- Parts from <channel>."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2011-11-20 15:06:44 +01:00
notice("Attempting to part from " + inp + "...")
2011-11-20 10:23:31 +01:00
input.conn.send("PART " + inp)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
2012-02-19 03:26:19 +01:00
def nick(inp, input=None, notice=None):
2012-02-28 03:03:43 +01:00
".nick <nick> -- Changes the bots nickname to <nick>."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
notice("Changing nick to " + inp + ".")
input.conn.send("NICK " + inp)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def raw(inp, input=None, notice=None):
2012-02-28 03:03:43 +01:00
".raw <command> -- Sends a RAW IRC command."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
notice("Raw command sent.")
input.conn.send(inp)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def kick(inp, input=None, notice=None):
2012-02-28 03:03:43 +01:00
".kick [channel] <user> [reason] -- kicks a user."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2012-02-19 19:10:57 +01:00
split = inp.split(" ")
if split[0][0] == "#":
chan = split[0]
user = split[1]
out = "KICK %s %s" % (chan, user)
if len(split) > 2:
2011-11-20 10:23:31 +01:00
reason = ""
2012-02-19 19:10:57 +01:00
for x in split[2:]:
2011-11-20 10:23:31 +01:00
reason = reason + x + " "
reason = reason[:-1]
2012-02-29 06:15:35 +01:00
out = out + " :" + reason
2011-11-20 10:23:31 +01:00
else:
2012-02-19 19:10:57 +01:00
chan = input.chan
user = split[0]
out = "KICK %s %s" % (input.chan, split[0])
if len(split) > 1:
2011-11-20 10:23:31 +01:00
reason = ""
2012-02-19 19:10:57 +01:00
for x in split[1:]:
2011-11-20 10:23:31 +01:00
reason = reason + x + " "
reason = reason[:-1]
out = out + " :" + reason
2012-02-19 19:10:57 +01:00
2012-02-29 06:47:11 +01:00
notice("Attempting to kick %s from %s..." % (user, chan))
2011-11-20 10:23:31 +01:00
input.conn.send(out)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def say(inp, input=None, notice=None):
2012-02-29 06:15:35 +01:00
".say [channel] <message> -- Makes the bot say <message> in [channel]. "\
2012-02-29 06:47:11 +01:00
"If [channel] is blank the bot will say the <message> in "\
"the channel the command was used in."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2012-02-19 19:10:57 +01:00
split = inp.split(" ")
if split[0][0] == "#":
2011-11-20 10:23:31 +01:00
message = ""
2012-02-19 19:10:57 +01:00
for x in split[1:]:
2011-11-20 10:23:31 +01:00
message = message + x + " "
message = message[:-1]
2012-02-19 19:10:57 +01:00
out = "PRIVMSG %s :%s" % (split[0], message)
2011-11-20 10:23:31 +01:00
else:
message = ""
2012-02-19 19:10:57 +01:00
for x in split[0:]:
2011-11-20 10:23:31 +01:00
message = message + x + " "
message = message[:-1]
2012-02-19 19:10:57 +01:00
out = "PRIVMSG %s :%s" % (input.chan, message)
2011-11-20 10:23:31 +01:00
input.conn.send(out)
2012-02-29 06:15:35 +01:00
@hook.command("me")
2012-02-19 03:20:25 +01:00
@hook.command
def act(inp, input=None, notice=None):
2012-02-29 06:47:11 +01:00
".act [channel] <action> -- Makes the bot act out <action> in [channel] "\
"If [channel] is blank the bot will act the <action> in "\
"the channel the command was used in."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2012-02-19 03:20:25 +01:00
notice("Only bot admins can use this command!")
return
2012-02-19 19:10:57 +01:00
split = inp.split(" ")
if split[0][0] == "#":
2012-02-19 03:20:25 +01:00
message = ""
2012-02-19 19:10:57 +01:00
for x in split[1:]:
2012-02-19 03:20:25 +01:00
message = message + x + " "
message = message[:-1]
2012-02-19 19:10:57 +01:00
out = "PRIVMSG %s :\x01ACTION %s\x01" % (split[0], message)
2012-02-19 03:20:25 +01:00
else:
message = ""
2012-02-19 19:10:57 +01:00
for x in split[0:]:
2012-02-19 03:20:25 +01:00
message = message + x + " "
message = message[:-1]
2012-02-19 19:10:57 +01:00
out = "PRIVMSG %s :\x01ACTION %s\x01" % (input.chan, message)
2012-02-19 03:20:25 +01:00
input.conn.send(out)
2012-02-29 06:15:35 +01:00
2011-11-20 10:23:31 +01:00
@hook.command
def topic(inp, input=None, notice=None):
2012-02-28 03:03:43 +01:00
".topic [channel] <topic> -- Change the topic of a channel."
2012-02-28 04:22:39 +01:00
if not input.nick in input.bot.config["admins"]:
2011-11-20 10:23:31 +01:00
notice("Only bot admins can use this command!")
return
2012-02-19 19:10:57 +01:00
split = inp.split(" ")
if split[0][0] == "#":
out = "PRIVMSG %s :%s" % (split[0], message)
2011-11-20 10:23:31 +01:00
else:
2012-02-19 19:10:57 +01:00
out = "TOPIC %s :%s" % (input.chan, message)
2011-11-20 10:23:31 +01:00
input.conn.send(out)