diff --git a/README.md b/README.md index 51a7cad..fdf7388 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ To build and use the bot, you'll need to: To make your own bot follow these steps: 1. Clone this repository on your local machine -2. Create a virtual environment in your project's root directory: `python3 -m venv venv && source venv/bin/activate` +2. Create a virtual environment in your project's root directory: `python -m venv venv` 3. Install the required libraries using pip: `pip install -r requirements.txt` 4. Create a file called `.env` in the root directory of your project. Put your twitter App keys there: ``` diff --git a/requirements.txt b/requirements.txt index fd2fbd4..6635d98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -tweepy==3.9.0 +tweepy==4.9.0 python-dotenv==0.14.0 \ No newline at end of file diff --git a/src/lambda_function.py b/src/lambda_function.py index 652d30d..7691d20 100644 --- a/src/lambda_function.py +++ b/src/lambda_function.py @@ -32,16 +32,17 @@ def lambda_handler(event, context): access_token_secret = os.getenv("ACCESS_TOKEN_SECRET") print("Authenticate") - auth = tweepy.OAuthHandler(consumer_key, consumer_secret) - auth.set_access_token(access_token, access_token_secret) - api = tweepy.API(auth) + client = tweepy.Client( + consumer_key=consumer_key, + consumer_secret=consumer_secret, + access_token=access_token, + access_token_secret=access_token_secret + ) print("Get tweet from csv file") tweets_file = ROOT / "tweets.csv" - recent_tweets = api.user_timeline()[:3] tweet = get_tweet(tweets_file) - - print(f"Post tweet: {tweet}") - api.update_status(tweet) + print(f"Post tweet: {tweet}") + client.create_tweet(text=tweet, user_auth=True) return {"statusCode": 200, "tweet": tweet}