-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (26 loc) · 751 Bytes
/
main.py
File metadata and controls
31 lines (26 loc) · 751 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
import tweepy
from bgapi import *
import os
# Getting sloks from Bhagavad Gita API
Slok = Slokm()
# Tweet Text limit
Post = (Slok[:277] + "..") if len(Slok) > 280 else Slok
# Authenticate to Twitter
consumer_key = os.environ["APIKey"]
consumer_secret = os.environ["APISecretKey"]
access_token = os.environ["AccessToken"]
access_token_secret = os.environ["AccessTokenSecret"]
client = tweepy.Client(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token=access_token,
access_token_secret=access_token_secret,
)
# Tweet Posting
try:
status = client.create_tweet(text=Post)
print(Post)
print(status)
print("\nPosted")
except Exception as error:
print(f"Error during authentication :\n{error}")