def repeat_tweet(chains):
    """"""
    response = raw_input('Enter to tweet again (q to quit): ')
    if response == '':
        next_tweet = markov.make_text(chains, int(argv[2]))
        api.PostUpdate(next_tweet)
        print next_tweet
        repeat_tweet(chains)
    else:
        pass
Example #2
0
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('ham me'):
        filename = sys.argv[1:]
        raw_text = markov.open_and_read_file(filename)
        markov_chains = markov.make_chains(raw_text)
        markov_text = markov.make_text(markov_chains)
        await message.channel.send(markov_text)
Example #3
0
def repeat_tweet(chains):
    """"""
    response = raw_input('Enter to tweet again (q to quit): ')
    if response == '':
        next_tweet = markov.make_text(chains, int(argv[2]))
        api.PostUpdate(next_tweet)
        print next_tweet
        repeat_tweet(chains)
    else:
        pass
def first_tweet():
    input_path = argv[1]

    # Open the file and turn it into one long string
    input_text = markov.open_and_read_file(input_path)

    # Get a Markov chain
    chains = markov.make_chains(input_text, int(argv[2]))

    new_tweet = markov.make_text(chains, int(argv[2]))
    api.PostUpdate(new_tweet)
    print new_tweet
    return chains
Example #5
0
def first_tweet():
    input_path = argv[1]

    # Open the file and turn it into one long string
    input_text = markov.open_and_read_file(input_path)

    # Get a Markov chain
    chains = markov.make_chains(input_text, int(argv[2]))

    new_tweet = markov.make_text(chains, int(argv[2]))
    api.PostUpdate(new_tweet)
    print new_tweet
    return chains
Example #6
0
def searches_user():
    """Gets username input and generates tweet via Markov chains.
    
    Validates twitter user: if user is not private, does not exist,
    or does not have enough tweets.

    """

    username = request.args.get('username')

    size = int(request.args.get('chain-size'))

    tweets['username'] = username

    try:
        statuses = api.GetUserTimeline(screen_name=username,
                                       include_rts=False,
                                       count=200)
        
        text = ' '.join([s.text for s in statuses])

        if len(text) < size:
            tweets[username] = ['Invalid user! User is either not public \
                               or does not have enough tweets.']
        
        else:
            chains = markov.make_chains(text, size)

            random_text = markov.make_text(chains, size)

            tweets.setdefault(username, [])

            tweets[username].append(random_text)

    
    except twitter.TwitterError:
        tweets[username] = ['Please enter a valid Twitter user!']

    return jsonify(tweets)
Example #7
0
import os

import twitter

import markov

api = twitter.Api(
    consumer_key=os.environ['TWITTER_CONSUMER_KEY'],
    consumer_secret=os.environ['TWITTER_CONSUMER_SECRET'],
    access_token_key=os.environ['TWITTER_ACCESS_TOKEN_KEY'],
    access_token_secret=os.environ['TWITTER_ACCESS_TOKEN_SECRET'])

#print api.VerifyCredentials()

while True:
    user_update_input = raw_input("Enter to tweet again [q to quit] > ")
    if user_update_input == "q" or user_update_input == "Q":
        break
    else:
        chains = 'gettysburg.txt'
        status = api.PostUpdate(markov.make_text(chains))
        print status.text
from markov import open_and_read_file, make_chains, make_text, char_limit
# from tweet_dumper import get_all_tweets

api = twitter.Api(
    consumer_key=os.environ['TWITTER_CONSUMER_KEY'],
    consumer_secret=os.environ['TWITTER_CONSUMER_SECRET'],
    access_token_key=os.environ['TWITTER_ACCESS_TOKEN_KEY'],
    access_token_secret=os.environ['TWITTER_ACCESS_TOKEN_SECRET'])

# print api.VerifyCredentials()

input_text = sys.argv[1]

text = open_and_read_file(input_text)
chains = make_chains(text)
long_text = make_text(chains)
tweet = char_limit(long_text)

status = api.PostUpdate(tweet)
print status.text

# tweet source brainstorm
#   Oscar Wilde
#   Mark Twain
#   Shakespeare
#   Miley Cyrus
#   Andy Borowitz
#   The Onion
#   Internation Declaration of Human Rights
#   Taylor Swift
#   Arrested Development
def char_line(char_dict, char_name):
    chains_char = markov.make_chains(char_dict[char_name])
    lines_char = markov.make_text(chains_char)
    index = lines_char.find(".")
    final_string = lines_char[:index + 1]
    return final_string
            char_dict[line_list[0]] = char_dict.get(line_list[0], [])
            char_dict[line_list[0]].append(line_list[1])

    for char in char_dict.keys():
        char_dict[char] = " ".join(char_dict[char])

    names_text = " ".join(names)
    names_dict = markov.make_chains(names_text, 2)

    return (names_dict, char_dict)


char_data = name_markov(script_lines)
# print script_lines
# print char_data[0]
name_str = markov.make_text(char_data[0])
# print name_str
name_order = name_str.split()
char_dict = char_data[1]

# run make_chains for every character's source text
# then run make_text on every character's chains dictionary


def char_line(char_dict, char_name):
    chains_char = markov.make_chains(char_dict[char_name])
    lines_char = markov.make_text(chains_char)
    index = lines_char.find(".")
    final_string = lines_char[:index + 1]
    return final_string
Example #11
0
import twitter
import os
import markov
import sys

api = twitter.Api(
    consumer_key=os.environ['TWITTER_CONSUMER_KEY'],
    consumer_secret=os.environ['TWITTER_CONSUMER_SECRET'],
    access_token_key=os.environ['TWITTER_ACCESS_TOKEN_KEY'],
    access_token_secret=os.environ['TWITTER_ACCESS_TOKEN_SECRET'])

print api.VerifyCredentials()

input_path = sys.argv[1]

# Open the file and turn it into one long string
input_text = markov.open_and_read_file(input_path)

# Get a Markov chain
chains = markov.make_chains(input_text)

# Produce random text
random_text = markov.make_text(chains)

# status = api.PostDirectMessage(random_text, screen_name='soylentbleen')  # this is how you send direct messages

status = api.PostUpdate(random_text)  # tweet to linked account
print status.text