Begin WhatsApp integration
This commit is contained in:
@@ -238,7 +238,23 @@ async def send_message_raw(service: str, recipient: str, text=None, attachments=
|
||||
if service_key == "signal":
|
||||
return await signalapi.send_message_raw(recipient, text, attachments or [])
|
||||
|
||||
if service_key in {"whatsapp", "instagram"}:
|
||||
if service_key == "whatsapp":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "send_message_raw"):
|
||||
try:
|
||||
runtime_result = await runtime_client.send_message_raw(
|
||||
recipient,
|
||||
text=text,
|
||||
attachments=attachments or [],
|
||||
)
|
||||
if runtime_result is not False and runtime_result is not None:
|
||||
return runtime_result
|
||||
except Exception as exc:
|
||||
log.warning("%s runtime send failed: %s", service_key, exc)
|
||||
log.warning("whatsapp send skipped: runtime is unavailable or not paired")
|
||||
return False
|
||||
|
||||
if service_key == "instagram":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "send_message_raw"):
|
||||
try:
|
||||
@@ -269,7 +285,18 @@ async def start_typing(service: str, recipient: str):
|
||||
await signalapi.start_typing(recipient)
|
||||
return True
|
||||
|
||||
if service_key in {"whatsapp", "instagram"}:
|
||||
if service_key == "whatsapp":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "start_typing"):
|
||||
try:
|
||||
result = await runtime_client.start_typing(recipient)
|
||||
if result:
|
||||
return True
|
||||
except Exception as exc:
|
||||
log.warning("%s runtime start_typing failed: %s", service_key, exc)
|
||||
return False
|
||||
|
||||
if service_key == "instagram":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "start_typing"):
|
||||
try:
|
||||
@@ -288,7 +315,18 @@ async def stop_typing(service: str, recipient: str):
|
||||
await signalapi.stop_typing(recipient)
|
||||
return True
|
||||
|
||||
if service_key in {"whatsapp", "instagram"}:
|
||||
if service_key == "whatsapp":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "stop_typing"):
|
||||
try:
|
||||
result = await runtime_client.stop_typing(recipient)
|
||||
if result:
|
||||
return True
|
||||
except Exception as exc:
|
||||
log.warning("%s runtime stop_typing failed: %s", service_key, exc)
|
||||
return False
|
||||
|
||||
if service_key == "instagram":
|
||||
runtime_client = get_runtime_client(service_key)
|
||||
if runtime_client and hasattr(runtime_client, "stop_typing"):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user