def markov_tweet():
    """ Generates a tweet using a Markov bot. """
    bot = MarkovBot()
    read_book(bot, 'alice.txt')
    read_book(bot, 'dao.txt')
    read_book(bot, 'pride.txt')
    read_book(bot, 'sherlock.txt')
    read_book(bot, 'oz.txt')

    seed_words = ['drink', 'health', 'water', 'river', 'stream']
    tweet_content = bot.generate_text(15, seedword=seed_words)
    print tweet_content

    # Check if the generated content has a seed word in it.
    for word in seed_words:
        if word in tweet_content:
            return tweet_content + ' #DrinkWater'
    return None
Ejemplo n.º 2
0
def markov():
    tweetbot = MarkovBot()
    dirname = os.path.dirname(os.path.abspath(__file__))
    data1 = os.path.join(dirname, 'positiveTweets.txt')
    data2 = os.path.join(dirname, '1liner.txt')
    data3 = os.path.join(dirname, '10ondate.txt')
    data4 = os.path.join(dirname, 'forCachetes.txt')
    #data5 = os.path.join(dirname, 'book3.txt')
    #data6 = os.path.join(dirname, 'book4.txt')
    data7 = os.path.join(dirname, 'jokes.txt')
    #data8 = os.path.join(dirname, 'book4.txt')
    tweetbot.read(data1)
    tweetbot.read(data2)
    tweetbot.read(data3)
    tweetbot.read(data4)
    #tweetbot.read(data5)
    #tweetbot.read(data6)
    tweetbot.read(data7)
    #tweetbot.read(data8)

    my_first_text = tweetbot.generate_text(25, seedword=['life', 'motivation', 'happy', 'bullying'])
    print("tweetbot says:")
    print(my_first_text)
Ejemplo n.º 3
0
import os
from markovbot import MarkovBot

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
print(dirname)
# Construct the path to the book
book = os.path.join(dirname, 'hotep_speak.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['black', 'america'])
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = 'K9YqNYb8j6HA0hgBKLZ1aQ918'
# Consumer Secret (API Secret)
cons_secret = 'BFCDji7mF7sfw2PpdQMEcZ90Poht5E6OMff1XEHb3UeLB8K1Fz'
# Access Token
access_token = '988043632828715008-U4kAofzutxFuPx6c3jCwnrRztm3y5lt'
# Access Token Secret
access_token_secret = 'zNxtfZQb9HU3nRN88uJzJ39H2Ttfk7Vno0Qc3WobX0U5J'

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
Ejemplo n.º 4
0
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


import os
from markovbot import MarkovBot
tweetbot = MarkovBot()
dirname = os.path.abspath(C:\Users\Colin\Documents\Growtye\bot\tweetbot\markovbot-master\Freud_Dream_Psychology.txt)
book = os.path.join(dirname,'Freud_Dream_Psychology.txt')
tweet.read(book)
my_first_text - tweetbot.generate_text(25, seedword=['dream','psychoanalysis'])
print("tweetbot says:")
print(my_first_text)

Ejemplo n.º 5
0
import os
import time

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'smith_wealth_of_nations.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'labour', u'capital'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))
Ejemplo n.º 6
0
import os
import time

from markovbot import MarkovBot


# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)


# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'dream', u'psychoanalysis'])
Ejemplo n.º 7
0
from random import randint
from markovbot import MarkovBot
import os

bot = MarkovBot()

book = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                    'realdonaldtrump.txt')

# Make your bot read the text!
bot.read(book)

# Choose how many tweets you want to generate
tweets_to_generate = 150

for x in range(0, tweets_to_generate):
    # len of the new tweets that will be generated, in words
    tweet_len = randint(10, 25)
    # generating tweet, based on its len and seedwords!
    tweet = bot.generate_text(tweet_len, seedword=[])

    # writting to our generated sentences to the file the poster will use later
    sentences_list = open("generated_sentences.txt", "a")
    sentences_list.write(tweet + "\n")
    sentences_list.close()
