Esempio n. 1
0
#!/usr/bin/env python2.7
#! -*- coding:utf-8 -*-
from tweepy.streaming import StreamListener
from tweepy import API, OAuthHandler, Stream
import commands
import platform

consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
auth = OAuthHandler(consumer_key, consumer_secret)
auth.access_token = access_token
auth.access_token_secret = access_token_secret
auth.apply_auth()
api = API(auth)

class Commands(StreamListener):

    def post_on_twitter(self, data):
        for i in range(0, int(len(data) / 140) + 1):
            if i == 0:
                first = 140 * i
                last = 140 - (140 * i)
            else:
                first = (140 * (i + 1)) - 140
                last = 140 * (i + 1)
            status = data[first:last]
            if status:
                api.update_status(status=status)