Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aditeyas/grow-your-x

A bot that automatically tweets (posts) on Twitter (X).
https://github.com/aditeyas/grow-your-x

chatgpt chatgpt-bot flask openapi python python-bot twitter twitter-api twitter-bot

Last synced: 13 days ago
JSON representation

A bot that automatically tweets (posts) on Twitter (X).

Awesome Lists containing this project

README

        




grow-your-x


A bot that automatically tweets (posts) on Twitter (X).


I tweet about Technology, Programming/Coding, Anime, Nature and Travel.



Check status
ยท
Report Bug
ยท
Request Feature



Tech Stack







### How to make your own?

##### Testing the app

- Fork and clone the repo (Optional: Leave a โญ)
- Create a .env file at the root and paste the following

```
SECRET=
OPENAI_API_KEY=
OPENAI_ORGANIZATION_ID=
OPENAI_PROJECT_ID=
X_API_KEY=
X_API_KEY_SECRET=
X_ACCESS_TOKEN=
X_ACCESS_TOKEN_SECRET=
```

- Replace the key values with your key. Read about getting [OpenAi key](https://platform.openai.com/docs/overview) and [Twitter key](https://developer.x.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api)
- Create a virtual env (Optional)

```bash
python -m venv venv
source .venv/bin/activate
```

- Install the requirements

```bash
pip install -r requirements.txt
```

- Run your app

```bash
python main.py
```

- Test you app

```
curl -H 'Content-Type: application/json'
-d '{"secret" : ""}' \
-X POST \
/api/tweet
```

- If you get a success message, congratulations! ๐ŸŽ‰
- If you face any errors connect with me.

##### Personalizing your bot

You can personalize your bot by exploring [src/clients/OpenAI.py](https://github.com/aditeyaS/grow-your-x/blob/main/src/clients/OpenAI.py) and [src/service/generate_topic.py](https://github.com/aditeyaS/grow-your-x/blob/main/src/service/generate_topic.py)

##### Deploying your app

- Sign in/Sign up at [render.com](https://render.com/) (Recomended: use github to sign in/sign up)
- Create New web service and connect this repo
- In the **Start command** enter the following

```
gunicorn main:bot
```

- Add all the environemt variables
- Most likey your app will be deployed without errors

##### Setting up CRON job

- Go to your repository settings
- In the left sidebar, click on Secrets and variables > Actions
- Click the New repository secret button.
- In the Name enter - URL
- In the Secrte enter your POST endpoint which will look something like below

```
https://.onrender.com/api/tweet
```

- Again click the New repository secret button.
- In the Name enter - SECRET
- In the Secret enter -
- Go to the **cron-job.yml** file inside .github/workflows
- Under schedule update [cron](http://www.cronmaker.com/) according to your needs. (GitHub cron jobs run at UTC time)
- Push your code.

(FYI: You can also set this job through iPhone shortcut automation and many other ways)

### You are done. Happy Coding. ๐ŸŽ‰

You can check your logs on render if you face issues.