|
@@ -14,11 +14,6 @@ API_BASE_URL = "https://visafly.top"
|
|
|
BEARER_TOKEN = "tok_e946329a60ff45ba807f3f41b0e8b7fc"
|
|
BEARER_TOKEN = "tok_e946329a60ff45ba807f3f41b0e8b7fc"
|
|
|
MAX_ATTEMPTS = 5
|
|
MAX_ATTEMPTS = 5
|
|
|
|
|
|
|
|
-DEFAULT_TG_TOKEN = "6771183256:AAEd0Tenq4z6hk5toUGrCpEVPfP00bpYT1s"
|
|
|
|
|
-DEFAULT_WECHAT_TOKEN = "a8f79817-e18b-4739-8459-adb2ed5e2e32"
|
|
|
|
|
-DEFAULT_WA_API_KEY = "51fc877539064f5882fae0f6f0661123"
|
|
|
|
|
-DEFAULT_WA_SESSION = "default"
|
|
|
|
|
-
|
|
|
|
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
|
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
|
|
|
logger = logging.getLogger("Iris")
|
|
logger = logging.getLogger("Iris")
|
|
|
|
|
|
|
@@ -131,9 +126,8 @@ class IrisWorker:
|
|
|
async def send_wechat(self, task_payload: Dict) -> bool:
|
|
async def send_wechat(self, task_payload: Dict) -> bool:
|
|
|
try:
|
|
try:
|
|
|
content = render_wechat_markdown(task_payload.get("template_id"), task_payload.get("payload", {}))
|
|
content = render_wechat_markdown(task_payload.get("template_id"), task_payload.get("payload", {}))
|
|
|
- api_token = task_payload.get("api_token") or DEFAULT_WECHAT_TOKEN
|
|
|
|
|
- async with self.session.post(f"{API_BASE_URL}/api/wechat/send_markdown",
|
|
|
|
|
- json={"api_token": api_token, "message": content}) as resp:
|
|
|
|
|
|
|
+ async with self.session.post(f"{API_BASE_URL}/api/wechat/send_markdown_no_token",
|
|
|
|
|
+ json={"message": content}) as resp:
|
|
|
if resp.status == 200: return True
|
|
if resp.status == 200: return True
|
|
|
await self._log_response_error(resp, "WeChat Dispatch")
|
|
await self._log_response_error(resp, "WeChat Dispatch")
|
|
|
return False
|
|
return False
|
|
@@ -144,12 +138,11 @@ class IrisWorker:
|
|
|
async def send_whatsapp(self, task_payload: Dict) -> bool:
|
|
async def send_whatsapp(self, task_payload: Dict) -> bool:
|
|
|
try:
|
|
try:
|
|
|
content = render_whatsapp_text(task_payload.get("template_id"), task_payload.get("payload", {}))
|
|
content = render_whatsapp_text(task_payload.get("template_id"), task_payload.get("payload", {}))
|
|
|
- api_key = task_payload.get("api_key") or DEFAULT_WA_API_KEY
|
|
|
|
|
recs = task_payload.get("receivers", [])
|
|
recs = task_payload.get("receivers", [])
|
|
|
success = True
|
|
success = True
|
|
|
for r in recs:
|
|
for r in recs:
|
|
|
- data = {"session": DEFAULT_WA_SESSION, "chat_id": r, "message": content, "api_key": api_key}
|
|
|
|
|
- async with self.session.post(f"{API_BASE_URL}/api/whatsapp/send", json=data) as resp:
|
|
|
|
|
|
|
+ data = {"chat_id": r, "message": content}
|
|
|
|
|
+ async with self.session.post(f"{API_BASE_URL}/api/whatsapp/send_no_token", json=data) as resp:
|
|
|
if resp.status != 200:
|
|
if resp.status != 200:
|
|
|
await self._log_response_error(resp, f"WhatsApp to {r}")
|
|
await self._log_response_error(resp, f"WhatsApp to {r}")
|
|
|
success = False
|
|
success = False
|
|
@@ -162,11 +155,10 @@ class IrisWorker:
|
|
|
try:
|
|
try:
|
|
|
data = task_payload.get("payload", {})
|
|
data = task_payload.get("payload", {})
|
|
|
content = render_telegram_html(task_payload.get("template_id"), data)
|
|
content = render_telegram_html(task_payload.get("template_id"), data)
|
|
|
- api_token = task_payload.get("api_token") or DEFAULT_TG_TOKEN
|
|
|
|
|
chat_id = task_payload.get("chat_id") or data.get("chat_id")
|
|
chat_id = task_payload.get("chat_id") or data.get("chat_id")
|
|
|
if not chat_id: return False
|
|
if not chat_id: return False
|
|
|
- async with self.session.post(f"{API_BASE_URL}/api/tg/send_message",
|
|
|
|
|
- json={"chat_id": str(chat_id), "api_token": api_token, "message": content}) as resp:
|
|
|
|
|
|
|
+ async with self.session.post(f"{API_BASE_URL}/api/tg/send_message_no_token",
|
|
|
|
|
+ json={"chat_id": str(chat_id), "message": content}) as resp:
|
|
|
if resp.status == 200: return True
|
|
if resp.status == 200: return True
|
|
|
await self._log_response_error(resp, "Telegram Dispatch")
|
|
await self._log_response_error(resp, "Telegram Dispatch")
|
|
|
return False
|
|
return False
|
|
@@ -238,4 +230,4 @@ if __name__ == "__main__":
|
|
|
except KeyboardInterrupt:
|
|
except KeyboardInterrupt:
|
|
|
logger.info("Iris stopped by user.")
|
|
logger.info("Iris stopped by user.")
|
|
|
except Exception:
|
|
except Exception:
|
|
|
- logger.critical(f"Iris Engine Crashed: {traceback.format_exc()}")
|
|
|
|
|
|
|
+ logger.critical(f"Iris Engine Crashed: {traceback.format_exc()}")
|