Corrige MINIMAX_API_KEY via environment (não env_file)
This commit is contained in:
@@ -33,8 +33,82 @@ logger = logging.getLogger(__name__)
|
||||
import uuid
|
||||
import time
|
||||
import asyncio
|
||||
import sqlite3
|
||||
from session_manager import get_history, add_message, clear_history as sm_clear_history, set_orchestrator_pending, get_orchestrator_pending, clear_orchestrator_pending
|
||||
|
||||
# ── /btc command — BrainSteel Fin analysis ───────────────────────────────
|
||||
async def handle_btc(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
chat_id = update.effective_chat.id
|
||||
user_id = update.effective_user.id
|
||||
if ALLOWED_USER_ID and user_id != ALLOWED_USER_ID:
|
||||
return
|
||||
await update.message.reply_chat_action(action="typing")
|
||||
try:
|
||||
import requests
|
||||
# Fetch pipeline history + portfolio + latest run
|
||||
base = "https://office.reifonas.cloud"
|
||||
ph = requests.get(f"{base}/api/pipeline_history", verify=False, timeout=10).json()
|
||||
pf = requests.get(f"{base}/api/portfolio", verify=False, timeout=10).json()
|
||||
state = requests.get(f"{base}/api/state", verify=False, timeout=10).json()
|
||||
|
||||
# Build 10-line concise report
|
||||
lines = []
|
||||
lines.append("━━━━━━━━━━━━━━━━━━━━")
|
||||
lines.append("📊 BTC — BrainSteel Fin")
|
||||
|
||||
brief = state.get("brief", {})
|
||||
price = brief.get("price", "?")
|
||||
signal = brief.get("signal", "?")
|
||||
conf = brief.get("confidence", 0)
|
||||
rsi = brief.get("rsi", "?")
|
||||
chg24h = brief.get("change_24h", "?")
|
||||
fg = brief.get("fear_greed", "?")
|
||||
fg_class = brief.get("fear_greed_class", "?")
|
||||
funding = brief.get("funding_rate", "?")
|
||||
sup = brief.get("support", "?")
|
||||
res = brief.get("resistance", "?")
|
||||
|
||||
lines.append(f"BTC $ {price} | {signal} ({conf}% conf)")
|
||||
lines.append(f"RSI {rsi} | F&G {fg}/100 ({fg_class})")
|
||||
lines.append(f"4h {brief.get('change_4h','?')} | 24h {chg24h}%")
|
||||
lines.append(f"Funding {funding}% | Sup ${sup} | Res ${res}")
|
||||
|
||||
decio_state = state.get("decio", {})
|
||||
action = decio_state.get("action", "?")
|
||||
if action == "?": action = brief.get("signal", "HOLD")
|
||||
lines.append(f"Decisão: {action}")
|
||||
|
||||
# Portfolio
|
||||
bal = pf.get("current_balance", 10000)
|
||||
pnl = pf.get("total_pnl", 0)
|
||||
pnl_pct = pf.get("total_pnl_pct", 0)
|
||||
trades = pf.get("total_trades", 0)
|
||||
wins = pf.get("wins", 0)
|
||||
losses = pf.get("losses", 0)
|
||||
lines.append(f"Portfolio: ${bal:,.0f} ({pnl:+.2f} | {pnl_pct:+.2f}%)")
|
||||
lines.append(f"Trades: {trades} ({wins}W/{losses}L) | WinRate: {pf.get('win_rate',0):.0f}%")
|
||||
|
||||
# Compare with last 7 days of runs
|
||||
recent = [r for r in ph if r.get("decio_decision")][:7]
|
||||
hold_days = sum(1 for r in recent if "HOLD" in str(r.get("decio_decision","")))
|
||||
buy_days = sum(1 for r in recent if "BUY" in str(r.get("decio_decision","")))
|
||||
sell_days = sum(1 for r in recent if "SELL" in str(r.get("decio_decision","")))
|
||||
if recent:
|
||||
first_ts = recent[-1].get("started_at","?")[:10]
|
||||
last_ts = recent[0].get("started_at","?")[:10]
|
||||
lines.append(f"Últ. 7 ciclos: {hold_days}H/{buy_days}BUY/{sell_days}SELL")
|
||||
lines.append(f"Período: {first_ts} → {last_ts}")
|
||||
else:
|
||||
lines.append("Nenhuma execução registrada ainda.")
|
||||
|
||||
lines.append("━━━━━━━━━━━━━━━━━━━━")
|
||||
|
||||
reply = "\n".join(lines)
|
||||
await update.message.reply_text(reply, parse_mode='Markdown')
|
||||
except Exception as e:
|
||||
logger.error(f"/btc error: {e}")
|
||||
await update.message.reply_text(f"Erro ao obter dados BTC: {e}")
|
||||
|
||||
# ============================================================
|
||||
# CIRCUIT BREAKER — API degradation state
|
||||
# ============================================================
|
||||
@@ -273,6 +347,7 @@ if __name__ == '__main__':
|
||||
# Adiciona handlers
|
||||
application.add_handler(CommandHandler("limpar", clear_history))
|
||||
application.add_handler(CommandHandler("clear", clear_history))
|
||||
application.add_handler(CommandHandler("btc", handle_btc))
|
||||
application.add_handler(MessageHandler(filters.TEXT | filters.COMMAND, handle_message))
|
||||
application.add_handler(MessageHandler(filters.VOICE, handle_voice))
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ services:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:rw
|
||||
- /:/host_root:ro
|
||||
- ./data:/app/data
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- MINIMAX_API_KEY=sk-cp-siEwoNh9WA3Prxe6frpJ2HsXPje-gjt5jObhHloqqoO0FX0i9yP54N3zhY492GKu18l9XiANDiCoECU3t0uMtRODvkzzi93A2Rmtco6MjATrKNOEDR_bxa4
|
||||
networks:
|
||||
- coolify
|
||||
- ollama_net
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Tenta limpar processos conflitantes no host se tiver acesso privilegiado
|
||||
# Kills conflicting host processes (chroot lets us reach host namespace)
|
||||
if [ -d "/host_root" ]; then
|
||||
echo "Limpando processos conflitantes no HOST..."
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f telegram_bot.js" || true
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f bot_logic.py" || true
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f bridge_telegram.py" || true
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f bridge_telegram.py" 2>/dev/null || true
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f BotVPS.*main.py" 2>/dev/null || true
|
||||
chroot /host_root /bin/bash -c "pkill -9 -f watchdog.py" 2>/dev/null || true
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# Inicia a ponte do Telegram em background
|
||||
|
||||
Reference in New Issue
Block a user