initial code+corpus commit
parent
10d9b894f5
commit
531673116c
@ -1 +1,7 @@
|
||||
# endlessgenghis
|
||||
# endlessgenghis
|
||||
|
||||
A Twitter bot which creates additional verses for Miike Snow's Genghis Khan.
|
||||
|
||||
To create the verses, run `python3 write_verses > tweets.txt`.
|
||||
|
||||
Then `python3 tweet.py` tweets one verse.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tweepy
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import random
|
||||
|
||||
load_dotenv()
|
||||
|
||||
def tweet():
|
||||
lines = open('tweets.txt').read().splitlines()
|
||||
new_tweet = random.choice(lines)
|
||||
if find_dup(new_tweet):
|
||||
tweet()
|
||||
else:
|
||||
return new_tweet
|
||||
|
||||
|
||||
def find_dup(tweet):
|
||||
with open('tweets.log', 'rt') as f:
|
||||
tweets = f.readlines()
|
||||
for line in tweets:
|
||||
if line.__contains__(tweet):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# Authenticate to Twitter
|
||||
auth = tweepy.OAuthHandler(os.getenv("APIKEY"), os.getenv("APISECRET"))
|
||||
auth.set_access_token(os.getenv("TOKEN"), os.getenv("TOKENSECRET"))
|
||||
|
||||
# Create API object
|
||||
api = tweepy.API(auth)
|
||||
|
||||
# Create a tweet
|
||||
new_tweet = tweet()
|
||||
if find_dup(new_tweet):
|
||||
new_tweet = tweet()
|
||||
|
||||
api.update_status(new_tweet)
|
||||
|
||||
# log to file
|
||||
file = open('tweets.log', 'a')
|
||||
file.write(new_tweet + "\n")
|
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import pronouncing
|
||||
import sys
|
||||
import random
|
||||
|
||||
file1 = open('famous_ppl.txt', 'r')
|
||||
people = file1.readlines()
|
||||
random.shuffle(people)
|
||||
|
||||
file2 = open('euphemisms.txt', 'r')
|
||||
euphemisms = file2.readlines()
|
||||
random.shuffle(euphemisms)
|
||||
|
||||
for person in people:
|
||||
for euphemism in euphemisms:
|
||||
person = person.rstrip()
|
||||
last_name = person.split(" ")[-1]
|
||||
for p in pronouncing.rhymes(last_name.rstrip()):
|
||||
last = euphemism.split(" ")[-1]
|
||||
if p == last.rstrip() and last_name.lower() != last.rstrip():
|
||||
euphemism = euphemism.rstrip()
|
||||
print(f'♫ I get a little bit {person} / Don\'t want you to {euphemism} / ♪ With nobody else but me')
|
Loading…
Reference in New Issue