Permalink
Browse files

fix: split url in url_title

  • Loading branch information...
disabler committed May 4, 2013
1 parent 81083a0 commit ff56d80d19bf50bc78b2927a16b140fcf80216ee
Showing with 9 additions and 19 deletions.
  1. +2 −2 kernel.py
  2. +5 −15 plugins/main.py
  3. +2 −2 plugins/www.py
@@ -1462,8 +1462,8 @@ def presenceCB(sess,mess):
cur_execute('insert into first_join values (%s,%s,%s);', (room,jid,tt))

def onoff_no_tr(msg):
if msg == None or msg == False or msg == 0 or msg == '0': return 'off'
elif msg == True or msg == 1 or msg == '1': return 'on'
if msg in [None,False,0,'0']: return 'off'
elif msg in [True,1,'1']: return 'on'
else: return msg

def onoff(msg): return L(onoff_no_tr(msg))
@@ -538,18 +538,18 @@ def un_unix(val):
day_h,day_l = tt[2]/10%10,tt[2] % 10
if day_h == 1: ret = L('%s days, %s') % (tt[2],ret)
else:
if day_l in [5,6,7,8,9]: ret = L('%s days, %s') % (tt[2],ret)
elif day_l in [2,3,4]: ret = L('%s Days, %s').lower() % (tt[2],ret)
if day_l in xrange(5,10): ret = L('%s days, %s') % (tt[2],ret)
elif day_l in xrange(2,5): ret = L('%s Days, %s').lower() % (tt[2],ret)
elif day_l == 1: ret = L('%s day, %s') % (tt[2],ret)
if sum(tt[:2]):
if tt[1] in [5,6,7,8,9,10,11,12]: ret = L('%s months, %s') % (tt[1],ret)
elif tt[1] in [2,3,4]: ret = L('%s Months, %s').lower() % (tt[1],ret)
if tt[1] in xrange(5,13): ret = L('%s months, %s') % (tt[1],ret)
elif tt[1] in xrange(2,5): ret = L('%s Months, %s').lower() % (tt[1],ret)
elif tt[1] == 1: ret = L('%s month, %s') % (tt[1],ret)
if tt[0]:
ty = tt[0] % 100
if ty >= 20: ty = ty % 10
if ty in [0]+range(5,21): ret = L('%s years, %s') % (tt[0],ret)
elif ty in [2,3,4]: ret = L('%s Years, %s').lower() % (tt[0],ret)
elif ty in xrange(2,5): ret = L('%s Years, %s').lower() % (tt[0],ret)
else: ret = L('%s year, %s') % (tt[0],ret)
return ret

@@ -566,15 +566,13 @@ def close_age():
tt = int(time.time())
for ab in ccu: cur_execute('insert into age values (%s,%s,%s,%s,%s,%s,%s,%s,%s)', (ab[0],ab[1],ab[2],tt,ab[4]+(tt-ab[3]),1,ab[6],ab[7],ab[1].lower()))


def close_age_room(room):
cur_execute('delete from age where jid ilike %s',('<temporary>%',))
ccu = cur_execute_fetchall('select * from age where status=%s and room=%s order by room',(0,room))
cur_execute('delete from age where status=%s and room=%s',(0,room))
tt = int(time.time())
for ab in ccu: cur_execute('insert into age values (%s,%s,%s,%s,%s,%s,%s,%s,%s)', (ab[0],ab[1],ab[2],tt,ab[4]+(tt-ab[3]),1,ab[6],ab[7],ab[1].lower()))


def sfind(mass,stri):
for a in mass:
if stri in a: return a
@@ -1070,12 +1068,6 @@ def info(type, jid, nick):
msg += L('\nUsed virtual ram: %s, Used real ram: %s','%s/%s'%(jid,nick)) % memstat
send_msg(type, jid, nick, msg)

# 0 - конфа
# 1 - ник
# 2 - роль
# 3 - аффиляция
# 4 - jid

def info_base(type, jid, nick):
msg = L('What need find?','%s/%s'%(jid,nick))
if nick != '':
@@ -1254,8 +1246,6 @@ def html_encode(body):
try: return smart_encode(body,enc)
except: return L('Encoding error!')

#[room, nick, role, affiliation, jid]

def rss_flush(jid,link,break_point):
tstop = cur_execute_fetchone('select hash from feed where room=%s and url=%s',(jid,link))
if tstop: tstop = tstop[0] if base_type == 'pgsql' else eval(tstop[0])
@@ -141,7 +141,7 @@ def parse_url_in_message(room,jid,nick,type,text):
for t in text.split():
link = re.findall(r'(http[s]?://.*)',t)
if link:
link = link[0].split(' ')[0]
link = link[0].split(' ')[0].split('"')[0].split('\'')[0]
if not cur_execute_fetchone('select * from url where room=%s and jid=%s and url=%s',(room,rjid,link)):
ttext = get_content_title(link)
if ttext:
@@ -167,7 +167,7 @@ def parse_url_in_message(room,jid,nick,type,text):
was_shown = False
if get_config(getRoom(room),'url_title'):
try:
link = re.findall(r'(http[s]?://.*)',text)[0].split(' ')[0]
link = re.findall(r'(http[s]?://.*)',text)[0].split(' ')[0].split('"')[0].split('\'')[0]
if link and last_url_watch != link and pasteurl not in link:
if content_title and content_title[0] == link: ttext = content_title[1]
else: ttext = get_content_title(link)

0 comments on commit ff56d80

Please sign in to comment.