https://github.com/greedyape420/afuera_x_bot
Autonomous Twitter bot replying with AI-generated sarcastic punchlines. Powered by the X API & OpenAI.
https://github.com/greedyape420/afuera_x_bot
ai automation bot bottleneck humour nodejs openai sarcasm sarcastic-tweets twitter twitter-api twitter-bot
Last synced: 2 months ago
JSON representation
Autonomous Twitter bot replying with AI-generated sarcastic punchlines. Powered by the X API & OpenAI.
- Host: GitHub
- URL: https://github.com/greedyape420/afuera_x_bot
- Owner: GreedyApe420
- License: mit
- Created: 2025-05-04T02:31:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-05T08:03:38.000Z (about 1 year ago)
- Last Synced: 2025-06-14T05:04:23.181Z (about 1 year ago)
- Topics: ai, automation, bot, bottleneck, humour, nodejs, openai, sarcasm, sarcastic-tweets, twitter, twitter-api, twitter-bot
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# đ€ AFUERA X BOT
Un bot Twitter (X) autonome qui surveille des comptes, rĂ©pond automatiquement "AFUERA đȘ" Ă leurs tweets, et gĂ©nĂšre des rĂ©ponses IA aux commentaires. BasĂ© sur l'API v2 de X et OpenAI (GPT).
---
## đ Structure du projet
```
AFUERA_X_BOT/
âââ accounts.txt # Liste des handles Ă surveiller (@ supprimĂ©)
âââ .env # Variables d'environnement sensibles
âââ auth.js # Script d'authentification OAuth2 PKCE (token OpenAI + X)
âââ main.js # Bot principal : boucle de polling + rĂ©ponses
âââ lib/
â âââ openaiClient.js # Initialisation client OpenAI
â âââ xApi.js # Fonctions Twitter (follow, tweet, reply, etc)
âââ utils/
â âââ logger.js # Logger stylĂ© (chalk + dayjs)
âââ README.md
```
---
## đ fichier .env (A crĂ©er toi mĂȘme)
```env
X_CLIENT_ID=... # Depuis portal X
X_CLIENT_SECRET=... # Si client confidentiel
X_ACCESS_TOKEN=... # Généré via auth.js
X_REFRESH_TOKEN=... # Idem
X_SELF_USER_ID=GreedyApe423 # Ton @ handle sans @
OPENAI_API_KEY=sk-... # Ton token OpenAI
POLL_INTERVAL_MS=120000 # Délai en ms entre chaque boucle (par défaut: 2min)
```
---
## â
Prérequis
* Node.js v20+
* Un compte Twitter Developer avec **OAuth 2.0 PKCE activé**
* Un client OpenAI (GPT-3.5 ou 4)
---
## đ Lancer le bot
### 1. Cloner & installer
```bash
git clone https://github.com/GreedyApe420/AFUERA_X_BOT.git
cd AFUERA_X_BOT
npm install
```
### 2. Ajouter les handles dans `accounts.txt`
```
GreedyApe420
elonmusk
@OpenAI # Les @ seront supprimés automatiquement
```
### 3. Récupérer les tokens OAuth2
```bash
node auth.js
```
* Ouvre une URL, se connecte Ă X et autorise l'appli.
* Les tokens seront écrits dans `.env`
### 4. Lancer le bot
```bash
node main.js
```
---
## âïž Fonctionnement
### â
Suivi de comptes
* Appelle `GET /users/by/username`
* Suit les comptes via `POST /users/:id/following` (facultatif)
### đ Polling de tweets
* Appelle `GET /users/:id/tweets`
* Ignore réponses/retweets
* Mémorise le dernier tweet vu (in-memory)
### đ§ RĂ©action au tweet
* RĂ©pond instantanĂ©ment: `AFUERA đȘ`
* Cherche les réponses (replies): `GET /tweets/search/recent`
* Pour chaque reply :
* Envoie Ă GPT-4 via `openaiClient.generateResponse()`
* Répond à la reply (avec `replyToTweet()`) (désactivé à cause des limites API)
---
## â± Antispam & Rate Limits
| Action | Endpoint | Délai imposé |
| ------------------ | ---------------------- | ------------ |
| Lire tweets | GET /users/\:id/tweets | 5 sec |
| Lire réponses | GET /tweets/search | 5 sec |
| Poster une réponse | POST /tweets | 45 sec |
* Géré avec **Bottleneck** + Group par user.
* Chaque type de requĂȘte a sa propre file.
* Le polling est répété toutes les 2 minutes (modifiable).
---
## đ§ OpenAI
* Utilise GPT-4 ou GPT-3.5
* Appelle `generateResponse(replyText)` pour chaque réponse utilisateur (désactivé)
* Répond avec humour/sarcasme selon les prompts (configurable).
---
## đ§Ș DĂ©ploiement VPS
* Lancer `auth.js` en local avec tunnel ou domaine configuré dans `Callback URL`
* Puis copier `.env` sur VPS
* Lancer `node main.js` sur le VPS via `pm2`, `screen` ou `nohup`
```bash
pm install -g pm2
pm2 start main.js --name afuera-bot
```
---
## đ SĂ©curitĂ©
* `.env` doit ĂȘtre dans `.gitignore`
* Les tokens ont une durée de 2h, mais le `refresh_token` permet de renouveler sans repasser par l'auth
* Le script dâauth gĂšre tout automatiquement
---
## đ Licence
MIT
---
## đ Auteur
* Créateur : [@GreedyApe420](https://twitter.com/GreedyApe420)
* Projet AFUERAâą â
* Pour toute question : DM ou issue GitHub