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):
|
||||
"""check to see that our db has the the encryption table."""
|
||||
db.execute("create table if not exists encryption(encrypted, iv, "
|
||||
"primary key(encrypted))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists encryption(encrypted, iv, "
|
||||
"primary key(encrypted))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
|
||||
def get_salt(bot):
|
||||
|
@ -42,8 +44,7 @@ def get_salt(bot):
|
|||
@hook.command
|
||||
def encrypt(inp, bot=None, db=None, notice=None):
|
||||
"""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(" ")
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ from util import hook, http, text, pyexec
|
|||
|
||||
re_lineends = re.compile(r'[\r\n]*')
|
||||
|
||||
db_ready = False
|
||||
|
||||
# some simple "shortcodes" for formatting purposes
|
||||
shortcodes = {
|
||||
'[b]': '\x02',
|
||||
|
@ -18,9 +20,12 @@ shortcodes = {
|
|||
|
||||
|
||||
def db_init(db):
|
||||
db.execute("create table if not exists mem(word, data, nick,"
|
||||
" primary key(word))")
|
||||
db.commit()
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists mem(word, data, nick,"
|
||||
" primary key(word))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
|
||||
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):
|
||||
"""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)")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists horoscope(nick primary key, sign)")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def horoscope(inp, db=None, notice=None, nick=None):
|
||||
"""horoscope <sign> -- Get your horoscope."""
|
||||
|
||||
if not db_ready:
|
||||
db_init(db)
|
||||
db_init(db)
|
||||
|
||||
# check if the user asked us not to save his details
|
||||
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(?)",
|
||||
(nick,)).fetchone()
|
||||
if not sign:
|
||||
notice(horoscope.__doc__)
|
||||
notice("horoscope <sign> -- Get your horoscope")
|
||||
return
|
||||
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)
|
||||
|
||||
title = soup.find_all('h1', {'class': 'h1b'})[1]
|
||||
horoscope = soup.find('div', {'class': 'fontdef1'})
|
||||
result = "\x02%s\x02 %s" % (title, horoscope)
|
||||
horoscope_text = soup.find('div', {'class': 'fontdef1'})
|
||||
result = u"\x02%s\x02 %s" % (title, horoscope_text)
|
||||
result = text.strip_html(result)
|
||||
#result = unicode(result, "utf8").replace('flight ','')
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import re
|
|||
from util import hook
|
||||
|
||||
|
||||
db_inited = False
|
||||
db_ready = False
|
||||
|
||||
|
||||
def clean_sql(sql):
|
||||
|
@ -11,8 +11,8 @@ def clean_sql(sql):
|
|||
|
||||
|
||||
def db_init(db):
|
||||
global db_inited
|
||||
if db_inited:
|
||||
global db_ready
|
||||
if db_ready:
|
||||
return
|
||||
|
||||
exists = db.execute("""
|
||||
|
@ -32,7 +32,7 @@ def db_init(db):
|
|||
|
||||
db.commit()
|
||||
|
||||
db_inited = True
|
||||
db_ready = True
|
||||
|
||||
|
||||
def db_getall(db, nick, limit=-1):
|
||||
|
|
|
@ -11,10 +11,12 @@ db_ready = False
|
|||
|
||||
def db_init(db):
|
||||
"""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, "
|
||||
"primary key(name, chan))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists seen_user(name, time, quote, chan, host, "
|
||||
"primary key(name, chan))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
|
||||
@hook.singlethread
|
||||
|
|
|
@ -6,13 +6,17 @@ import re
|
|||
|
||||
from util import hook, timesince
|
||||
|
||||
db_ready = False
|
||||
|
||||
def db_init(db):
|
||||
"""check to see that our db has the tell table and return a dbection."""
|
||||
db.execute("create table if not exists tell"
|
||||
"(user_to, user_from, message, chan, time,"
|
||||
"primary key(user_to, message))")
|
||||
db.commit()
|
||||
global db_ready
|
||||
if not db_ready:
|
||||
db.execute("create table if not exists tell"
|
||||
"(user_to, user_from, message, chan, time,"
|
||||
"primary key(user_to, message))")
|
||||
db.commit()
|
||||
db_ready = True
|
||||
|
||||
return db
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from util import hook, http
|
|||
|
||||
|
||||
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'}
|
||||
|
||||
|
||||
|
@ -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 "")
|
||||
|
||||
|
||||
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&"
|
||||
"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')
|
||||
if result:
|
||||
url = result.find('div', {'class': 'tinylink'}).text
|
||||
xkcd_id = url[:-1].split("/")[-1]
|
||||
print xkcd_id
|
||||
return xkcd_info(xkcd_id, url=True)
|
||||
else:
|
||||
return "No results found!"
|
||||
|
|
Reference in a new issue