Ejemplo n.º 8
0
import os
import time

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'onion_headlines_filtered.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(maxlength=15)

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))
    while(tweetStr_2 == ""):
        if sentenceKey[dictNo].has_key(rowResponse['rows'][0][column]):
            tweetStr_2 = sentenceKey[dictNo][rowResponse['rows'][0][column]]
        else:
            column = randint(8,27)

    tweetStr = tweetStr_1 + tweetStr_2
    return tweetStr

while True:
    tweetStr = GetTweetStr(service)
    api.update_status(tweetStr)
    time.sleep(3600)

# Markovbot for automated replies
tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, u'ebook.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=[u'economy', u'money'])
print(u'\ntweetbot says: "%s"' % (my_first_text))

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)

#Start tweeting periodically
tweetbot.twitter_tweeting_start(days=0, hours=0, minutes=1, keywords=None, prefix=None, suffix=None)

Ejemplo n.º 10
0
import os
from markovbot import MarkovBot

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))

book = os.path.join(dirname, 'EveryBeatleslyricrecorded.txt')

tweetbot.read(book)

my_first_text = tweetbot.generate_text(50)
print("tweetbot says:")
print(my_first_text)
import os
import time

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path, find Malcolm's speech collections and read it
dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, u'speeches/all_speeches.txt')
tweetbot.read(book)

# # # # #
# TWUTT

# The MarkovBot uses @sixohsix' Python Twitter Tools, which is a Python wrapper
# for the Twitter API. Find it on GitHub: https://github.com/sixohsix/twitter
cons_key = os.environ['MY_CONSUMER_KEY']
cons_secret = os.environ['MY_CONSUMER_SECRET']
access_token = os.environ['MY_ACCESS_TOKEN_KEY']
access_token_secret = os.environ['MY_ACCESS_TOKEN_SECRET']

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)

# The target string is what the bot will reply to on Twitter. To learn more,
# read: https://dev.twitter.com/streaming/overview/request-parameters#track
Ejemplo n.º 12
0
import os
import time

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'data_amazon_one_star.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25, seedword=[u'failed', u'crap'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))
Ejemplo n.º 13
0
#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import os
import time

from markovbot import MarkovBot

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, u'politicaBrasileira.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(30)

print(u'\ntweetbot says: "%s"' % (my_first_text))

# Consumer Key (API Key)
cons_key = '1rVz2u5o37F6ycuQiXqYpmvz7'
# Consumer Secret (API Secret)
cons_secret = 'r1z2vJLwUExkWDm0vgVKgUYLT5cB5jRcUQDxizbBp6jIYGv4Op'
# Access Token
access_token = '772074137258954752-g9yoZSIRVmhA9EQmyAfDAx5Hfef1G7w'
# Access Token Secret
access_token_secret = 'sqkQRyOWKSXXSxZHqVWwKZZoJpXHnLar7nlT2z1O1ot8Z'

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token, access_token_secret)

targetstring = 'professorpolitica'
Ejemplo n.º 14
0
import os
import time
from markovbot import MarkovBot
tweetbot = MarkovBot()
dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, 'manifesto.txt')
tweetbot.read(book)
my_text = tweetbot.generate_text(25, seedword=['society', 'bourgeoisie'])
print(my_text)

# Consumer Key (API Key)
cons_key = 'TIShdZ9JgpYIyg8X4oJXAzgFq'
# Consumer Secret (API Secret)
cons_secret = 'qgLQKTadisYeb1T7DIVPNs17U7ce0LUaCAofHss8fiDWDMugpx'
# Access Token
access_token = '1087385094858387459-DijdGpPcFmugx0L86msnc5TOeXj8Gh'
# Access Token Secret
access_token_secret = 'XUAoW9ieporFcgqE1wMJnHEag4rpurUwJzewP7XCkhPgq'
#log in to twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
#set parameters for auto-replies
targetstring = "capitalism"
keywords = ['cultural', 'economics', 'proletariat', 'bourgeoisie']
prefix = None
suffix = None
maxconvdepth = 1
#start auto-replies
tweetbot.twitter_autoreply_start(targetstring,
                                 keywords=keywords,
                                 prefix=prefix,
Ejemplo n.º 15
0
import os
import time

from markovbot import MarkovBot

# from markovbot import MarkovBot

tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, 'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)

# my_first_text = tweetbot.generate_text(25, seedword=['dream', 'psychoanalysis'])
#print("tweetbot says:")
#print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = ''
# Consumer Secret (API Secret)
cons_secret = ''
# Access Token
access_token = ''
# Access Token Secret
access_token_secret = ''

# Log in to Twitter
Ejemplo n.º 16
0
def getBot(filePath):
    tweetbot = MarkovBot()
    tweetbot.read(filePath)
    return tweetbot
Ejemplo n.º 17
0
import os
import time

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'cleaner.trumptweets.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(
    25, seedword=[u'loser', u'sad', u'china', u'covfefe'])

