Skip to content

Instantly share code, notes, and snippets.

@danaabs
Last active April 1, 2016 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danaabs/6ea1b13a992075f417a6afa032eb513b to your computer and use it in GitHub Desktop.
Save danaabs/6ea1b13a992075f417a6afa032eb513b to your computer and use it in GitHub Desktop.
CruzTrumpSatan
from random import shuffle
from TwitterSearch import *
import sys
import random
import pprint
import re
debate = open("RepubDebate.txt", "r")
keep_phrases = ["TRUMP", "CRUZ"]
trump = list()
cruz = list()
host = list()
notes = list()
## find the lines from trump and cruz less than a 100 characters and put them in separate lists
for line in debate:
if len(line) < 100:
if "TRUMP" in line:
trump.append(line)
if "CRUZ" in line:
cruz.append(line)
if "KELLY" in line:
host.append(line)
if "(" in line:
notes.append(line)
trump_split = [item.split('TRUMP:')[1] for item in trump]
cruz_split = [item.split('CRUZ:')[1] for item in cruz]
host_split = [item.split('KELLY:')[1] for item in host]
##split all items with a '(' and take eveyrything BEFORE the \n
notes_split = [item.split('\n')[0] for item in notes]
trump_split_random = random.choice(trump_split)
cruz_split_random = random.choice(cruz_split)
satanTweets = list()
try:
tuo = TwitterUserOrder('s8n') # create a TwitterUserOrder
# it's about time to create TwitterSearch object again
ts = TwitterSearch(
consumer_key = 'x',
consumer_secret = 'x',
access_token = 'x',
access_token_secret = 'x'
)
# start asking Twitter about the timeline
for tweet in ts.search_tweets_iterable(tuo):
satanTweets.append(tweet['text'])
except TwitterSearchException as e: # catch all those ugly errors
print(e)
### split the items in the satanTweets list up by the the http term. Strip everything after that term, including that term (url for images)
satanTweets_strip = [item.split('http')[0].rstrip() for item in satanTweets]
kidsJokes = list()
try:
tuo = TwitterUserOrder('KidsWriteJokes') # create a TwitterUserOrder
# it's about time to create TwitterSearch object again
ts = TwitterSearch(
consumer_key = 'x',
consumer_secret = 'x',
access_token = 'x',
access_token_secret = 'x'
)
# start asking Twitter about the timeline
for tweet in ts.search_tweets_iterable(tuo):
kidsJokes.append(tweet['text'] )
except TwitterSearchException as e: # catch all those ugly errors
print(e)
####strip kids jokes of blank lines
kidsJokes_strip = [item.split('\n')[0].rstrip() for item in kidsJokes]
print ('\n')
print ('CRUZ: ' + random.choice(cruz_split))
print ('HOST:' + random.choice(host_split))
print ('TRUMP: ' + random.choice(trump_split))
print ('CRUZ: ' + random.choice(cruz_split))
print (random.choice(notes_split))
print ('TRUMP: ' + random.choice(trump_split))
print ('HOST:' + random.choice(host_split))
print ('CRUZ: ' + random.choice(satanTweets_strip))
print ('TRUMP: ' + random.choice(kidsJokes_strip))
print ('CRUZ: ' + random.choice(satanTweets_strip))
print ('TRUMP: ' + random.choice(kidsJokes_strip))
print ('CRUZ: ' + random.choice(satanTweets_strip))
print (random.choice(notes_split))
print ('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment