-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtweet.py
More file actions
30 lines (23 loc) · 975 Bytes
/
tweet.py
File metadata and controls
30 lines (23 loc) · 975 Bytes
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
#!/usr/bin/env python
import tweepy, time, os, sys, yaml
from generate_messages import genernate_messages
from generate_image import generate_image
# Load twitter credentials for this bot from config file
BOTCRED_FILE = '%s/.twurlrc' % os.path.expanduser('~')
with open(BOTCRED_FILE, 'r') as credfile:
full_config = yaml.load(credfile)
api_key = api_key = full_config['profiles']['win95promises'].keys()[0]
bot_creds = full_config['profiles']['win95promises'][api_key]
CONSUMER_KEY = bot_creds['consumer_key']
CONSUMER_SECRET = bot_creds['consumer_secret']
ACCESS_KEY = bot_creds['token']
ACCESS_SECRET = bot_creds['secret']
# Do actual authentication
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
# Generate image and tweet
BOTDIR = sys.path[0]
msgs, screen = genernate_messages(BOTDIR)
img = generate_image(msgs, screen, BOTDIR)
api.update_with_media('%s/tweetme.png' % BOTDIR)