# Print your text to the console
Ejemplo n.º 18
0
        print("...%s tweets downloaded so far" % (len(alltweets)))

    #transform the tweepy tweets into a 2D array that will populate the csv
    outtweets = [[tweet.text.encode("utf-8")] for tweet in alltweets]

    #write the csv
    with open('%s_tweets.txt' % screen_name, 'wb') as f:
        for tweet in alltweets:
            f.write(tweet.text.encode("utf-8") + ' '.encode("utf-8"))

    pass


get_all_tweets("kanyewest")
kanyebot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
tweets = os.path.join(dirname, 'kanyewest_tweets.txt')
# Make your bot read the book!
kanyebot.read(tweets)

kanyebot.twitter_login(consumer_key, consumer_secret, access_key,
                       access_secret)

# Set some parameters for your bot
targetstring = 'KanyeToTheBot'
keywords = ['kim', 'pablo', 'wavy', 'bill', 'cosby']
prefix = None
Ejemplo n.º 19
0
#Bot basado en MarkovBot con la funcion autoreply_start, tomando como fuente de texto el Manifiesto "Zorra Mutante" del colectivo ciberfeminista VNS Matrix

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import time
import sys
from markovbot import MarkovBot

reload(sys)
sys.setdefaultencoding('utf-8')

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Make your bot read the book!
tweetbot.read(
    'https://github.com/gini10/akelarreciberfeminista/blob/master/bots/ZorraMutante.py'
)

my_first_text = tweetbot.generate_text(
    10, seedword=[u'código', u'límite', u'hay'])
print(u'\ntweetbot says: "%s"' % (my_first_text))

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = '[ copy this value from Consumer Settings ]'
# Consumer Secret (API Secret)
cons_secret = '[ copy this value from Consumer Settings ]'
# Access Tokenf
Ejemplo n.º 20
0
import collections
import os
import re
import time
from collections import defaultdict
from heapq import nlargest
from string import punctuation

import nltk
from markovbot import MarkovBot
from nltk import word_tokenize
from nltk.corpus import stopwords
from nltk.tokenize import sent_tokenize, word_tokenize

