Bot & Automation
jorgasisten
/root/hermes-projects/jorgasisten
get_status_or_qr.py
text
import http.client
import json
conn = http.client.HTTPConnection("localhost", 8082)
headers = {
'apikey': 'ApiKeyJorgAsisten2026',
'Content-Type': 'application/json'
}
# 1. Check connection state
try:
conn.request("GET", "/instance/connectionState/jorgasisten-wa", "", headers)
res = conn.getresponse()
state_data = res.read().decode("utf-8")
print("CONNECTION STATE:", state_data)
# 2. Get QR Code again (if not connected)
conn.request("GET", "/instance/connect/jorgasisten-wa", "", headers)
res2 = conn.getresponse()
connect_data = res2.read().decode("utf-8")
response_json = json.loads(connect_data)
base64_str = response_json.get("base64") or response_json.get("qrcode", {}).get("base64")
if base64_str:
with open("/root/hermes-projects/jorgasisten/data/qrcode.txt", "w") as f:
f.write(base64_str)
print("SUCCESS: Retrieved new QR Code and saved base64")
else:
print("CONNECT RESPONSE:", json.dumps(response_json, indent=2))
except Exception as e:
print("ERROR:", str(e))