-
Notifications
You must be signed in to change notification settings - Fork 0
/
tilvera.py
31 lines (26 loc) · 1.21 KB
/
tilvera.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from random import choice
import sys, tweepy, time
from os import environ
# Accepts 3 .txt file parameters
with open(sys.argv[1], encoding="utf-8") as lo_hk, open(sys.argv[2], encoding="utf-8") as no_hk, open(sys.argv[3], encoding="utf-8") as no_ft, open(sys.argv[4], encoding="utf-8") as no_et:
lo_list = [word.strip() for word in lo_hk]
no_hk_list = [word.strip() for word in no_hk]
no_ft_list = [word.strip() for word in no_ft]
no_et_list = [word.strip() for word in no_et]
def tweet_the_thing(tweet):
CONSUMER_KEY = environ['CONSUMER_KEY']
CONSUMER_SECRET = environ['CONSUMER_SECRET']
ACCESS_KEY = environ['ACCESS_KEY']
ACCESS_SECRET = environ['ACCESS_SECRET']
tw_auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
tw_auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
tw_api = tweepy.API(tw_auth)
tw_api.update_status(tweet)
print(tweet)
# Outputs random words from the files in a sentence
def getTweet():
return f'Tilvera okkar er {choice(lo_list)} {choice(no_hk_list)}. Við erum {choice(no_ft_list)} og {choice(no_et_list)} okkar er {choice(no_et_list)}.'
# Only posts once every three hours
a = time.localtime()
if a.tm_hour % 3 == 0:
tweet_the_thing(getTweet())