Skip to content

abcodeworks-team/auto-creat-article

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AB CodeWorks Logo

AB CodeWorks — Auto Article Bot

🤖 Bot Discord otomatis untuk generate artikel SEO + gambar AI + upload ke Blogger

TypeScript Discord.js Blogger OpenRouter


📋 Daftar Isi


✨ Fitur

  • 🧠 Generate Artikel AI — Artikel SEO otomatis menggunakan OpenRouter (Mistral, DeepSeek, dll)
  • 🎨 Generate Gambar AI — Ilustrasi otomatis menggunakan Replicate (SDXL)
  • 🖼️ Watermark Otomatis — Logo AB CodeWorks ditambahkan ke setiap gambar
  • 🚀 Upload ke Blogger — Posting otomatis ke blog Blogger kamu
  • 🔍 SEO Optimization — Meta description, keywords, Schema.org JSON-LD, slug, alt text
  • 📢 Log ke Discord — Notifikasi embed setiap artikel berhasil diposting
  • Auto Post — Cron job otomatis setiap Senin jam 09:00 WIB
  • 🔒 User Whitelist — Hanya user Discord tertentu yang bisa menggunakan bot

🛠 Teknologi

Teknologi Kegunaan
TypeScript Bahasa pemrograman utama
Discord.js v14 Framework bot Discord
OpenRouter API Generate artikel & metadata SEO via AI
Replicate API Generate gambar AI (SDXL)
Google Blogger API Upload artikel ke blog
Imgur API Hosting gambar untuk artikel
Jimp Image processing & watermark
node-cron Scheduled auto-post

📁 Struktur Proyek

ab-codeworks-article-bot/
├── src/
│   ├── index.ts                    # Entry point
│   ├── bot/
│   │   └── discord.ts              # Bot Discord (event handler & cron)
│   ├── config/
│   │   └── keys.ts                 # Konfigurasi environment variables
│   ├── modules/
│   │   ├── addWatermark.ts         # Tambah watermark ke gambar
│   │   ├── articleGenerator.ts     # Generate artikel via AI
│   │   ├── imageGenerator.ts       # Generate gambar via AI
│   │   └── uploadToBlogger.ts      # Upload artikel ke Blogger
│   └── utils/
│       └── helper.ts               # Utility functions (SEO, formatting)
├── dist/                           # Compiled JavaScript (auto-generated)
├── temp/
│   ├── generated/                  # Gambar mentah dari AI
│   └── with_watermark/            # Gambar dengan watermark
├── logo.png                        # Logo untuk watermark
├── .env                            # Environment variables (JANGAN di-commit)
├── .env.example                    # Contoh environment variables
├── .gitignore
├── tsconfig.json
├── package.json
└── README.md

📦 Prasyarat

Sebelum memulai, pastikan kamu sudah memiliki:


🔧 Instalasi

1. Clone Repository

https://github.com/abcodeworks-cod/auto-creat-article.git
cd auto-creat-article

2. Install Dependencies

npm install

3. Build TypeScript

npm run build

⚙️ Konfigurasi

1. Discord Bot

  1. Buka Discord Developer Portal
  2. Klik "New Application" → beri nama (contoh: AB CodeWorks Bot)
  3. Masuk ke menu "Bot" → klik "Add Bot""Yes, do it!"
  4. Klik "Reset Token"copy token (simpan baik-baik!)
  5. Di bagian "Privileged Gateway Intents", aktifkan:
    • Message Content IntentWAJIB AKTIF (untuk membaca command)
  6. Masuk ke menu "OAuth2""URL Generator":
    • Scopes: bot
    • Bot Permissions:
      • View Channels - melihat channel
      • Send Messages - mengirim pesan
      • Embed Links - mengirim embed (untuk /help dan log)
      • Read Message History - membaca riwayat pesan
  7. Copy URL yang dihasilkan → buka di browser → pilih server → Authorize

Catatan Penting:

  • Message Content Intent adalah privileged intent yang wajib diaktifkan agar bot bisa membaca isi pesan
  • Tanpa intent ini, bot tidak akan bisa mendeteksi command artikel: dan /help
  • Bot ini hanya menggunakan scope bot (tidak perlu applications.commands karena menggunakan message-based commands)

2. OpenRouter API

  1. Daftar di openrouter.ai
  2. Masuk ke DashboardKeys → buat API key baru
  3. Copy API key

3. Google Blogger API

  1. Buka Google Cloud Console
  2. Buat project baru atau pilih project yang ada
  3. Aktifkan Blogger API v3
  4. Buat OAuth 2.0 Credentials (Client ID + Client Secret)
  5. Gunakan OAuth Playground untuk mendapatkan Refresh Token
    • Scope: https://www.googleapis.com/auth/blogger
  6. Dapatkan Blog ID dari URL Blogger kamu:
    https://www.blogger.com/blog/posts/1234567890  ← ini Blog ID kamu
    

4. Imgur API

  1. Daftar aplikasi di Imgur API Registration
  2. Authorization type: OAuth 2 authorization without a callback URL
  3. Copy Client ID

