i += 1 print(i) u = twitter_api.user(token, user_id) if u is None: continue if 'since_id' not in user['twitter']: user['twitter']['since_id'] = -1 since_id = user['twitter']['since_id'] ids = twitter_api.user_tweets_id(token, user_id, since_id) if '_activity' not in user['twitter']: user['twitter']['_activity'] = {} activity = { 'statuses_count': u['statuses_count'], 'favourites_count': u['favourites_count'], 'friends_count': u['friends_count'], 'followers_count': u['followers_count'], 'listed_count': u['listed_count'], 'tweets': ids } user['twitter']['_activity'][str(today)] = activity if (len(ids) > 0): user['twitter']['since_id'] = ids[-1] people.save(users, './people.json')
aboutme = pq('div.content.firstContent') lifetime = pq('div.tabsData.lifetime.cached') lifetime_steps = lifetime('div.tabsData.steps') lifetime_floor = lifetime('div.tabsData.floor') lifetime_distance = lifetime('div.tabsData.distance') #best = pq('div.tabsData.bestStats.cached') best = pq('div#achievementsBest') best_steps = best('div.tabsData.steps') best_floor = best('div.tabsData.floor') best_distance = best('div.tabsData.distance') if '_activity' not in fitbit: fitbit['_activity'] = {} activity = fitbit['_activity'] activity[today] = { 'height':height.text(), 'location':location.text(), 'joined':joined.text(), 'aboutme':aboutme.text(), 'steps-all':lifetime_steps('span.value').text(), 'floor-all':lifetime_floor('span.value').text(), 'distance-all':lifetime_distance('span.value').text() #'steps-best':best_steps('span.value').text(), #'floor-best':best_floor('span.value').text(), #'distance-best':best_distance('span.value').text() } people.save(persons, '/vagrant/data/people.json')
# for each url for url in urls: expanded_url = url['expanded_url'] try: expanded_url = expand(expanded_url) except: print('[WARN] @' + str(i) + ' Url not valid') continue url_match = re.match('^.*www.facebook.com/(.*)/posts/.*$', expanded_url) if url_match: fb_username = url_match.group(1) person = { 'twitter': { 'name': tw_name, 'screen_name': tw_username }, 'facebook': { 'username': fb_username }, '_': { 'tw_fb_jaro': jellyfish.jaro_distance(tw_username, fb_username) } } people.link_tw_fb(person, persons) continue people.save(persons, people_path) print('[INFO] Success')
def respond(self, msg): msg.printToConsole() msg = self.lang.handler_recv(msg) if msg.type == 'NUMERIC': if msg.subject in ['ERR_NICKNAMEINUSE', 'ERR_ERRONEUSNICKNAME'] and not irc.nick: irc.changeNick(self.names.next()) elif msg.subject == 'RPL_ENDOFMOTD' and not irc.nick: irc.nick = irc.lastNickTried if self.needToJoinChannels: for channel in self.needToJoinChannels: print "Joining " + channel irc.join(channel) self.needToJoinChannels = False elif msg.subject == 'RPL_NAMREPLY': for name in msg.content.rpartition(':')[2].split(): print "Finding " + name.lstrip('@+') + "..." people.Person(name.lstrip('@+')) atexit.register(people.save) print "Saving people..." people.save() # for person in people.knownPeople.values(): # print "nick: " + person.nickname, "\tusername: "******"\trealname: ", person.realname, "\tchannels: ", person.channels elif msg.type in ['MSG', 'MSG ACTION', 'PM', 'PM ACTION'] and msg.content: if msg.type == 'MSG' or 'PM': formattedMessage = simpleFormat(msg.content) formattedCurrentName = simpleFormat(irc.nick) formattedFirstName = simpleFormat(self.namesList[0]) if msg.type == 'MSG': if formattedMessage.startswith(formattedCurrentName): self.execCommand(simpleFormat(formattedMessage.partition(formattedCurrentName)[2]), msg) elif formattedMessage.startswith(formattedFirstName): self.execCommand(simpleFormat(formattedMessage.partition(formattedFirstName)[2]), msg) elif msg.type == 'PM': self.execCommand(formattedMessage, msg) elif msg.type == 'NICK': if msg.user == irc.nick: irc.nick = msg.content try: people.onlinePeople[msg.user].nickname = msg.content people.save() except KeyError: print "ERROR: That's odd, I've never heard of %s before..." % (msg.user) print "Users list: ", people.onlinePeople elif msg.type == 'JOIN': if msg.user == irc.nick: self.channels.append(msg.channel) else: self.sendMsg(msg.channel, "Welcome to %s, %s!" % (msg.channel, msg.user)) people.Person(msg.user) elif msg.type == 'PART': if msg.user != irc.nick: self.sendMsg(msg.channel, ";(") self.sendMsg(msg.channel, "So sad to see %s go." % (msg.user)) elif msg.type == 'QUIT': if msg.user == self.namesList[0]: self.names = iter(self.namesList) irc.changeNick(self.names.next()) elif msg.type == 'INVITE': irc.join(msg.channel) self.sendMsg(msg.channel, msg.user + " invited me to this channel.") self.lang.handler_unknown(msg)