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 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 rr_command(self, message=None): """Handles /rr (renren) requests.""" email = self.has_service(message, 'Renren') if email is None: return username, password = datastore.get_username_and_pass(email, 'Renren') r = renren.RenrenAPI(username, password) response = r.login() if response.status_code != 302: message.reply("Error: Renren: login failed") return response = r.statuses_update(message.arg, response) if response is None: message.reply("Error: Renren: get_check not found") else: if response.status_code == 200: message.reply("Your Renren status has updated.") else: message.reply(error.response_error(response, 'Renren'))