-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamplet.py
More file actions
35 lines (24 loc) · 813 Bytes
/
examplet.py
File metadata and controls
35 lines (24 loc) · 813 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
30
31
32
33
34
import tweepy
import datetime
import exampleb as bot
class TwitterAPI:
def __init__(self):
'''connect to twitter account'''
consumer_key = "XXXXXXXXXX"
consumer_secret = "XXXXXXXXXX"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
access_token = "XXXXXXXXXX"
access_token_secret = "XXXXXXXXXX"
auth.set_access_token(access_token, access_token_secret)
self.api = tweepy.API(auth)
def tweet(self, message):
'''post tweet'''
self.api.update_status(status=message)
def go_tweet():
'''generate, record, send tweet'''
twitter = TwitterAPI()
to_tweet=bot.get_string()
print(str(datetime.datetime.now()) + " " + to_tweet)
twitter.tweet(to_tweet)
if __name__ == '__main__':
go_tweet()