This commit is contained in:
neersighted 2012-02-28 21:09:40 -08:00
parent c014d91ec2
commit eec12aa9e4
7 changed files with 28 additions and 18 deletions

View file

@ -38,8 +38,8 @@ if not os.path.exists('config'):
"bitly_api": "INSERT API KEY FROM bitly.com HERE", "bitly_api": "INSERT API KEY FROM bitly.com HERE",
"wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE", "wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE",
"lastfm": "INSERT API KEY FROM lastfm HERE", "lastfm": "INSERT API KEY FROM lastfm HERE",
"mc_user": "INSERT MINECRAFT USERNAME HERE (used to check login servers in mctools.py)", "mc_user": "INSERT MINECRAFT USERNAME HERE",
"mc_pass": "INSERT MINECRAFT PASSWORD HERE (used to check login servers in mctools.py)" "mc_pass": "INSERT MINECRAFT PASSWORD HERE"
}, },
"censored_strings": "censored_strings":
[ [
@ -50,11 +50,11 @@ if not os.path.exists('config'):
}''') + '\n') }''') + '\n')
print "Config generated!" print "Config generated!"
print "Please edit the config now!" print "Please edit the config now!"
print "(The default config will work, but you most likely want to change it)"
print "For help, see http://git.io/cloudbotwiki" print "For help, see http://git.io/cloudbotwiki"
print "Thank you for using CloudBot!" print "Thank you for using CloudBot!"
sys.exit() sys.exit()
def config(): def config():
# reload config from file if file has changed # reload config from file if file has changed
config_mtime = os.stat('config').st_mtime config_mtime = os.stat('config').st_mtime

View file

@ -2,7 +2,8 @@ import os
import sqlite3 import sqlite3
import thread import thread
threaddbs={} threaddbs = {}
def get_db_connection(conn, name=''): def get_db_connection(conn, name=''):
"returns an sqlite3 connection to a persistent database" "returns an sqlite3 connection to a persistent database"

View file

@ -247,4 +247,4 @@ class SSLIRC(IRC):
IRC.__init__(self, server, nick, port, channels, conf) IRC.__init__(self, server, nick, port, channels, conf)
def create_connection(self): def create_connection(self):
return crlf_ssl_tcp(self.server, self.port, self.ignore_cert_errors) return crlf_ssl_tcp(self.server, self.port, self.ignore_cert_errors)

View file

@ -15,7 +15,7 @@ class Input(dict):
def say(msg): def say(msg):
conn.msg(chan, msg) conn.msg(chan, msg)
def pm(msg): def pm(msg):
conn.msg(nick, msg) conn.msg(nick, msg)

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# Tiny little restarter by neersighted # Tiny little restarter by neersighted
import subprocess, sys, os import sys
import os
import subprocess
if os.path.isfile("./control.sh"): if os.path.isfile("./control.sh"):
restart = "./control.sh restart" restart = "./control.sh restart"

View file

@ -27,15 +27,17 @@ answers = [g + "As I see it, yes",
y + "Maybe...", y + "Maybe...",
r + "You're kidding, right?", r + "You're kidding, right?",
r + "Don't count on it", r + "Don't count on it",
r + "In your dreams", r + "In your dreams",
r + "My reply is no", r + "My reply is no",
r + "My sources say no", r + "My sources say no",
r + "Outlook not so good", r + "Outlook not so good",
r + "Very doubtful"] r + "Very doubtful"]
@hook.command('8ball') @hook.command('8ball')
def eightball(inp, me=None): def eightball(inp, me=None):
".8ball <question> -- The all knowing magic eight ball, in electronic form. Ask and it shall be answered!" ".8ball <question> -- The all knowing magic eight ball, "\
"in electronic form. Ask and it shall be answered!"
global nextresponsenumber global nextresponsenumber
inp = inp.strip() inp = inp.strip()
if re.match("[a-zA-Z0-9]", inp[-1]): if re.match("[a-zA-Z0-9]", inp[-1]):

View file

@ -3,35 +3,40 @@
# Improved by Lukeroge # Improved by Lukeroge
# Further improved by neersighted # Further improved by neersighted
from util import hook from util import hook
import sys, subprocess, time import sys
import subprocess
import time
@hook.command(autohelp=False) @hook.command(autohelp=False)
def quit(inp, input=None, db=None, notice=None): def quit(inp, input=None, db=None, notice=None):
".quit [reason] -- Kills the bot, with [reason] reason as its quit message." ".quit [reason] -- Kills the bot, with [reason] as its quit message."
if not input.nick in input.bot.config["admins"]: if not input.nick in input.bot.config["admins"]:
notice("Only bot admins can use this command!") notice("Only bot admins can use this command!")
return return
if inp: if inp:
input.conn.send("QUIT :Bot killed by "+input.nick+" (" + inp + ")") input.conn.send("QUIT :Bot killed by " + input.nick + " (" + inp + ")")
else: else:
input.conn.send("QUIT :Bot killed by "+input.nick+" (no reason)") input.conn.send("QUIT :Bot killed by " + input.nick + " (no reason)")
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@hook.command(autohelp=False) @hook.command(autohelp=False)
def restart(inp, input=None, db=None, notice=None): def restart(inp, input=None, db=None, notice=None):
".restart [reason] -- Restarts the bot, with [reason] reason as its quit message." ".restart [reason] -- Restarts the bot, with [reason] as its quit message."
if not input.nick in input.bot.config["admins"]: if not input.nick in input.bot.config["admins"]:
notice("Only bot admins can use this command!") notice("Only bot admins can use this command!")
return return
if inp: if inp:
input.conn.send("QUIT :Bot restarted by "+input.nick+" (" + inp + ")") input.conn.send("QUIT :Bot restarted by " + input.nick + " (" + inp + ")")
else: else:
input.conn.send("QUIT :Bot restarted by "+input.nick+" (no reason)") input.conn.send("QUIT :Bot restarted by " + input.nick + " (no reason)")
time.sleep(3) time.sleep(3)
subprocess.call(['lib/restart.py']) subprocess.call(['lib/restart.py'])
sys.exit() sys.exit()
@hook.command @hook.command
def join(inp, input=None, db=None, notice=None): def join(inp, input=None, db=None, notice=None):
".join <channel> -- Joins <channel>." ".join <channel> -- Joins <channel>."