Пример #1
0
def sendTweets():
	global options, db
#	search the db for the weeks happiest news
#	$UTC = getUTCByDateAndTimezone(date('Y-m-d H:i:s', strtotime('-7 days')), "Australia/Sydney");	
#	$SELECT = "
#		$S
#		FROM articles 
#		LEFT JOIN ratings_1 ON articles.id = ratings_1.id 
#		WHERE articles.date_utc > date('$UTC') 
#		ORDER BY ratings_1.q4 DESC
#		LIMIT 1
#	";
#	$results3 = $db->query($SELECT);

#	the_date = datetime.today() - timedelta(days=7)
#	one_week_ago = getUTCDate(time.strftime('%Y-%m-%d %H:%M:%S', the_date.timetuple()), "Australia/Sydney")

#	query = 'SELECT articles.title, articles.link, articles.id FROM articles LEFT JOIN ratings_1 ON articles.id = ratings_1.id WHERE date(articles.date_utc) > "%s" ORDER BY ratings_1.q4 DESC LIMIT 1' % (one_week_ago)

#	from pysqlite2 import dbapi2 as sqlite
#	db = sqlite.connect('door_wordlist.db')
#	cursor = db.cursor()

#	cursor.execute(query)
#	item = cursor.fetchone()

#	d7_q4 = db.getStrongestResult(7, 4)
	d7_q4 = db.getStrongestMood(7, 'happy')
#	d7_q4 = db.getStrongestMoods(7, 'happy', 3)
	item = d7_q4
	
	print item
	
#	if we've already announced the joyous news do nothing
	last_update = libs.utils.get_option('last_update')
#	last_update = '' 
	print last_update
	
	if last_update == item[4]:
		print "Already sent"
		return
	else:
		print "New update %d" % item[4]

#	otherwise continue on and send updates
		from libs.services._twitter import Tweet
		tweet = Tweet()
#	update our followers first
		tweet.updateFollowing()

#	create a short url pointing to the original article
		url = tweet.ShortenUrl(item[1], 'trim').strip()
		print url
	
#	determine any hashtags to use
		title = item[0]
	
		max_length = 140
#	trim the title if necessary
		if len(title) + len(url) >= max_length:
			print 'Trim required.'
			title = title[:max_length-len(url)-1]
	
		msg = "%s %s" % (title, url)
		print "%s [%d]" % (msg, len(msg))
			
		tweet.setMessage(msg)
		tweet.send()	
		libs.utils.set_option('last_update', item[4])		
Пример #2
0
def sendTweets():
    global options, db
    #	search the db for the weeks happiest news
    #	$UTC = getUTCByDateAndTimezone(date('Y-m-d H:i:s', strtotime('-7 days')), "Australia/Sydney");
    #	$SELECT = "
    #		$S
    #		FROM articles
    #		LEFT JOIN ratings_1 ON articles.id = ratings_1.id
    #		WHERE articles.date_utc > date('$UTC')
    #		ORDER BY ratings_1.q4 DESC
    #		LIMIT 1
    #	";
    #	$results3 = $db->query($SELECT);

    #	the_date = datetime.today() - timedelta(days=7)
    #	one_week_ago = getUTCDate(time.strftime('%Y-%m-%d %H:%M:%S', the_date.timetuple()), "Australia/Sydney")

    #	query = 'SELECT articles.title, articles.link, articles.id FROM articles LEFT JOIN ratings_1 ON articles.id = ratings_1.id WHERE date(articles.date_utc) > "%s" ORDER BY ratings_1.q4 DESC LIMIT 1' % (one_week_ago)

    #	from pysqlite2 import dbapi2 as sqlite
    #	db = sqlite.connect('door_wordlist.db')
    #	cursor = db.cursor()

    #	cursor.execute(query)
    #	item = cursor.fetchone()

    #	d7_q4 = db.getStrongestResult(7, 4)
    d7_q4 = db.getStrongestMood(7, 'happy')
    #	d7_q4 = db.getStrongestMoods(7, 'happy', 3)
    item = d7_q4

    print item

    #	if we've already announced the joyous news do nothing
    last_update = libs.utils.get_option('last_update')
    #	last_update = ''
    print last_update

    if last_update == item[4]:
        print "Already sent"
        return
    else:
        print "New update %d" % item[4]

        #	otherwise continue on and send updates
        from libs.services._twitter import Tweet
        tweet = Tweet()
        #	update our followers first
        tweet.updateFollowing()

        #	create a short url pointing to the original article
        url = tweet.ShortenUrl(item[1], 'trim').strip()
        print url

        #	determine any hashtags to use
        title = item[0]

        max_length = 140
        #	trim the title if necessary
        if len(title) + len(url) >= max_length:
            print 'Trim required.'
            title = title[:max_length - len(url) - 1]

        msg = "%s %s" % (title, url)
        print "%s [%d]" % (msg, len(msg))

        tweet.setMessage(msg)
        tweet.send()
        libs.utils.set_option('last_update', item[4])
Пример #3
0
def updateTwitterFollowing():
	from libs.services._twitter import Tweet
	tweet = Tweet()
	print tweet.updateFollowing()
Пример #4
0
def updateTwitterFollowing():
    from libs.services._twitter import Tweet
    tweet = Tweet()
    print tweet.updateFollowing()