def pick_weapon(player, weapon): if len(player.item_list) <= 1: player.item_list.append(weapon) player.location.items.pop(player.location.items.index(weapon)) tweet = Tweet() tweet.type = TweetType.somebody_found_item tweet.player = player tweet.place = player.location tweet.item = weapon write_tweet(tweet) else: if player.item_list[0].power >= player.item_list[1].power: worst_item = player.item_list[1] best_item = player.item_list[0] else: worst_item = player.item_list[0] best_item = player.item_list[1] if weapon.power > worst_item.power: player.item_list = [weapon, best_item] player.location.items.pop(player.location.items.index(weapon)) tweet = Tweet() tweet.type = TweetType.somebody_replaced_item tweet.place = player.location tweet.item = weapon tweet.old_item = worst_item tweet.player = player write_tweet(tweet) else: return False return True
def steal(): player_1, player_2, place = get_two_players_in_random_place() if (player_1, player_2) == (None, None) or are_friends(player_1, player_2): return False if len(player_1.item_list) > 0: robbed = player_1 robber = player_2 elif len(player_2.item_list) > 0: robbed = player_2 robber = player_1 else: return False item = random.choice(robbed.item_list) index = robbed.item_list.index(item) robbed.item_list.pop(index) if len(robber.item_list) <= 1: robber.item_list.append(item) tweet = Tweet() tweet.type = TweetType.somebody_stole tweet.place = robber.location tweet.player = robber tweet.player_2 = robbed tweet.item = item write_tweet(tweet) else: if robber.item_list[0].power >= robber.item_list[1].power: worst_item = robber.item_list[1] best_item = robber.item_list[0] else: worst_item = robber.item_list[0] best_item = robber.item_list[1] if item.power > worst_item.power: robber.item_list = [item, best_item] tweet = Tweet() tweet.type = TweetType.somebody_stole_and_replaced tweet.place = robber.location tweet.player = robber tweet.player_2 = robbed tweet.item = item tweet.old_item = worst_item write_tweet(tweet) else: tweet = Tweet() tweet.type = TweetType.somebody_stole_and_threw tweet.place = robber.location tweet.player = robber tweet.player_2 = robbed tweet.item = item write_tweet(tweet) return True
def infect(): any_infection = any(x for x in player_list if x.infected) alive_players = get_alive_players() infected_players = [] healthy_players = [] for i, p in enumerate(alive_players): if p.infected: infected_players.append(p) elif not p.infection_immunity: healthy_players.append(p) if not any_infection and len(healthy_players) > 0: player = random.choice(healthy_players) if not player.infection_immunity: player.infected = True affected = [x for x in player.location.players if x.get_name() != player.get_name()] for i, p in enumerate(affected): if not p.infection_immunity: p.infected = True tweet = Tweet() tweet.type = TweetType.somebody_was_infected tweet.place = player.location tweet.player = player tweet.player_list = affected write_tweet(tweet) elif len(infected_players) > 0: player = random.choice(infected_players) action_number = random.randint(1, 100) if action_number > config.general.infection_die_threshold: player.infected = False player.infection_immunity = True tweet = Tweet() tweet.type = TweetType.somebody_got_cured tweet.place = player.location tweet.player = player write_tweet(tweet) elif len(alive_players) > 5: kill_player(player) tweet = Tweet() tweet.type = TweetType.somebody_died_of_infection tweet.place = player.location tweet.player = player write_tweet(tweet) if config.general.match_type == MatchType.districts: destroy_tweet = destroy_district_if_needed(player.district) if destroy_tweet is not None: write_tweet(destroy_tweet) else: return False return True
def revive(): dead_players = get_dead_players() if len(dead_players) > 0: player = random.choice(dead_players) player.is_alive = True rebuild_district = config.general.match_type == MatchType.districts and player.district.destroyed if rebuild_district: place = player.district place.destroyed = False else: place = player.location while place.destroyed: place = random.choice(place_list) tweet = Tweet() player.location = place for i, pl in enumerate(place.players): if pl.infected: player.infected = True tweet.there_was_infection = True place.players.append(player) tweet.type = TweetType.somebody_revived tweet.place = player.location tweet.player = player tweet.double = rebuild_district write_tweet(tweet) return True else: suicide()
def main(): now = datetime.utcnow() yesterday = now - timedelta(days=1) start_date_str = yesterday.strftime('%Y-%m-%d') end_date_str = now.strftime('%Y-%m-%d') tweet_accounts = util.read_tweet_accounts() for screen_name in tweet_accounts: tweets = TweetScraper.get_tweets_from_user_timeline( screen_name, start_date_str, end_date_str) Tweet.init() print("Tweet account name: %s" % str(screen_name)) len_of_tweets = len(tweets) print("Total length of tweets: %s" % str(len_of_tweets)) for tweet in tweets: try: obj = Tweet(meta={'id': tweet['id']}) obj.screen_name = tweet['screen_name'] obj.full_text = tweet['full_text'] obj.created_at = tweet['created_at'] obj.save() except: pass
async def add_tweet(user, msg, tags): """ add user tweet with specific tags and after that add to redis to fetch in future :param user: login user json data :param msg: tweet message :param tags: list of tags :return: """ try: async with db.transaction(): tweet = Tweet(msg=msg, user_id=user.get('user_id')) await tweet.create() for tag_item in tags: tag = await get_or_create(Tag, *(Tag.tag_name == tag_item, ), **({ "tag_name": tag_item })) tweet_tag = TagTweet(tag_id=tag.id, tweet_id=tweet.id) await tweet_tag.create() if tweet_tag: await redis.append_value(tag.tag_name, tweet.as_json()) return tweet.as_json(), None except Exception as ex: global_logger.write_log('error', f"error: {ex}") return None, ex
def add(rq): user = current_user(rq) d = rq.form() d['user_id'] = user.id t = Tweet(d) t.add() return redirect('/tweet')
def tweet_command(opts, args): y_flag = False v_flag = False cache = io_service.read_cache() text = ' '.join(args) tweet = Tweet(cache['index'], text, None, cache['last_id']) for opt, arg in opts: if opt == "-y": y_flag = True if opt in ("-s", "--stats"): tweet.tone_analysis = tone_analyzer.analyze(text) if opt in ("-v", "--verbose"): v_flag = True tweet_str = tweet.to_string() log_tweet(tweet_str) if not y_flag: logger.color = Color.Red logger.log("Do you want to tweet? (y/n)") choice = input() if choice != "y" and choice != "Y": return push_tweet(tweet_str, tweet.in_reply_to_id, v_flag)
def all_tweets(): """ This method handles All Tweets View. :return: If "GET" rendering template "all_tweets", If "POST" adding new Tweet to db and redirecting back to all_tweets. """ if not session['logged_in']: return redirect(url_for('login')) if request.method == "GET": cnx = connect_db() tweets = Tweet.load_all_tweets(cnx.cursor()) return render_template('all_tweets.html', tweets=tweets) elif request.method == "POST": tweet = Tweet() tweet.user_id = session['user_id'] tweet.text = request.form['new_tweet'] tweet.creation_date = datetime.now() cnx = connect_db() tweet.add_tweet(cnx.cursor()) cnx.commit() return redirect(url_for('all_tweets'))
def post(self): if not request.is_json: abort(400, message="Could not parse JSON") content = request.get_json() try: user = User.query.filter_by(username=content['username']).one() except NoResultFound as e: abort(401, message="No user found") try: auth = UserAuthorization.query.filter_by(user_id=user.id).one() except NoResultFound as e: abort(401, message="No user authorization found") if auth.token != content['token']: abort(403, message="Invalid token found") tweet = Tweet( user=user, content=content['content'], tag=content['tag'], ) db.session.add(tweet) db.session.commit() return {'tweet': repr(tweet)}
def pick_special(player, item): if item.special == SpecialType.injure_immunity: player.injure_immunity = True if item.special == SpecialType.monster_immunity: player.monster_immunity = True if item.special == SpecialType.infection_immunity: player.infection_immunity = True if item.special == SpecialType.movement_boost: player.movement_boost = True if config.general.match_type == MatchType.districts: others_in_district = [x for x in get_alive_players() if x.district.name == player.district.name and x.get_name() != player.get_name()] if len(others_in_district) > 0: for i, pl in enumerate(others_in_district): if item.special == SpecialType.injure_immunity: pl.injure_immunity = player.injure_immunity if item.special == SpecialType.monster_immunity: pl.monster_immunity = player.monster_immunity if item.special == SpecialType.infection_immunity: pl.infection_immunity = player.infection_immunity if item.special == SpecialType.movement_boost: pl.movement_boost = player.movement_boost player.location.items.pop(player.location.items.index(item)) tweet = Tweet() tweet.type = TweetType.somebody_got_special tweet.place = player.location tweet.item = item tweet.player = player if config.general.match_type == MatchType.districts and len(others_in_district) > 0: tweet.player_list = others_in_district write_tweet(tweet) return True
def tie(player_1, player_2, factor, action_number): if not are_friends(player_1, player_2): befriend(player_1, player_2) tweet = Tweet() tweet.type = TweetType.somebody_tied_and_became_friend tweet.place = player_1.location tweet.player = player_1 tweet.player_2 = player_2 tweet.factor = factor tweet.action_number = action_number write_tweet(tweet) else: tweet = Tweet() tweet.type = TweetType.somebody_tied_and_was_friend tweet.place = player_1.location tweet.player = player_1 tweet.player_2 = player_2 tweet.factor = factor tweet.action_number = action_number write_tweet(tweet) return True
def insert_tweet(id_tweet, username, text=None, date=None, url=None, reply_count=None, retweet_count=None, like_count=None, quote_count=None): """ Insere um novo tweet no banco de dados Caso já exista então atualiza Parâmetros ---------- id_tweet : str Id do tweet (deve ser único) username : str Username no autor do tweet text : str Texto do tweet username : str Username no autor do tweet date : datetime Data do tweet url : str URL para o tweet reply_count : int Contagem de replies retweet_count : int Contagem de retweets like_count : int Contagem de likes quote_count : int Contagem de citações """ session = Session() new_tweet = Tweet(id_tweet=id_tweet, username=username, text=text, date=date, url=url, reply_count=reply_count, retweet_count=retweet_count, like_count=like_count, quote_count=quote_count) session.merge(new_tweet) # Realiza commit e encerra sessão session.commit() session.close()
def write_twitter_data_to_file(self): # Clear contents of file open(self.twitter_data_filename, 'w').close() # Write new content to file for index, tweet_id in self.archive_data.tweet_id.iteritems(): try: Tweet(self.api.get_status(tweet_id)).write_to_file( self.twitter_data_filename) except tweepy.TweepError as e: self.tweets_with_404.append(tweet_id) print(str(tweet_id) + ': ' + e.reason) print(index) print(self.tweets_with_404)
def save_tweet(): # mysql = connectToMySQL('dojo_tweets') # query = "INSERT INTO tweets (tweet_content, Users_id) VALUES(%(tm)s, %(uid)s)" # data = { # 'tm': request.form['tweet'], # 'uid': session['user_id'] # } # mysql.query_db(query, data) tweet = Tweet(tweet_content=request.form['tweet'], users_id=session['user_id']) db.session.add(tweet) db.session.commit() return redirect("/create_tweet")
def postTweet(userId, text): """create a tweet for a given user""" user = getUser(userId) if user != None: user.numberOfTweet += 1 user.put() id_tweet = userId + "_" + str(user.numberOfTweet) tweet = Tweet(id=id_tweet) tweet.author = user.pseudo tweet.authorId = userId tweet.text = text tweet.wordSearch = formatTextForSearch(text) tweet.put()
def suicide(): alive_players = get_alive_players() if len(alive_players) < 5: return False player = random.choice(alive_players) kill_player(player) tweet = Tweet() tweet.type = TweetType.somebody_suicided tweet.place = player.location tweet.player = player write_tweet(tweet) if config.general.match_type == MatchType.districts: destroy_tweet = destroy_district_if_needed(player.district) if destroy_tweet is not None: write_tweet(destroy_tweet) return True
def next_entrance(): alive_players = get_alive_players() players_in_place = [x for x in alive_players if x.location is not None] players_out = [x for x in alive_players if x.location is None] if len(players_out) == 0: return False candidate = random.choice(players_out) move_player(candidate, place_list[0]) tweet = Tweet() tweet.type = TweetType.next_entrance tweet.place = candidate.location tweet.player = candidate tweet.player_list = players_in_place write_tweet(tweet) return True
def validate_proc_tweet(): is_valid = True if not request.form['tweet_content']: flash("You cannot post a empty tweet.") is_valid = False if len(request.form['tweet_content']) > 255: flash("Tweets must be less than 255 characters.") is_valid = False if is_valid: tweet = Tweet(content=request.form['tweet_content'], author_id=session['user_id']) db.session.add(tweet) db.session.commit() tweet_like_count([tweet]) return render_template('fragments/tweet_content.html', tweet=tweet) else: return "False"
def test_command(opts, args): t_flag = False v_flag = False cache = io_service.read_cache() text = ' '.join(args) tweet = Tweet(cache['index'], text, None, cache['last_id']) for opt, arg in opts: if opt in ("-s", "--stats"): tweet.tone_analysis = tone_analyzer.analyze(text) if opt == "-t": t_flag = True if opt in ("-v", "--verbose"): v_flag = True tweet_str = tweet.to_string() log_tweet(tweet_str) if t_flag: push_tweet(tweet_str, tweet.in_reply_to_id, v_flag)
def _handle_tweet(self, tweet): if Tweet.objects.filter(twitter_id=tweet.id_str): return self._update_tweet_stats(tweet) tweet_model = { 'twitter_id': tweet.id_str, 'source_page': self.current_twitter_page, 'twitter_user_id': tweet.user.id_str, 'text': tweet.retweeted_status.text if tweet.retweeted else tweet.text, 'hashtags': [th.AsDict() for th in tweet.hashtags], 'user_mentions': [tm.AsDict() for tm in tweet.user_mentions], 'urls': [tu.AsDict() for tu in tweet.urls], 'favorites': tweet.favorite_count, 'retweets': tweet.retweet_count, 'is_retweet': tweet.retweeted_status is not None, 'retweet_id': tweet.retweeted_status.id_str if tweet.retweeted_status is not None else None, 'language': tweet.lang, 'location': tweet.location, 'created_at': datetime.datetime.strptime(tweet.created_at, '%a %b %d %H:%M:%S +0000 %Y') } for url in tweet_model['urls']: url.update({'extended_url': self._unshorten_url(url['url'])}) logger.info('Inserting new Tweet %r' % tweet_model) return Tweet(**tweet_model).save()
def extract(query, mode='strict', max_tweets=5000): regex = r"^[\*\-\d]+[ \.\-]+(.+)$" auth = tweepy.AppAuthHandler(config['TWITTER']['Auth_Public_Key'], config['TWITTER']['Auth_Secret_Key']) api = tweepy.API(auth, wait_on_rate_limit=True) processed_tweets = 0 for tweet in tweepy.Cursor(api.search, q=query, rpp=100, tweet_mode='extended', include_entities=False).items(max_tweets): processed_tweets += 1 if processed_tweets % 20 == 0: print("> Processed " + str(processed_tweets) + " tweets out of " + str(max_tweets)) new_tweet = Tweet(tweet_id=tweet.id_str, user_id=tweet.user.id_str, created_at=tweet.created_at) matches = list(re.finditer(regex, tweet.full_text, re.MULTILINE)) if not (tweet.is_quote_status or tweet.retweeted) and len(matches) > 2: for num, match in enumerate(matches): sanitized_preference = html.unescape(match.group(1).strip()) if mode != 'keep_user_text': tmdb_title = get_tmdb_title(sanitized_preference, mode) if tmdb_title != "" and tmdb_title is not None: print("Before: " + sanitized_preference + " - After: " + tmdb_title) new_tweet.preferences.append(tmdb_title) else: new_tweet.preferences.append(sanitized_preference) if len(new_tweet.preferences) >= 1: new_tweet.save()
def testCreateTweet(): new_tweet = Tweet() new_tweet.text = 'gollsdfsdfsdfsfdsdfum' new_tweet.creation_date = datetime.now() print(new_tweet.id) try: cnx = connect(user=user, password=password, host=host, database=database) print("Connected...") cursor = cnx.cursor() new_tweet.add_edit_tweet(cursor) cnx.commit() cursor.close() cnx.close() print('Disconnected...') except ProgrammingError: print("Not connected...")
def seed_users(g): for i in range(0, AMOUNT_TO_SEED): first_name = names.get_first_name() last_name = names.get_last_name() username = first_name + '_' + last_name user = User( username='******', password='******', display_name='Andrew P. Groebe', join_date='August 2017', bio='Software Engineering Student and tech enthusiast' ) user_vertex_id = user.write(g) tweet = Tweet( contents='This is my first tweet, so Hello World!' ) tweet_vertex_id = tweet.write(g) g.V(user_vertex_id).addE('tweeted').to(g.V(tweet_vertex_id)).next()
def run_away(player_1, player_2, factor, action_number, inverse): tweet = Tweet() candidates = [x for x in player_1.location.connection_list if not x.destroyed] if len(candidates) == 0: return False new_location = random.choice(candidates) if inverse: there_was_infection, infected_or_was_infected_by = who_infected_who(player_1, new_location.players) move_player(player_1, new_location) tweet.place = player_2.location tweet.place_2 = player_1.location else: there_was_infection, infected_or_was_infected_by = who_infected_who(player_1, new_location.players) move_player(player_2, new_location) tweet.place = player_1.location tweet.place_2 = player_2.location tweet.type = TweetType.somebody_escaped tweet.player = player_1 tweet.player_2 = player_2 tweet.factor = factor tweet.action_number = action_number tweet.inverse = inverse if there_was_infection: tweet.there_was_infection = True tweet.infected_or_was_infected_by = infected_or_was_infected_by if are_friends(player_1, player_2): unfriend(player_1, player_2) tweet.unfriend = True write_tweet(tweet) return True
def commit_tweet_to_db(self, ruleid, result): text = result.text.encode(errors='ignore').\ decode('utf-8', 'ignore') location = result.user.location.encode(errors='ignore').\ decode('utf-8', 'ignore') sentiment = self.sentiment_analyser.multinomial_naive_bayes(str(text)) tweet = Tweet( timestamp=result.created_at, tweet=text, location=location, from_screenname=result.user.screen_name, ruleid=ruleid, profile_image_url=result.user.profile_image_url, profile_image_url_https=result.user.profile_image_url_https, following=result.user.following, no_of_followers=result.user.followers_count, contacted=0, tweet_id=result.id, sentiment=sentiment, trained=0, ) session.add(tweet) session.commit()
def _scrape_tweets(start_date_str, num_of_date_project, max_count_per_day): tweet_accounts = util.read_tweet_accounts() for i in range(num_of_date_project): print(datetime.now()) end_date_str = _add_one_day_to_date_string(start_date_str) print(start_date_str) for screen_name in tweet_accounts: #print(screen_name) tweets = TweetScraper.get_tweets_from_user_timeline( screen_name, start_date_str, end_date_str, max_count_per_day) Tweet.init() len_of_tweets = len(tweets) print("Total length of tweets: %s" % str(len_of_tweets)) no_of_tweets_saved = 1 for tweet in tweets: try: if no_of_tweets_saved % 1000 == 0: print("%s tweets have been saved to database." % str(no_of_tweets_saved)) obj = Tweet(meta={'id': tweet['id']}) obj.screen_name = tweet['screen_name'] obj.full_text = tweet['full_text'] obj.created_at = tweet['created_at'] obj.save() no_of_tweets_saved = no_of_tweets_saved + 1 except: no_of_tweets_saved = no_of_tweets_saved + 1 pass start_date_str = _add_one_day_to_date_string(start_date_str)
def handle_event(event): tweet = Tweet() tweet.is_event = True tweet.type = event.name if event.name == 'airdrop': item_list_1 = [] item_list_2 = [] item_list_3 = [] for i, item in enumerate(spare_item_list): if item.get_rarity() == 1: item_list_1.append(item) elif item.get_rarity() == 2: item_list_2.append(item) elif item.get_rarity() == 3: item_list_3.append(item) alive_districts = [x for x in place_list if not x.destroyed and len([y for y in x.tributes if y.is_alive]) > 0] for i, district in enumerate(alive_districts): district.items = district.items + get_items_in_place(item_list_1, item_list_2, item_list_3) elif event.name == 'abduction_1': abducted = random.choice(get_alive_players()) abducted.is_alive = False abducted.location.players.pop(abducted.location.players.index(abducted)) tweet.player = abducted tweet.place = abducted.location elif event.name == 'abduction_1_end': abducted = get_dead_players()[0] abducted.is_alive = True abducted.power = abducted.power + 7.4 new_place = random.choice(place_list) while new_place.name == abducted.location.name: new_place = random.choice(place_list) abducted.location = new_place new_place.players.append(abducted) tweet.player = abducted tweet.place = abducted.location elif event.name == 'abduction_2': alive_players = get_alive_players() random.shuffle(alive_players) abducted_1 = alive_players[0] abducted_2 = alive_players[1] while abducted_1.location.name == abducted_2.location.name: random.shuffle(alive_players) abducted_1 = alive_players[0] abducted_2 = alive_players[1] abducted_1.location.players.pop(abducted_1.location.players.index(abducted_1)) abducted_2.location.players.pop(abducted_2.location.players.index(abducted_2)) abducted_1.location.players.append(abducted_2) abducted_2.location.players.append(abducted_1) abducted_1.location, abducted_2.location = abducted_2.location, abducted_1.location tweet.player = abducted_1 tweet.player_2 = abducted_2 tweet.player = abducted_1 tweet.player_2 = abducted_2 tweet.place = abducted_1.location tweet.place_2 = abducted_2.location return tweet
def kill(player_1, player_2, place, factor, action_number, inverse): killer = player_1 killed = player_2 if inverse: killer = player_2 killed = player_1 killer.kills = killer.kills + 1 best_killer_item = killer.get_best_item() best_killed_item = killed.get_best_item() tweet = Tweet() tweet.type = TweetType.somebody_killed tweet.place = place tweet.player = player_1 tweet.player_2 = player_2 tweet.factor = factor tweet.action_number = action_number tweet.inverse = inverse tweet.item = killer.get_best_item() if best_killed_item is not None and len(killer.item_list) == 2 and ( best_killer_item.power < best_killed_item.power): # Steal item and throw away killer.previous_power = killer.get_power() killed.previous_power = killed.get_power() killer.item_list = [best_killer_item, best_killed_item] killed.item_list.pop(killed.item_list.index(best_killed_item)) old_item = killer.get_worst_item() killer.location.items.append(old_item) old_item.thrown_away_by = killer tweet.old_item = old_item tweet.new_item = best_killed_item elif best_killed_item is not None and len(killer.item_list) < 2: # Steal item killer.previous_power = killer.get_power() killed.previous_power = killed.get_power() if best_killer_item is not None: killer.item_list = [best_killer_item, best_killed_item] else: killer.item_list = [best_killed_item] killed.item_list.pop(killed.item_list.index(best_killed_item)) tweet.new_item = best_killed_item place = killed.location place.players.pop(place.players.index(killed)) killed.is_alive = False write_tweet(tweet) kill_player(killed) killer.previous_power = None killed.previous_power = None if config.general.match_type == MatchType.districts: destroy_tweet = destroy_district_if_needed(killed.district) if destroy_tweet is not None: write_tweet(destroy_tweet) return True
def destroy_district_if_needed(district): if any(x for x in district.tributes if x.is_alive): return None district.destroyed = True district.monster = False district.trap_by = None district.items = [] tributes_list = district.tributes escaped_list = [] route_list = [] new_location = False for j, c in enumerate(district.connection_list): if not c.destroyed: route_list.append(c) if len(route_list) == 0: for j, c in enumerate(district.connection_list): for k, sc in enumerate(c.connection_list): if not sc.destroyed and sc.name != district.name: route_list.append(sc) if len(route_list) == 0: for j, c in enumerate(district.connection_list): for k, sc in enumerate(c.connection_list): for l, ssc in enumerate(sc.connection_list): if not ssc.destroyed and ssc.name != district.name: route_list.append(ssc) if len(route_list) == 0: for j, c in enumerate(district.connection_list): for k, sc in enumerate(c.connection_list): for l, ssc in enumerate(sc.connection_list): for m, sssc in enumerate(ssc.connection_list): if not sssc.destroyed and sssc.name != district.name: route_list.append(sssc) if len(route_list) == 0: new_location = random.choice([x for x in place_list if not x.destroyed and x.name != district.name]) else: new_location = random.choice(route_list) for i, p in enumerate(district.players): if p.is_alive: escaped_list.append(p) any_infected = False any_healthy = False for i, p in enumerate(escaped_list + new_location.players): if p.infected: any_infected = True else: any_healthy = True move_player(p, new_location) tweet = Tweet() tweet.type = TweetType.destroyed_district tweet.place = district tweet.place_2 = new_location tweet.player_list = tributes_list tweet.player_list_2 = escaped_list if any_infected and any_healthy: tweet.there_was_infection = True return tweet