def tl_command(self, message=None): """Handles /tl (timeline) requests.""" email = self.has_service(message, 'Twitter') if email is None: return consumer_key, consumer_secret = datastore.get_oauth_consumer('t_') oauth_token, oauth_token_secret = datastore.get_oauth_token_and_secret(email, 'Twitter') t = twitter.TwitterAPI(consumer_key, consumer_secret, oauth_token, oauth_token_secret) response = t.statuses_home_timeline() if response.status_code == 200: message.reply(response.content) else: message.reply(error.response_error(response, 'Twitter'))
def t_command(self, message=None): """Handles /t (twitter) requests.""" email = self.has_service(message, 'Twitter') if email is None: return consumer_key, consumer_secret = datastore.get_oauth_consumer('t_') oauth_token, oauth_token_secret = datastore.get_oauth_token_and_secret(email, 'Twitter') t = twitter.TwitterAPI(consumer_key, consumer_secret, oauth_token, oauth_token_secret) response = t.statuses_update(message.arg) if response.status_code == 200: message.reply("Your tweet has sended.") else: message.reply(error.response_error(response, "Twitter"))
def get(self): callback_url = "http://buzzingcat.appspot.com/callback/t" consumer_key, consumer_secret = datastore.get_oauth_consumer('t_') t = oauth.TwitterClient(consumer_key, consumer_secret, callback_url) self.redirect(t.get_authorization_url())