راسی اون مشکلمو اصلا یه جور دیگه حلش کردم
def telegram_request(method: str, payload: Dict[str, Any]) -> Dict[str, Any]:
url = f"{config.TELEGRAM_URL}{config.BOT_TOKEN}/{method}"
try:
response = requests.post(url, json=payload, timeout=30)
response.raise_for_status()
return response.json()
except requests.RequestException as e:
raise Exception(f"Request failed for {method}: {e}")
اینجوری تو فایل کمک کننده و فایل اصلیم مثلا اینجوری :
if text == "/check":
helper.telegram_request("sendMessage", {"chat_id": chat_id, "text": "Check OK ✅"}, )
elif text == "/start":
helper.telegram_request("sendMessage", {"chat_id": chat_id, "text": "Hey This Is ME :) "})
elif text == "/process":
process = helper.find_process()
helper.telegram_request('sendRichMessage', {
"chat_id": chat_id,
"rich_message": {
"markdown": pd.DataFrame(process, columns=['pid', 'path'], index=range(1, len(process) + 1)).to_markdown(),
},
})
else:
helper.telegram_request('forwardMessage',{"chat_id": config.ADMIN_ID,"from_chat_id": chat_id,"message_id": message_id,})
return "OK"