bot = MarkovBot()
bot2 = MarkovBot()
bot3 = MarkovBot()
bot4 = MarkovBot()
''' 
clean data for shakespeare

data = open('shakeComplete.txt', 'r').read()
fOne = ''.join(filter(lambda x: not x.isdigit(), data))
fTwo = (re.sub('[0-9\W]+', " ", fOne))
fThree = (fTwo.replace("SCENE", " "))
fFour = (fThree.replace("ACT", " "))
finalDataShake = fFour
'''
'''freud'''
''' 
i need to clean this up a lot and add organon
Ejemplo n.º 21
0
import os
from markovbot import MarkovBot

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
headline = os.path.join(dirname, 'hosking_headlines.txt')
comment = os.path.join(dirname, 'hosking_comments.txt')

gen = input('Generate headline? Y/N\n')
while True:
    if gen == 'Y' or gen == 'y':
        tweetbot.read(headline)
        gen_head = tweetbot.generate_text(10)
        print(u'\nMike Hosking: %s' % (gen_head))

        tweetbot.clear_data()
        tweetbot.read(comment)
        gen_comm = tweetbot.generate_text(30)
        print('COMMENT: %s' % (gen_comm))
        gen = input(u'\nGenerate headline? Y/N\n')

    elif gen == 'N' or gen == 'n':
        exit()

    elif gen != 'Y' and gen != 'N' and gen != 'y' and gen != 'n':
        print(u'\nInput was not Y or N')
        gen = input(u'\nGenerate headline? Y/N\n')
Ejemplo n.º 22
0
import os
from markovbot import MarkovBot
import json

tweetbot = MarkovBot()

dirname = os.path.dirname(os.path.abspath(__file__))
book = os.path.join(dirname, 'The Dhammapada.txt')
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['way', 'He'])
print("tweetbot says:")
print(my_first_text)

json_data = {}

with open("config.json") as json_file:
    json_data = json.loads(json_file.read())
    print(json_data)

consumer_key = json_data['consumer_key']
consumer_secret = json_data['consumer_secret']
access_token = json_data['access_token']
access_token_secret = json_data['access_token_secret']
tweetbot.twitter_login(consumer_key, consumer_secret, access_token,
                       access_token_secret)

targetstring = 'Buddhism'
keywords = ['man', 'always', 'truth', 'ignorant', 'lives']
prefix = None
suffix = '#BuddhismSays'
Ejemplo n.º 23
0
# import config # contains the API keys and access tokens
import twitter
import os
import time

from markovbot import MarkovBot

# Initialise the MarkovBot instance
tweetbot = MarkovBot()

# Get the seinfeld transcripts and read
dirname = os.path.dirname(os.path.abspath(__file__))
textFile = os.path.join(dirname, 'seinfelf.txt')
tweetbot.read(textFile)

# Text Generations

# Log in to Twitter
consumer_key = os.environ.get('cons_key')
consumer_key_secret = os.environ.get('cons_secret')
access_token = os.environ.get('access_token')
access_token_secret = os.environ.get('access_token_secret')
tweetbot.twitter_login(consumer_key, consumer_key_secret, access_token,
                       access_token_secret)

# Start periodically tweeting
while True:
    minutesToWait = 120
    secondsToWait = 60 * minutesToWait
    tweetbot.twitter_tweeting_start(days=0,
                                    hours=0,
Ejemplo n.º 24
0
import os 
from markovbot import MarkovBot
#import twitter

#initalise a MarkovBot instance
tweetbot = MarkovBot()

#get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))

#construct the path to the book
book = os.path.join(dirname, 'sherlock.txt')

#make your bot read the book!
tweetbot.read(book)


my_first_text = tweetbot.generate_text(25, seedword=['Irene', 'watson','Mycroft'])
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = 'AqYyIzu5jXXYhubZI83WtfmnV'
# Consumer Secret (API Secret)
cons_secret = 'QyqofLZtVJSjgS4L7EltzaxPJrcz23vgyN8zMNZ4dm88HdM1c6'
# Access Token
access_token = '751058612051648514-FGw6PEjNmkIdbWqrC3MfhVYEe8KJyCF'
# Access Token Secret
access_token_secret = 'PFKpoM7ra8rziOc0gs9ci4pT2TGRvn0fRXw5gw8PzYFnp'
Ejemplo n.º 25
0
#!/usr/bin/env python
import os
import time
import os, ssl

print os.environ['cons_key']
print os.environ['cons_secret']
print os.environ['access_token']
print os.environ['access_token_secret']

from markovbot import MarkovBot
#Initialize a MarkovBot instance
tweetbot = MarkovBot()
dirname = os.path.dirname(os.path.abspath("tmg copy.text"))
# Construct the path to the book
book = os.path.join(dirname, 'tmg copy.text')
# Make your bot read the book!
tweetbot.read(book)
my_first_text = tweetbot.generate_text(25,
                                       seedword=[
                                           'you',
                                           'I am',
                                           'going to',
                                           'my',
                                           'love',
                                       ])
print(my_first_text)
tweetbot.twitter_login(os.environ['cons_key'], os.environ['cons_secret'],
                       os.environ['access_token'],
                       os.environ['access_token_secret'])
# Start periodically tweeting
Ejemplo n.º 26
0
Archivo: app.py Proyecto: zlr/markovbot
SLEEPING = int(os.environ["SLEEPING"])

# use tweetpy instead
try:
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
    api = tweepy.API(auth)
    logger.debug("Successfull auth")
except tweepy.TweepError as e:
    logger.debug("Failed to auth " + e.response.text)

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

try:
    # Get the current directory's path
    dirname = os.path.dirname(os.path.abspath(__file__))
    # Construct the path to the book
    book = os.path.join(dirname, TWEETS)
    # Make your bot read the book!
    tweetbot.read(book)
except:
    logging.debug("Failed to load book " + TWEETS)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
Ejemplo n.º 27
0
# This thing started with this tweet, if you're looking for someone to blame:
# https://twitter.com/jlsinc/status/798142993651867648

import time

from markovbot import MarkovBot
from secret import cons_key, cons_secret, access_token, access_token_secret

# Initialise a MarkovBot instance.
print(u"\nInitialising a new MarkovBot.")
tweetbot = MarkovBot()

# Generate a dict for all possible responses.
respdict = {u'Kendrick Lamar':( \
 u'HEDLEY! https://www.youtube.com/watch?v=8vjEnkQdaHM',
u'HEDLEY! http://jpg.party/http://i.imgur.com/lzLPfT3.gif',
u'HEDLEY! http://jpg.party/http://i.imgur.com/nAV7ueU.gif',
u'HEDLEY! http://jpg.party/http://i.imgur.com/3yt4gex.jpg',
u'HEDLEY! http://jpg.party/http://i.imgur.com/6COCqT1.jpg',
u'HEDLEY! http://jpg.party/http://i.imgur.com/C9pcsJI.jpg'
                               )}

# Add the respdict to the bot's database.
tweetbot.set_simple_responses(respdict)

# Log in to Twitter.
print(u"\nBot is logging in to Twitter.")
tweetbot.twitter_login(cons_key, cons_secret, \
 access_token, access_token_secret)

# Start auto-responding to tweets.
Ejemplo n.º 28
0
import os
import time
from markovbot import MarkovBot

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, 'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text()
print("tweetbot says:")
print(my_first_text)

# ALL YOUR SECRET STUFF!
# Consumer Key (API Key)
cons_key = ""
# Consumer Secret (API Secret)
cons_secret = ""
# Access Token
access_token = ""
# Access Token Secret
access_token_secret = ""

# Log in to Twitter
tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)
Ejemplo n.º 29
0
import os
from markovbot import MarkovBot

with open("tokens.txt", "r") as f:
    f_read = f.readline()
    access_token = ""  # f_read.split(" ")[2][0:-1]
    access_token_secret = ""
    cons_key = ""
    cons_secret = ""

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, 'ElonMuskTxt.txt')
# Make your bot read the book!
tweetbot.read(book)

my_first_text = tweetbot.generate_text(25, seedword=['space', 'Tesla'])
print("tweetbot says:")
print(my_first_text)

tweetbot.twitter_login(cons_key, cons_secret, access_token,
                       access_token_secret)

from time import sleep
while True:
    tweetbot.twitter_tweeting_start(days=0,
                                    hours=0,
Ejemplo n.º 30
0
import os

from markovbot import MarkovBot

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot()

# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'Freud_Dream_Psychology.txt')
# Make your bot read the book!
tweetbot.read(book)

# # # # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will
# 	simply try the first, and move on to the next if he can't find something
# 	that works.
my_first_text = tweetbot.generate_text(25,
                                       seedword=[u'dream', u'psychoanalysis'])

# Print your text to the console
print(u'\ntweetbot says: "%s"' % (my_first_text))
Ejemplo n.º 31
0
from markovbot import MarkovBot

###

# Argumento de entrada: nombre del fichero .json con las credenciales de twitter
try:
	text_filename = sys.argv[1]
except IndexError:
	print('Error: falta indicar el nombre del fichero .json con las credenciales de twitter')
	sys.exit(1)

# # # # #
# INITIALISE

# Initialise a MarkovBot instance
tweetbot = MarkovBot(chainlength=4)
# Get the current directory's path
dirname = os.path.dirname(os.path.abspath(__file__))
# Construct the path to the book
book = os.path.join(dirname, u'texto_ejemplo.txt')
# Make your bot read the book!
tweetbot.read(book)


# # #
# TEXT GENERATION

# Generate text by using the generate_text method:
# 	The first argument is the length of your text, in number of words
# 	The 'seedword' argument allows you to feed the bot some words that it
# 	should attempt to use to start its text. It's nothing fancy: the bot will