def init(): global api api = config.create_twitter_api() logger.info('Bot Started: %s' % datetime.utcnow()) config.load_cfg() imgpicker.init_img_list() users.init_user_list()
def __init__(self): logger.info(f"Loading config") self.config = config.Config.load() logger.info(f"Create twitter api") self.api = config.create_twitter_api(self.config) logger.info(f"Retrieving mdconfig") self.mdc = mdconfig.get_mdconfig(self.config.mdconfig_url) self.screen_name = self.api.get_settings()['screen_name']
def fake_laura_tweet(): twitter_api = config.create_twitter_api() if datetime.datetime.today().day == 4: tweets = twitter.get_tweet_text(twitter_api, '@laurarawra', 3000) laura_text = '' for tweet in tweets: tweet = ' '.join(filter(lambda x: x[0] != '@', tweet.split())) laura_text += tweet + '.' hello_there = general_kenobi(laura_text) else: hello_there = load_model('marko_model.json') bot_tweet = hello_there.make_short_sentence(280) twitter_api.update_status(bot_tweet) print(bot_tweet)
def main(): # Creating/loading the chatbot my_bot = load_bot('chatterbot.pkl') # Setting up twitter functionality api = create_twitter_api() since_id = readConfig() while True: new_messages, since_id = checkForDMs(api, since_id) if new_messages: for message in reversed(new_messages): senderID = message[0] text = message[1] sender = message[2] response = my_bot.get_response(text) print('Sender: ', sender) print('Text: ', text) print('Response: ', response) api.send_direct_message(senderID, response.text) time.sleep(60)
def main(): api = create_twitter_api() loop = True since_id = readConfig() parseTweets(api, '@elonmusk')