示例#1
0
  html=item.getElementsByTagName('description')[0].childNodes[1].data
  html=html2md(html)   
  html=html.encode('ascii','xmlcharrefreplace').decode("utf-8")

  guid.append(fefe_id)
  
  output.append("")
  output[len(output)-1]+="[[l]](" + link + ") "
  output[len(output)-1]+=html
  output[len(output)-1]+="\n"


conn = sqlite3.connect('fefe.db')
c = conn.cursor()
client=Client()

for i in range(len(output)-1,-1,-1):
  c.execute("SELECT post, diasporaid from posts WHERE fefeid=:guid", {"guid":guid[i]})
  post_in_db=c.fetchone()

  # post doesn't exist yet
  if post_in_db==None:
    text=output[i]
    text+="\n\n"
    text+=add_tags(output[i])
    post_id=client.post(text).id
    c.execute("INSERT INTO posts (fefeid,diasporaid,post) values (?,?,?)",(guid[i],post_id,output[i]))
    log_write("New Post: " + str(post_id))

  # post exists but was changed
示例#2
0
#! /usr/bin/env python

from time import gmtime, strftime
from foaas import foaas
from diaspy_client import Client

import config
import re
import urllib2

client = Client()
notify = client.notifications()
for n in notify:
  if not n.unread: continue
  idm = re.search('href=\\"/posts/(\d+?)\\"', n._data['note_html'])

  if (n.type == "mentioned" and hasattr(idm, 'group')):
    post_id = idm.group(1)
    post = client.getPost(post_id)
    text = post._data['text']
    post_notify = re.search('^\s*\@\{[^\};]+;[^\};]+\}\s+(\/.+?)$', text)
    #comment_notify = re.search('^\s*\@\{[^\};]+;[^\};]+\}\s+([\d\w]{32})\s+(\/.+?)$', text)
    comment_notify = re.search('^\s*\@\{[^\};]+;[^\};]+\}\s+([\d]+?)\s+(\/.+?)$', text)
    if hasattr(post_notify, 'group'):
      try:
        command = post_notify.group(1)
        client.post(foaas(command))
      except urllib2.URLError:
        client.comment(id=post_id, text="F**k this! Something went wrong :\\")
    elif hasattr(comment_notify, 'group'):
      try: