Spaces:
Sleeping
Sleeping
Prudvireddy
commited on
Commit
•
7fcde6c
1
Parent(s):
154c276
Update tools.py
Browse files
tools.py
CHANGED
@@ -4,6 +4,19 @@ import requests
|
|
4 |
import json
|
5 |
import tempfile
|
6 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def generate_image(text):
|
9 |
|
|
|
4 |
import json
|
5 |
import tempfile
|
6 |
import os
|
7 |
+
import tweepy
|
8 |
+
|
9 |
+
def post_on_twitter(tweet, consumer_key, consumer_secret, access_token, access_token_secret):
|
10 |
+
|
11 |
+
try:
|
12 |
+
client = tweepy.Client(consumer_key=consumer_key, consumer_secret=consumer_secret,
|
13 |
+
access_token=access_token, access_token_secret=access_token_secret)
|
14 |
+
|
15 |
+
tweet = tweet.strip('"')
|
16 |
+
res = client.create_tweet(text=tweet)
|
17 |
+
return 'Twitter tweet generated and posted to user twitter account successfully'
|
18 |
+
except Exception as e:
|
19 |
+
return Exception(f"Failed to tweet: {e}")
|
20 |
|
21 |
def generate_image(text):
|
22 |
|