<commit_before>#!/usr/bin/env python3.5

import sys
from time import ctime
from tweepy import API
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from credentials import *
from utils import gen_hashtags
import markovify
import random
import argparse
import logging

log = logging.getLogger(__name__)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(logging.Formatter('%(asctime)s: %(name)s - %(levelname)s - %(message)s'))
stdout_handler.setLevel(logging.INFO)
log.addHandler(stdout_handler)
log.setLevel(logging.INFO)

class Listener(StreamListener):
    def __init__(self, api, followed_user_id, followed_user_handle, mock_mode, hashtags):
        super().__init__(api)
        self.tweet_data = []
        self.followed_user_id = followed_user_id
        self.followed_user_handle = followed_user_handle

        self.mock_mode = mock_mode
        self.reply_list = []
        self.next_reply = ''
        self.load_next_reply(mock_mode, hashtags)

    def on_error(self, error):
        log.error("Returned error code %s" % error)
        return False

    def on_status(self, status):
        if status.user.id == self.followed_user_id:
            tweet_text = '@%s %s' % (self.followed_user_handle, self.next_reply)
            self.api.update_status(tweet_text, in_reply_to_status_id=status.id)

            log.info('%s tweeted: %s' % (self.followed_user_handle, status.text))
            log.info('Tweeted: %s' % tweet_text)

            if self.mock_mode:
                self.update_mock_text(status.text)

            self.load_next_reply(self.mock_mode)

    def load_next_reply(self, mock=False, hashtags=None):
        if hashtags:
            hashtag_string = gen_hashtags(hashtags)

        if not mock:
            with open('reply_list.txt', 'r') as reply_list_file:
                self.reply_list = reply_list_file.readlines()<commit_msg>hashtags should be passed to load_next_reply beyond the first invocation<commit_after>#!/usr/bin/env python3.5

import sys
from time import ctime
from tweepy import API
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from credentials import *
from utils import gen_hashtags
import markovify
import random
import argparse
import logging

log = logging.getLogger(__name__)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(logging.Formatter('%(asctime)s: %(name)s - %(levelname)s - %(message)s'))
stdout_handler.setLevel(logging.INFO)
log.addHandler(stdout_handler)
log.setLevel(logging.INFO)

class Listener(StreamListener):
    def __init__(self, api, followed_user_id, followed_user_handle, mock_mode, hashtags):
        super().__init__(api)
        self.tweet_data = []
        self.followed_user_id = followed_user_id
        self.followed_user_handle = followed_user_handle

        self.mock_mode = mock_mode
        self.reply_list = []
        self.next_reply = ''
        self.load_next_reply(mock_mode, hashtags)

    def on_error(self, error):
        log.error("Returned error code %s" % error)
        return False

    def on_status(self, status):
        if status.user.id == self.followed_user_id:
            tweet_text = '@%s %s' % (self.followed_user_handle, self.next_reply)
            self.api.update_status(tweet_text, in_reply_to_status_id=status.id)

            log.info('%s tweeted: %s' % (self.followed_user_handle, status.text))
            log.info('Tweeted: %s' % tweet_text)

            if self.mock_mode:
                self.update_mock_text(status.text)

            self.load_next_reply(self.mock_mode, hashtags)

    def load_next_reply(self, mock=False, hashtags=None):
        if hashtags:
            hashtag_string = gen_hashtags(hashtags)

        if not mock:
            with open('reply_list.txt', 'r') as reply_list_file:
                self.reply_list = reply_list_file.readlines()
{'fraction_non_alphanumeric': 0.09628506444275967, 'fraction_numerical': 0.0010108668182966893, 'mean_word_length': 3.344676180021954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '384483', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1248, 'n_words': 257}