Ejemplo n.º 1
0
 def __init__(self, account_name):
     super(TwitterBot, self).__init__()
     self.__app = secrets['twitter']['app']
     self.__account = secrets['twitter']['accounts'][account_name]
     self._api_client = twitter.Api(consumer_key = self.__app['consumer_key'],
                                    consumer_secret = self.__app['consumer_secret'],
                                    access_token_key = self.__account['token_key'],
                                    access_token_secret = self.__account['token_secret'])
     self.user = self._api_client.GetUser(user_id=self.__account['user_id'])
     self.db = TweetDatastore(account_name)
     self.__backfill_db()
Ejemplo n.º 2
0
 def __init__(self, listener_name, query=None):
     super(TwitterListener, self).__init__()
     self.listener_name = listener_name
     self.query = query
     self.__app = secrets['twitter']['app']
     self.__accounts = secrets['twitter']['accounts']
     self.__set_twitter_api_tokens()
     self.db = TweetDatastore(listener_name)
     self.__set_max_id()
Ejemplo n.º 3
0
class TwitterBot(object):
    """docstring for TwitterBot"""
    def __init__(self, account_name):
        super(TwitterBot, self).__init__()
        self.__app = secrets['twitter']['app']
        self.__account = secrets['twitter']['accounts'][account_name]
        self._api_client = twitter.Api(consumer_key = self.__app['consumer_key'],
                                       consumer_secret = self.__app['consumer_secret'],
                                       access_token_key = self.__account['token_key'],
                                       access_token_secret = self.__account['token_secret'])
        self.user = self._api_client.GetUser(user_id=self.__account['user_id'])
        self.db = TweetDatastore(account_name)
        self.__backfill_db()

    def __backfill_db(self):
        try:
            tweets = self._api_client.GetUserTimeline(user_id=self.__account['user_id'], count = 200)
            self.db.store(tweets)
        except Exception, e:
            pass