-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
38 lines (27 loc) · 1000 Bytes
/
bot.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
32
33
34
35
36
37
38
#import sys
import tweepy
from datetime import date
from messages import get_message
import gspread
import json
from oauth2client.service_account import ServiceAccountCredentials
from os import environ
Consumer_key= environ['Consumer_key']
Consumer_secret = environ['Consumer_secret']
Access_key = environ['Access_key']
Access_secret = environ['Access_secret']
json_creds = environ['google_cred']
creds_dict = json.loads(json_creds)
auth = tweepy.OAuthHandler(Consumer_key, Consumer_secret)
auth.set_access_token(Access_key, Access_secret)
api = tweepy.API(auth)
scopes = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds_dict["private_key"] = creds_dict["private_key"].replace("\\\\n", "\n")
creds = ServiceAccountCredentials.from_json_keyfile_dict(creds_dict, scopes)
gc = gspread.authorize(creds)
if __name__=='__main__':
message = get_message()
print("about to update status...")
try:
api.update_status(message)