add pre: search scene releases, urlhistory: don't alert quoted lines
This commit is contained in:
parent
543ff44995
commit
6824443901
|
@ -0,0 +1,32 @@
|
||||||
|
# searches scene releases using orlydb
|
||||||
|
|
||||||
|
from util import hook, http
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def predb(inp):
|
||||||
|
'.predb <query> -- searches scene releases using orlydb.com'
|
||||||
|
|
||||||
|
try:
|
||||||
|
h = http.get_html("http://orlydb.com/", q=inp)
|
||||||
|
except HTTPError:
|
||||||
|
return 'orlydb seems to be down'
|
||||||
|
|
||||||
|
results = h.xpath("//div[@id='releases']/div/span[@class='release']/..")
|
||||||
|
|
||||||
|
if not results:
|
||||||
|
return "zero results"
|
||||||
|
|
||||||
|
result = results[0]
|
||||||
|
|
||||||
|
date, time = result.xpath("span[@class='timestamp']/text()")[0].split()
|
||||||
|
section, = result.xpath("span[@class='section']//text()")
|
||||||
|
name, = result.xpath("span[@class='release']/text()")
|
||||||
|
|
||||||
|
size = result.xpath("span[@class='inforight']//text()")
|
||||||
|
if size:
|
||||||
|
size = ' :: ' + size[0].split()[0]
|
||||||
|
else:
|
||||||
|
size = ''
|
||||||
|
|
||||||
|
return '%s - %s - %s%s' % (date, section, name, size)
|
|
@ -4,7 +4,6 @@ import time
|
||||||
|
|
||||||
from util import hook, urlnorm, timesince
|
from util import hook, urlnorm, timesince
|
||||||
|
|
||||||
url_re = r'([a-zA-Z]+://|www\.)[^ ]+'
|
|
||||||
|
|
||||||
expiration_period = 60 * 60 * 24 # 1 day
|
expiration_period = 60 * 60 * 24 # 1 day
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ def format_reply(history):
|
||||||
hour_span, nicklist(history), last)
|
hour_span, nicklist(history), last)
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(url_re)
|
@hook.regex(r'([a-zA-Z]+://|www\.)[^ ]+')
|
||||||
def urlinput(match, nick='', chan='', db=None, bot=None):
|
def urlinput(match, nick='', chan='', db=None, bot=None):
|
||||||
db_init(db)
|
db_init(db)
|
||||||
url = urlnorm.normalize(match.group().encode('utf-8'))
|
url = urlnorm.normalize(match.group().encode('utf-8'))
|
||||||
|
@ -72,5 +71,12 @@ def urlinput(match, nick='', chan='', db=None, bot=None):
|
||||||
url = url.decode('utf-8')
|
url = url.decode('utf-8')
|
||||||
history = get_history(db, chan, url)
|
history = get_history(db, chan, url)
|
||||||
insert_history(db, chan, url, nick)
|
insert_history(db, chan, url, nick)
|
||||||
|
|
||||||
|
inp = match.string.lower()
|
||||||
|
|
||||||
|
for name in dict(history):
|
||||||
|
if name.lower() in inp: # person was probably quoting a line
|
||||||
|
return # that had a link. don't remind them.
|
||||||
|
|
||||||
if nick not in dict(history):
|
if nick not in dict(history):
|
||||||
return format_reply(history)
|
return format_reply(history)
|
||||||
|
|
Loading…
Reference in New Issue