Implement business plans
This commit is contained in:
@@ -8,9 +8,12 @@ from core.clients.instagram import InstagramClient
|
||||
from core.clients.signal import SignalClient
|
||||
from core.clients.whatsapp import WhatsAppClient
|
||||
from core.clients.xmpp import XMPPClient
|
||||
from core.commands.base import CommandContext
|
||||
from core.commands.engine import process_inbound_message
|
||||
from core.messaging import history
|
||||
from core.models import PersonIdentifier
|
||||
from core.realtime.typing_state import set_person_typing_state
|
||||
from core.translation.engine import process_inbound_translation
|
||||
from core.util import logs
|
||||
|
||||
|
||||
@@ -91,6 +94,34 @@ class UnifiedRouter(object):
|
||||
|
||||
async def message_received(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Message received ({protocol}) {args} {kwargs}")
|
||||
identifier = kwargs.get("identifier")
|
||||
local_message = kwargs.get("local_message")
|
||||
message_text = str(kwargs.get("text") or "").strip()
|
||||
if local_message is None:
|
||||
return
|
||||
channel_identifier = ""
|
||||
if isinstance(identifier, PersonIdentifier):
|
||||
channel_identifier = str(identifier.identifier or "").strip()
|
||||
elif identifier is not None:
|
||||
channel_identifier = str(identifier or "").strip()
|
||||
if channel_identifier:
|
||||
try:
|
||||
await process_inbound_message(
|
||||
CommandContext(
|
||||
service=str(protocol or "").strip().lower(),
|
||||
channel_identifier=channel_identifier,
|
||||
message_id=str(local_message.id),
|
||||
user_id=int(local_message.user_id),
|
||||
message_text=message_text,
|
||||
payload=dict(kwargs.get("payload") or {}),
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
self.log.warning("Command engine processing failed: %s", exc)
|
||||
try:
|
||||
await process_inbound_translation(local_message)
|
||||
except Exception as exc:
|
||||
self.log.warning("Translation engine processing failed: %s", exc)
|
||||
|
||||
async def _resolve_identifier_objects(self, protocol, identifier):
|
||||
if isinstance(identifier, PersonIdentifier):
|
||||
|
||||
Reference in New Issue
Block a user