Merge branch 'develop' into refresh
Conflicts: plugins/regex_chans.py
This commit is contained in:
commit
cdc9102694
9 changed files with 108 additions and 34 deletions
38
disabled_stuff/religion.py
Normal file
38
disabled_stuff/religion.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
from util import hook, http
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command('god')
|
||||||
|
@hook.command
|
||||||
|
def bible(inp):
|
||||||
|
""".bible <passage> -- gets <passage> from the Bible (ESV)"""
|
||||||
|
|
||||||
|
base_url = ('http://www.esvapi.org/v2/rest/passageQuery?key=IP&'
|
||||||
|
'output-format=plain-text&include-heading-horizontal-lines&'
|
||||||
|
'include-headings=false&include-passage-horizontal-lines=false&'
|
||||||
|
'include-passage-references=false&include-short-copyright=false&'
|
||||||
|
'include-footnotes=false&line-length=0&'
|
||||||
|
'include-heading-horizontal-lines=false')
|
||||||
|
|
||||||
|
text = http.get(base_url, passage=inp)
|
||||||
|
|
||||||
|
text = ' '.join(text.split())
|
||||||
|
|
||||||
|
if len(text) > 400:
|
||||||
|
text = text[:text.rfind(' ', 0, 400)] + '...'
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command('allah')
|
||||||
|
@hook.command
|
||||||
|
def koran(inp): # Koran look-up plugin by Ghetto Wizard
|
||||||
|
""".koran <chapter.verse> -- gets <chapter.verse> from the Koran"""
|
||||||
|
|
||||||
|
url = 'http://quod.lib.umich.edu/cgi/k/koran/koran-idx?type=simple'
|
||||||
|
|
||||||
|
results = http.get_html(url, q1=inp).xpath('//li')
|
||||||
|
|
||||||
|
if not results:
|
||||||
|
return 'No results for ' + inp
|
||||||
|
|
||||||
|
return results[0].text_content()
|
|
@ -25,10 +25,12 @@ db_ready = False
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
"""check to see that our db has the the encryption table."""
|
"""check to see that our db has the the encryption table."""
|
||||||
db.execute("create table if not exists encryption(encrypted, iv, "
|
global db_ready
|
||||||
"primary key(encrypted))")
|
if not db_ready:
|
||||||
db.commit()
|
db.execute("create table if not exists encryption(encrypted, iv, "
|
||||||
db_ready = True
|
"primary key(encrypted))")
|
||||||
|
db.commit()
|
||||||
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
def get_salt(bot):
|
def get_salt(bot):
|
||||||
|
@ -42,8 +44,7 @@ def get_salt(bot):
|
||||||
@hook.command
|
@hook.command
|
||||||
def encrypt(inp, bot=None, db=None, notice=None):
|
def encrypt(inp, bot=None, db=None, notice=None):
|
||||||
"""encrypt <pass> <string> -- Encrypts <string> with <pass>. (<string> can only be decrypted using this bot)"""
|
"""encrypt <pass> <string> -- Encrypts <string> with <pass>. (<string> can only be decrypted using this bot)"""
|
||||||
if not db_ready:
|
db_init(db)
|
||||||
db_init(db)
|
|
||||||
|
|
||||||
split = inp.split(" ")
|
split = inp.split(" ")
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ from util import hook, http, text, pyexec
|
||||||
|
|
||||||
re_lineends = re.compile(r'[\r\n]*')
|
re_lineends = re.compile(r'[\r\n]*')
|
||||||
|
|
||||||
|
db_ready = False
|
||||||
|
|
||||||
# some simple "shortcodes" for formatting purposes
|
# some simple "shortcodes" for formatting purposes
|
||||||
shortcodes = {
|
shortcodes = {
|
||||||
'[b]': '\x02',
|
'[b]': '\x02',
|
||||||
|
@ -18,9 +20,12 @@ shortcodes = {
|
||||||
|
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
db.execute("create table if not exists mem(word, data, nick,"
|
global db_ready
|
||||||
" primary key(word))")
|
if not db_ready:
|
||||||
db.commit()
|
db.execute("create table if not exists mem(word, data, nick,"
|
||||||
|
" primary key(word))")
|
||||||
|
db.commit()
|
||||||
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
def get_memory(db, word):
|
def get_memory(db, word):
|
||||||
|
|
22
plugins/googleurlparse.py
Normal file
22
plugins/googleurlparse.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from util import hook
|
||||||
|
from urllib import unquote
|
||||||
|
|
||||||
|
@hook.command(autohelp=False)
|
||||||
|
def googleurl(inp, db=None, nick=None):
|
||||||
|
"""googleurl [nickname] - Converts Google urls (google.com/url) to normal urls
|
||||||
|
where possible, in the specified nickname's last message. If nickname isn't provided,
|
||||||
|
action will be performed on user's last message"""
|
||||||
|
if not inp:
|
||||||
|
inp = nick
|
||||||
|
last_message = db.execute("select name, quote from seen_user where name"
|
||||||
|
" like ? and chan = ?", (inp.lower(), input.chan.lower())).fetchone()
|
||||||
|
if last_message:
|
||||||
|
msg = last_message[1]
|
||||||
|
out = ", ".join([(unquote(a[4:]) if a[:4] == "url=" else "") for a in msg.split("&")])\
|
||||||
|
.replace(", ,", "").strip()
|
||||||
|
return out if out else "No matches in your last message."
|
||||||
|
else:
|
||||||
|
if inp == nick:
|
||||||
|
return "You haven't said anything in this channel yet!"
|
||||||
|
else:
|
||||||
|
return "That user hasn't said anything in this channel yet!"
|
|
@ -7,17 +7,17 @@ db_ready = False
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
"""check to see that our db has the horoscope table and return a connection."""
|
"""check to see that our db has the horoscope table and return a connection."""
|
||||||
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
global db_ready
|
||||||
db.commit()
|
if not db_ready:
|
||||||
db_ready = True
|
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
||||||
|
db.commit()
|
||||||
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def horoscope(inp, db=None, notice=None, nick=None):
|
def horoscope(inp, db=None, notice=None, nick=None):
|
||||||
"""horoscope <sign> -- Get your horoscope."""
|
"""horoscope <sign> -- Get your horoscope."""
|
||||||
|
db_init(db)
|
||||||
if not db_ready:
|
|
||||||
db_init(db)
|
|
||||||
|
|
||||||
# check if the user asked us not to save his details
|
# check if the user asked us not to save his details
|
||||||
dontsave = inp.endswith(" dontsave")
|
dontsave = inp.endswith(" dontsave")
|
||||||
|
@ -32,16 +32,16 @@ def horoscope(inp, db=None, notice=None, nick=None):
|
||||||
sign = db.execute("select sign from horoscope where nick=lower(?)",
|
sign = db.execute("select sign from horoscope where nick=lower(?)",
|
||||||
(nick,)).fetchone()
|
(nick,)).fetchone()
|
||||||
if not sign:
|
if not sign:
|
||||||
notice(horoscope.__doc__)
|
notice("horoscope <sign> -- Get your horoscope")
|
||||||
return
|
return
|
||||||
sign = sign[0]
|
sign = sign[0]
|
||||||
|
|
||||||
url = "http://my.horoscope.com/astrology/free-daily-horoscope-%s.html" % sign
|
url = "http://my.horoscope.com/astrology/free-daily-horoscope-{}.html".format(sign)
|
||||||
soup = http.get_soup(url)
|
soup = http.get_soup(url)
|
||||||
|
|
||||||
title = soup.find_all('h1', {'class': 'h1b'})[1]
|
title = soup.find_all('h1', {'class': 'h1b'})[1]
|
||||||
horoscope = soup.find('div', {'class': 'fontdef1'})
|
horoscope_text = soup.find('div', {'class': 'fontdef1'})
|
||||||
result = "\x02%s\x02 %s" % (title, horoscope)
|
result = u"\x02%s\x02 %s" % (title, horoscope_text)
|
||||||
result = text.strip_html(result)
|
result = text.strip_html(result)
|
||||||
#result = unicode(result, "utf8").replace('flight ','')
|
#result = unicode(result, "utf8").replace('flight ','')
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import re
|
||||||
from util import hook
|
from util import hook
|
||||||
|
|
||||||
|
|
||||||
db_inited = False
|
db_ready = False
|
||||||
|
|
||||||
|
|
||||||
def clean_sql(sql):
|
def clean_sql(sql):
|
||||||
|
@ -11,8 +11,8 @@ def clean_sql(sql):
|
||||||
|
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
global db_inited
|
global db_ready
|
||||||
if db_inited:
|
if db_ready:
|
||||||
return
|
return
|
||||||
|
|
||||||
exists = db.execute("""
|
exists = db.execute("""
|
||||||
|
@ -32,7 +32,7 @@ def db_init(db):
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
db_inited = True
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
def db_getall(db, nick, limit=-1):
|
def db_getall(db, nick, limit=-1):
|
||||||
|
|
|
@ -11,10 +11,12 @@ db_ready = False
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
"""check to see that our db has the the seen table and return a connection."""
|
"""check to see that our db has the the seen table and return a connection."""
|
||||||
db.execute("create table if not exists seen_user(name, time, quote, chan, host, "
|
global db_ready
|
||||||
"primary key(name, chan))")
|
if not db_ready:
|
||||||
db.commit()
|
db.execute("create table if not exists seen_user(name, time, quote, chan, host, "
|
||||||
db_ready = True
|
"primary key(name, chan))")
|
||||||
|
db.commit()
|
||||||
|
db_ready = True
|
||||||
|
|
||||||
|
|
||||||
@hook.singlethread
|
@hook.singlethread
|
||||||
|
|
|
@ -6,13 +6,17 @@ import re
|
||||||
|
|
||||||
from util import hook, timesince
|
from util import hook, timesince
|
||||||
|
|
||||||
|
db_ready = False
|
||||||
|
|
||||||
def db_init(db):
|
def db_init(db):
|
||||||
"""check to see that our db has the tell table and return a dbection."""
|
"""check to see that our db has the tell table and return a dbection."""
|
||||||
db.execute("create table if not exists tell"
|
global db_ready
|
||||||
"(user_to, user_from, message, chan, time,"
|
if not db_ready:
|
||||||
"primary key(user_to, message))")
|
db.execute("create table if not exists tell"
|
||||||
db.commit()
|
"(user_to, user_from, message, chan, time,"
|
||||||
|
"primary key(user_to, message))")
|
||||||
|
db.commit()
|
||||||
|
db_ready = True
|
||||||
|
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from util import hook, http
|
||||||
|
|
||||||
|
|
||||||
xkcd_re = (r'(.*:)//(www.xkcd.com|xkcd.com)(.*)', re.I)
|
xkcd_re = (r'(.*:)//(www.xkcd.com|xkcd.com)(.*)', re.I)
|
||||||
months = {'1': 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'August',
|
months = {1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'August',
|
||||||
9: 'September', 10: 'October', 11: 'November', 12: 'December'}
|
9: 'September', 10: 'October', 11: 'November', 12: 'December'}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,13 +17,15 @@ def xkcd_info(xkcd_id, url=False):
|
||||||
return "xkcd: \x02%s\x02 (%s)%s" % (data['title'], date, url if url else "")
|
return "xkcd: \x02%s\x02 (%s)%s" % (data['title'], date, url if url else "")
|
||||||
|
|
||||||
|
|
||||||
def xkcd_search(inp):
|
def xkcd_search(term):
|
||||||
|
search_term = http.quote_plus(term)
|
||||||
soup = http.get_soup("http://www.ohnorobot.com/index.pl?s={}&Search=Search&"
|
soup = http.get_soup("http://www.ohnorobot.com/index.pl?s={}&Search=Search&"
|
||||||
"comic=56&e=0&n=0&b=0&m=0&d=0&t=0".format(inp))
|
"comic=56&e=0&n=0&b=0&m=0&d=0&t=0".format(search_term))
|
||||||
result = soup.find('li')
|
result = soup.find('li')
|
||||||
if result:
|
if result:
|
||||||
url = result.find('div', {'class': 'tinylink'}).text
|
url = result.find('div', {'class': 'tinylink'}).text
|
||||||
xkcd_id = url[:-1].split("/")[-1]
|
xkcd_id = url[:-1].split("/")[-1]
|
||||||
|
print xkcd_id
|
||||||
return xkcd_info(xkcd_id, url=True)
|
return xkcd_info(xkcd_id, url=True)
|
||||||
else:
|
else:
|
||||||
return "No results found!"
|
return "No results found!"
|
||||||
|
|
Reference in a new issue