mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
Finish integrating command registry
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
import tweepy
|
||||
"""A module that contains a command to send a tweet."""
|
||||
import os
|
||||
|
||||
import tweepy
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from autogpt.commands.command import command
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
def send_tweet(tweet_text):
|
||||
@command(
|
||||
"send_tweet",
|
||||
"Send Tweet",
|
||||
'"text": "<text>"',
|
||||
)
|
||||
def send_tweet(tweet_text: str) -> str:
|
||||
"""
|
||||
A function that takes in a string and returns a response from create chat
|
||||
completion api call.
|
||||
|
||||
Args:
|
||||
tweet_text (str): Text to be tweeted.
|
||||
|
||||
Returns:
|
||||
A result from sending the tweet.
|
||||
"""
|
||||
consumer_key = os.environ.get("TW_CONSUMER_KEY")
|
||||
consumer_secret = os.environ.get("TW_CONSUMER_SECRET")
|
||||
access_token = os.environ.get("TW_ACCESS_TOKEN")
|
||||
@@ -20,6 +39,6 @@ def send_tweet(tweet_text):
|
||||
# Send tweet
|
||||
try:
|
||||
api.update_status(tweet_text)
|
||||
print("Tweet sent successfully!")
|
||||
return "Tweet sent successfully!"
|
||||
except tweepy.TweepyException as e:
|
||||
print("Error sending tweet: {}".format(e.reason))
|
||||
return f"Error sending tweet: {e.reason}"
|
||||
|
||||
Reference in New Issue
Block a user