Files
telegram-bot-workers/wrangler.toml
kappa 45e0677ab0 refactor: code quality improvements (P3)
## Type Safety
- Add zod runtime validation for external API responses
  * Namecheap API responses (domain-register.ts)
  * n8n webhook responses (n8n-service.ts)
  * User request bodies (routes/api.ts)
  * Replaced unsafe type assertions with safeParse()
  * Proper error handling and logging

## Dead Code Removal
- Remove unused callDepositAgent function (127 lines)
  * Legacy Assistants API code no longer needed
  * Now using direct code execution
  * File reduced from 469 → 345 lines (26.4% reduction)

## Configuration Management
- Extract hardcoded URLs to environment variables
  * Added 7 new vars in wrangler.toml:
    OPENAI_API_BASE, NAMECHEAP_API_URL, WHOIS_API_URL,
    CONTEXT7_API_BASE, BRAVE_API_BASE, WTTR_IN_URL, HOSTING_SITE_URL
  * Updated Env interface in types.ts
  * All URLs have fallback to current production values
  * Enables environment-specific configuration (dev/staging/prod)

## Dependencies
- Add zod 4.3.5 for runtime type validation

## Files Modified
- Configuration: wrangler.toml, types.ts, package.json
- Services: 11 TypeScript files with URL/validation updates
- Total: 15 files, +196/-189 lines

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 22:06:01 +09:00

50 lines
1.9 KiB
TOML

name = "telegram-summary-bot"
main = "src/index.ts"
compatibility_date = "2024-01-01"
[ai]
binding = "AI"
[vars]
SUMMARY_THRESHOLD = "20" # 프로필 업데이트 주기 (메시지 수)
MAX_SUMMARIES_PER_USER = "3" # 유지할 프로필 버전 수 (슬라이딩 윈도우)
N8N_WEBHOOK_URL = "https://n8n.anvil.it.com" # n8n 연동 (선택)
DOMAIN_OWNER_ID = "821596605" # 도메인 관리 권한 Telegram ID
DEPOSIT_ADMIN_ID = "821596605" # 예치금 관리 권한 Telegram ID
# API Endpoints
OPENAI_API_BASE = "https://gateway.ai.cloudflare.com/v1/d8e5997eb4040f8b489f09095c0f623c/telegram-bot/openai"
NAMECHEAP_API_URL = "https://namecheap-api.anvil.it.com"
WHOIS_API_URL = "https://whois-api-kappa-inoutercoms-projects.vercel.app"
CONTEXT7_API_BASE = "https://context7.com/api/v2"
BRAVE_API_BASE = "https://api.search.brave.com/res/v1"
WTTR_IN_URL = "https://wttr.in"
HOSTING_SITE_URL = "https://hosting.anvil.it.com"
[[d1_databases]]
binding = "DB"
database_name = "telegram-conversations"
database_id = "c285bb5b-888b-405d-b36f-475ae5aed20e"
[[kv_namespaces]]
binding = "RATE_LIMIT_KV"
id = "15bcdcbde94046fe936c89b2e7d85b64"
# Email Worker 설정 (SMS → 메일 수신)
# Cloudflare Dashboard에서 Email Routing 설정 필요:
# 1. Email > Email Routing > Routes
# 2. deposit@your-domain.com → Worker: telegram-summary-bot
# Cron Trigger: 매일 자정(KST) 실행 - 24시간 경과된 입금 대기 자동 취소
[triggers]
crons = ["0 15 * * *"] # UTC 15:00 = KST 00:00
# Secrets (wrangler secret put 으로 설정):
# - BOT_TOKEN: Telegram Bot Token
# - WEBHOOK_SECRET: Webhook 검증용 시크릿
# - OPENAI_API_KEY: OpenAI API 키
# - NAMECHEAP_API_KEY: namecheap-api 래퍼 인증 키 (도메인 추천용)
# - NAMECHEAP_API_KEY_INTERNAL: Namecheap API 키 (내부용)
# - BRAVE_API_KEY: Brave Search API 키
# - DEPOSIT_API_SECRET: Deposit API 인증 키 (namecheap-api 연동)