Initial commit: 블로그 자동 수익 엔진 v2

- 수집봇: Google Trends, GitHub Trending, HN, Product Hunt, RSS 수집
  + 품질 점수(0-100) 시스템 + 6가지 폐기 규칙
- 발행봇: Blogger API v3 자동 발행 + 안전장치(팩트체크/위험키워드)
- 링크봇: 쿠팡 파트너스 HMAC 서명 + 자동 링크 삽입
- 분석봇: 색인률/CTR/14일성과 등 5대 핵심 지표 + Telegram 리포트
- 이미지봇: manual/request/auto 3가지 모드
  request 모드 — 주기적 프롬프트 전송 → Telegram으로 이미지 수령
- 스케줄러: APScheduler + Telegram 봇 명령 리스너

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sinmb79
2026-03-25 06:54:43 +09:00
commit 15eb007b5a
20 changed files with 4507 additions and 0 deletions

59
scripts/get_token.py Normal file
View File

@@ -0,0 +1,59 @@
"""
Google OAuth2 토큰 발급 스크립트
실행: python scripts/get_token.py
결과: credentials.json 필요, token.json 생성, refresh_token 출력
"""
import json
import os
import sys
from google_auth_oauthlib.flow import InstalledAppFlow
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
SCOPES = [
'https://www.googleapis.com/auth/blogger',
'https://www.googleapis.com/auth/webmasters',
]
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TOKEN_PATH = os.path.join(BASE_DIR, 'token.json')
CREDENTIALS_PATH = os.path.join(BASE_DIR, 'credentials.json')
def main():
if not os.path.exists(CREDENTIALS_PATH):
print(f"[ERROR] credentials.json 파일이 없습니다: {CREDENTIALS_PATH}")
print("Google Cloud Console에서 OAuth 클라이언트 ID를 생성하고")
print("credentials.json 을 C:\\blog-engine\\ 에 저장하세요.")
sys.exit(1)
creds = None
if os.path.exists(TOKEN_PATH):
creds = Credentials.from_authorized_user_file(TOKEN_PATH, SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
print("[OK] 기존 토큰 갱신 완료")
else:
flow = InstalledAppFlow.from_client_secrets_file(CREDENTIALS_PATH, SCOPES)
creds = flow.run_local_server(port=0)
print("[OK] 새 토큰 발급 완료")
with open(TOKEN_PATH, 'w') as token_file:
token_file.write(creds.to_json())
token_data = json.loads(creds.to_json())
refresh_token = token_data.get('refresh_token', '')
print("\n" + "=" * 50)
print("토큰 발급 성공!")
print("=" * 50)
print(f"\nREFRESH_TOKEN:\n{refresh_token}")
print(f"\n이 값을 .env 파일의 GOOGLE_REFRESH_TOKEN 에 붙여넣으세요.")
print(f"\ntoken.json 저장 위치: {TOKEN_PATH}")
if __name__ == '__main__':
main()

64
scripts/setup.bat Normal file
View File

@@ -0,0 +1,64 @@
@echo off
echo ========================================
echo Blog Engine Setup
echo ========================================
REM Python venv 생성
python -m venv venv
if errorlevel 1 (
echo [ERROR] Python venv 생성 실패. Python 3.11 이상이 설치되어 있는지 확인하세요.
pause
exit /b 1
)
REM 패키지 설치
call venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements.txt
if errorlevel 1 (
echo [ERROR] 패키지 설치 실패.
pause
exit /b 1
)
REM .env 파일 복사 (없을 경우)
if not exist .env (
copy .env.example .env
echo [OK] .env 파일 생성됨. API 키를 입력해주세요: .env
)
REM data 폴더 생성
if not exist data\topics mkdir data\topics
if not exist data\collected mkdir data\collected
if not exist data\discarded mkdir data\discarded
if not exist data\pending_review mkdir data\pending_review
if not exist data\published mkdir data\published
if not exist data\analytics mkdir data\analytics
if not exist data\images mkdir data\images
if not exist data\drafts mkdir data\drafts
if not exist logs mkdir logs
REM Windows 작업 스케줄러에 scheduler.py 등록
set SCRIPT_PATH=%~dp0bots\scheduler.py
set PYTHON_PATH=%~dp0venv\Scripts\pythonw.exe
schtasks /query /tn "BlogEngine" >nul 2>&1
if errorlevel 1 (
schtasks /create /tn "BlogEngine" /tr "\"%PYTHON_PATH%\" \"%SCRIPT_PATH%\"" /sc onlogon /rl highest /f
echo [OK] Windows 작업 스케줄러에 BlogEngine 등록 완료
) else (
echo [INFO] BlogEngine 작업이 이미 등록되어 있습니다.
)
echo.
echo ========================================
echo Setup 완료!
echo ========================================
echo.
echo 다음 단계:
echo 1. .env 파일을 열고 API 키를 모두 입력하세요
echo 2. scripts\get_token.py 를 실행해서 Google OAuth 토큰을 발급받으세요
echo 3. config\blogs.json 에서 BLOG_MAIN_ID 를 실제 블로그 ID로 변경하세요
echo 4. python bots\scheduler.py 로 스케줄러를 시작하세요
echo.
pause