5. Replicate API

  1. Daftar di replicate.com
  2. Masuk ke AccountAPI tokens → buat token baru
  3. Copy API token

6. File .env

Salin file .env.example menjadi .env:

cp .env.example .env

Lalu isi semua variabel:

# Discord Bot
DISCORD_BOT_TOKEN=token_bot_discord_kamu
DISCORD_LOG_CHANNEL_ID=id_channel_log_kamu

# AI (OpenRouter)
OPENROUTER_API_KEY=sk-or-v1-xxxxx

# Google Blogger
BLOGGER_CLIENT_ID=xxxxx.apps.googleusercontent.com
BLOGGER_CLIENT_SECRET=GOCSPX-xxxxx
BLOGGER_REFRESH_TOKEN=1//xxxxx
BLOGGER_BLOG_ID=1234567890

# Imgur (Image Hosting)
IMGUR_CLIENT_ID=xxxxx

# Replicate (AI Image Generation)
REPLICATE_API_TOKEN=r8_xxxxx

# Izin User (Discord User ID, pisahkan koma)
ALLOWED_DISCORD_IDS=123456789,987654321,CRON

⚠️ PENTING: Tambahkan CRON di ALLOWED_DISCORD_IDS jika ingin mengaktifkan auto-post.

Cara mendapatkan Discord User ID:

  1. Aktifkan Developer Mode di Discord (Settings → Advanced → Developer Mode)
  2. Klik kanan pada username → Copy User ID

Cara mendapatkan Discord Channel ID:

  1. Aktifkan Developer Mode
  2. Klik kanan pada channel → Copy Channel ID

🚀 Cara Menjalankan

Development Mode (dengan hot-reload)

npm run dev

Production Mode

# Build TypeScript ke JavaScript
npm run build

# Jalankan bot
npm start

Menggunakan PM2 (untuk server/production)

# Install PM2
npm install -g pm2

# Jalankan bot
pm2 start dist/index.js --name "ab-codeworks-bot"

# Lihat status
pm2 status

# Lihat log
pm2 logs ab-codeworks-bot

# Restart
pm2 restart ab-codeworks-bot

💬 Cara Menggunakan

Daftar Command

Bot mendukung beberapa command berikut:

Command Deskripsi
/help atau !help atau help Menampilkan panduan penggunaan bot
artikel: <topik> Generate artikel SEO + gambar AI + upload ke Blogger

📖 Lihat Panduan

Kirim salah satu dari command berikut di Discord:

/help
!help
help

Bot akan membalas dengan embed berisi panduan lengkap penggunaan bot.

📝 Generate Artikel Manual

Kirim pesan di Discord channel manapun tempat bot berada:

artikel: cara membuat website dengan React

Bot akan otomatis:

  1. 🧠 Generate artikel SEO menggunakan AI
  2. 🎨 Generate gambar ilustrasi AI
  3. 🖼️ Tambahkan watermark logo AB CodeWorks
  4. 🚀 Upload artikel ke Blogger
  5. 📢 Kirim notifikasi embed ke channel log

Format Command

artikel: <topik yang diinginkan>

Contoh:

artikel: tips belajar programming untuk pemula
artikel: review smartphone terbaru 2025
artikel: manfaat olahraga pagi untuk kesehatan

⏰ Auto Post (Cron)

Bot akan otomatis membuat dan memposting artikel trending setiap hari Senin jam 09:00 WIB.

Untuk mengaktifkan fitur ini:

  1. Pastikan CRON ada di ALLOWED_DISCORD_IDS
  2. Pastikan REPLICATE_API_TOKEN sudah diisi di .env

Untuk menonaktifkan, hapus CRON dari ALLOWED_DISCORD_IDS.

💡 Tips: Kamu bisa mengubah jadwal cron di file src/bot/discord.ts:

// Format: detik menit jam tanggal bulan hari
cron.schedule('0 9 * * 1', async () => { ... });  // Senin 09:00
cron.schedule('0 9 * * *', async () => { ... });  // Setiap hari 09:00
cron.schedule('0 */6 * * *', async () => { ... }); // Setiap 6 jam

🔍 Troubleshooting

Masalah Solusi
Bot tidak merespon Pastikan Message Content Intent aktif di Discord Developer Portal
❌ Maaf, kamu tidak diizinkan Tambahkan Discord User ID kamu ke ALLOWED_DISCORD_IDS
Gambar tidak muncul Periksa REPLICATE_API_TOKEN di .env
Upload Blogger gagal Periksa BLOGGER_REFRESH_TOKEN — mungkin expired, generate ulang
TypeScript build error Jalankan rm -rf dist && npm run build
Module not found Jalankan npm install ulang

📄 Lisensi

Proyek ini dibuat oleh AB CodeWorks.


Made with ❤️ by AB CodeWorks
Auto Article Generator — SEO Optimized — AI Powered

About

AB CodeWorks Auto Article Bot — Generate SEO articles, create AI images, add watermarks, and publish directly to Blogger.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Contributors