def print_status(self, status): print "|" + "_"*78 + "|" print utils.add_symbol(utils.colorize(status.author.screen_name, "B_CYAN"), 90) lines = utils.split_tweet(status.text) for line in lines: print line timestamp = utils.colorize("at " + status.created_at.strftime("%A, %d/%m/%y, %H:%M:%S") + " from " + status.source, "CYAN") print utils.add_symbol(timestamp, 90)
def on_status(self, status): try: print "|" + "_"*78 + "|" print utils.add_symbol(utils.colorize(status.author.screen_name, "B_CYAN"), 90) for line in self.status_wrapper.wrap(status.text): print utils.add_symbol_end(line, 80) timestamp = utils.colorize("at " + status.created_at.strftime("%A, %d/%m/%y, %H:%M:%S") + " from " + status.source, "CYAN") print utils.add_symbol(timestamp, 90) except: print 'error'
def on_status(self, status): try: print "|" + "_"*78 + "|" print utils.add_symbol(utils.colorize(status.author.screen_name, "B_CYAN"), 90) for line in self.status_wrapper.wrap(status.text): print utils.add_symbol_end(line, 80) timestamp = utils.colorize("at " + status.created_at.strftime("%A, %d/%m/%y, %H:%M:%S") + " from " + status.source, "CYAN") print utils.add_symbol(timestamp, 90) #print self.status_wrapper.fill(status.text) #print '\n %s %s via %s\n' % (status.author.screen_name, status.created_at, status.source) except: # Catch any unicode errors while printing to console # and just ignore them to avoid breaking application. print 'error'
def get_user_profile(self, user_input): try: name = user_input.split(' ')[1] print "Loading user....." user = self.api.get_user(name) print "|" + "_"*78 + "|" print utils.add_symbol(utils.colorize(user.name, "B_YELLOW"), 90) print "|" + " "*78 + "|" print utils.add_symbol(utils.colorize(" Location: " +user.location, "YELLOW"), 90) lines = utils.split_user_bio("Bio: " + user.description) for line in lines: print line print "|" + " "*78 + "|" print utils.add_symbol(utils.colorize(" " + str(user.statuses_count) + " tweets", "YELLOW"), 90) print utils.add_symbol(utils.colorize(" Followers: " + str(user.followers_count), "YELLOW"), 90) print utils.add_symbol(utils.colorize(" Following: " + str(user.friends_count), "YELLOW"), 90) print utils.add_symbol(utils.colorize(" " + str(user.favourites_count) + " tweets favorited", "YELLOW"), 90) print "|" + "_"*78 + "|" print utils.add_symbol("Loading tweets.....", 80) statuses = self.api.user_timeline(screen_name=name, count=20) print utils.add_symbol("User tweets: last updated at " + datetime.now().strftime("%A, %d/%m/%Y %I:%M%p"), 80) for status in statuses: self.print_status(status) print "|" + "_"*78 + "|" except: print utils.colorize('User not found', "RED")