- Add Dockerfile with Python 3.13 + uv - Add Gitea Actions workflow for auto-build on push - Add deposit_api.py for balance management - Update api_server.py with domain registration endpoint Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""
|
|
Deposit API Client - telegram-bot-workers deposit API 연동
|
|
"""
|
|
|
|
import os
|
|
import httpx
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
DEPOSIT_API_URL = os.getenv("DEPOSIT_API_URL", "https://telegram-summary-bot.kappa-d8e.workers.dev")
|
|
DEPOSIT_API_SECRET = os.getenv("DEPOSIT_API_SECRET", "")
|
|
|
|
|
|
async def get_balance(telegram_id: str) -> dict:
|
|
"""사용자 예치금 잔액 조회"""
|
|
async with httpx.AsyncClient() as client:
|
|
response = await client.get(
|
|
f"{DEPOSIT_API_URL}/api/deposit/balance",
|
|
params={"telegram_id": telegram_id},
|
|
headers={"X-API-Key": DEPOSIT_API_SECRET},
|
|
timeout=10.0,
|
|
)
|
|
return response.json()
|
|
|
|
|
|
async def deduct_balance(telegram_id: str, amount: int, reason: str) -> dict:
|
|
"""사용자 예치금 차감"""
|
|
async with httpx.AsyncClient() as client:
|
|
response = await client.post(
|
|
f"{DEPOSIT_API_URL}/api/deposit/deduct",
|
|
json={
|
|
"telegram_id": telegram_id,
|
|
"amount": amount,
|
|
"reason": reason,
|
|
},
|
|
headers={"X-API-Key": DEPOSIT_API_SECRET},
|
|
timeout=10.0,
|
|
)
|
|
return response.json()
|