2012-03-12 12:26:01 +01:00
|
|
|
# Plugin made by iloveportalz0r, TheNoodle, Lukeroge and neersighted
|
2011-11-20 10:23:31 +01:00
|
|
|
from util import hook
|
2012-03-01 23:17:12 +01:00
|
|
|
import os
|
2012-02-29 06:09:40 +01:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import time
|
2012-03-12 22:18:51 +01:00
|
|
|
import re
|
2012-02-29 06:09:40 +01:00
|
|
|
|
2012-03-12 07:24:52 +01:00
|
|
|
|
2012-03-12 07:33:55 +01:00
|
|
|
@hook.command(autohelp=False)
|
|
|
|
def admins(inp, bot=None):
|
2012-03-13 19:53:04 +01:00
|
|
|
".admins -- Lists the bot's admins."
|
2012-03-12 10:36:09 +01:00
|
|
|
admins = bot.config["admins"]
|
|
|
|
return ", ".join(admins)
|
2012-03-23 01:22:23 +01:00
|
|
|
|
2012-03-19 12:14:20 +01:00
|
|
|
|
|
|
|
@hook.command(autohelp=False)
|
|
|
|
def channels(inp, conn=None):
|
|
|
|
".channels -- Lists the channels that the bot is in."
|
2012-03-23 06:08:58 +01:00
|
|
|
return "I am in these channels: " + ", ".join(conn.channels)
|
2012-03-12 07:24:52 +01:00
|
|
|
|
|
|
|
|
2012-03-12 22:43:28 +01:00
|
|
|
@hook.command(autohelp=False, adminonly=True)
|
2012-03-23 06:08:58 +01:00
|
|
|
def stop(inp, nick=None, conn=None):
|
2012-03-12 21:31:41 +01:00
|
|
|
".stop [reason] -- Kills the bot with [reason] as its quit message."
|
2012-02-26 07:47:13 +01:00
|
|
|
if inp:
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.cmd("QUIT", ["Killed by %s (%s)" % (nick, inp)])
|
2012-02-26 07:47:13 +01:00
|
|
|
else:
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.cmd("QUIT", ["Killed by %s." % nick])
|
2012-03-01 22:52:09 +01:00
|
|
|
time.sleep(5)
|
2012-03-12 07:33:55 +01:00
|
|
|
subprocess.call("./cloudbot stop", shell=True)
|
2012-02-29 06:09:40 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command("reboot", autohelp=False, adminonly=True)
|
|
|
|
@hook.command(autohelp=False, adminonly=True)
|
2012-03-19 12:14:20 +01:00
|
|
|
def restart(inp, input=None):
|
2012-03-12 21:31:41 +01:00
|
|
|
".restart [reason] -- Restarts the bot with [reason] as its quit message."
|
2012-02-28 09:34:04 +01:00
|
|
|
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-03-01 22:52:09 +01:00
|
|
|
time.sleep(5)
|
2012-03-01 23:17:12 +01:00
|
|
|
os.execl("./cloudbot", "restart")
|
2012-02-29 06:09:40 +01:00
|
|
|
|
2012-03-12 12:25:38 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(autohelp=False, adminonly=True)
|
2012-03-23 06:08:58 +01:00
|
|
|
def clearlogs(inp, input=None):
|
|
|
|
".clearlogs -- Clears the bots log(s)."
|
2012-03-12 07:33:55 +01:00
|
|
|
subprocess.call("./cloudbot clear", shell=True)
|
2012-02-29 21:00:10 +01:00
|
|
|
|
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-25 04:15:11 +02:00
|
|
|
def join(inp, conn=None, notice=None):
|
|
|
|
".join <channel> -- Joins <channel>."
|
2011-11-20 15:06:44 +01:00
|
|
|
notice("Attempting to join " + inp + "...")
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.cmd("JOIN", [inp])
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-26 07:47:13 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-23 06:08:58 +01:00
|
|
|
def cycle(inp, conn=None, notice=None):
|
2012-03-25 04:15:11 +02:00
|
|
|
".cycle <channel> -- Cycles <channel>."
|
2011-11-20 15:06:44 +01:00
|
|
|
notice("Attempting to cycle " + inp + "...")
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.cmd("PART", [inp])
|
|
|
|
conn.cmd("JOIN", [inp])
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-23 06:08:58 +01:00
|
|
|
def part(inp, conn=None, notice=None):
|
2012-03-25 04:15:11 +02:00
|
|
|
".part <channel> -- Parts from <channel>."
|
2011-11-20 15:06:44 +01:00
|
|
|
notice("Attempting to part from " + inp + "...")
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.cmd("PART", [inp])
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-12 22:07:32 +01:00
|
|
|
def nick(inp, input=None, notice=None, set_nick=None):
|
2012-02-28 03:03:43 +01:00
|
|
|
".nick <nick> -- Changes the bots nickname to <nick>."
|
2012-03-12 22:18:51 +01:00
|
|
|
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
|
|
|
notice("Invalid username!")
|
|
|
|
return
|
2012-03-19 12:14:20 +01:00
|
|
|
notice("Attempting to change nick to " + inp + ".")
|
2012-03-12 22:07:32 +01:00
|
|
|
set_nick(inp)
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-23 06:08:58 +01:00
|
|
|
def raw(inp, conn=None, notice=None):
|
2012-02-28 03:03:43 +01:00
|
|
|
".raw <command> -- Sends a RAW IRC command."
|
2011-11-20 10:23:31 +01:00
|
|
|
notice("Raw command sent.")
|
2012-03-23 06:08:58 +01:00
|
|
|
conn.send(inp)
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-26 12:18:19 +02:00
|
|
|
def kick(inp, chan=None, conn=None, notice=None):
|
2012-03-25 04:15:11 +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."
|
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
|
|
|
user = split[0]
|
2012-03-26 12:18:19 +02:00
|
|
|
out = "KICK %s %s" % (chan, split[0])
|
2012-02-19 19:10:57 +01:00
|
|
|
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))
|
2012-03-25 04:15:11 +02:00
|
|
|
conn.send(out)
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-26 12:18:19 +02:00
|
|
|
def say(inp, conn=None, chan=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-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-03-26 12:18:19 +02:00
|
|
|
out = "PRIVMSG %s :%s" % (chan, message)
|
2012-03-25 04:15:11 +02:00
|
|
|
conn.send(out)
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command("me", adminonly=True)
|
|
|
|
@hook.command(adminonly=True)
|
2012-03-26 12:18:19 +02:00
|
|
|
def act(inp, conn=None, chan=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-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-03-25 04:15:11 +02:00
|
|
|
conn.send(out)
|
2012-02-19 03:20:25 +01:00
|
|
|
|
2012-02-29 06:15:35 +01:00
|
|
|
|
2012-03-12 21:31:41 +01:00
|
|
|
@hook.command(adminonly=True)
|
2012-03-26 12:18:19 +02:00
|
|
|
def topic(inp, conn=None, chan=None, notice=None):
|
2012-02-28 03:03:43 +01:00
|
|
|
".topic [channel] <topic> -- Change the topic of a channel."
|
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)
|