|
@@ -852,8 +852,8 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
|
|
|
|
|
for att in attachments:
|
|
for att in attachments:
|
|
|
url = att.asset_url.url if att.asset_url else ""
|
|
url = att.asset_url.url if att.asset_url else ""
|
|
|
- filename = att.filename or ""
|
|
|
|
|
- content_type = att.content_type or ""
|
|
|
|
|
|
|
+ filename = att.filename
|
|
|
|
|
+ content_type = att.content_type
|
|
|
if not url:
|
|
if not url:
|
|
|
# Videos are announced before transcoding finishes, so the
|
|
# Videos are announced before transcoding finishes, so the
|
|
|
# signed URL can legitimately be missing on arrival.
|
|
# signed URL can legitimately be missing on arrival.
|
|
@@ -941,8 +941,7 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
|
|
|
|
|
# A message carrying only an image/PDF has an empty body — dropping it
|
|
# A message carrying only an image/PDF has an empty body — dropping it
|
|
|
# here is what made attachments sent to Hermes disappear silently.
|
|
# here is what made attachments sent to Hermes disappear silently.
|
|
|
- attachments = list(message.attachments or [])
|
|
|
|
|
- if not message_body and not attachments:
|
|
|
|
|
|
|
+ if not message_body and not message.attachments:
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
event = await self._admit_and_build(
|
|
event = await self._admit_and_build(
|
|
@@ -1479,7 +1478,6 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
rooms_list = await client.list_rooms()
|
|
rooms_list = await client.list_rooms()
|
|
|
- respond_rooms = self.chatto_config.respond_rooms.value
|
|
|
|
|
member_ids: set[str] = set()
|
|
member_ids: set[str] = set()
|
|
|
new_room_ids: list[str] = []
|
|
new_room_ids: list[str] = []
|
|
|
|
|
|
|
@@ -1517,7 +1515,11 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
stale_room_ids,
|
|
stale_room_ids,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- unjoined_listed = [rid for rid in respond_rooms if rid not in member_ids]
|
|
|
|
|
|
|
+ unjoined_listed = [
|
|
|
|
|
+ rid
|
|
|
|
|
+ for rid in self.chatto_config.respond_rooms.value
|
|
|
|
|
+ if rid not in member_ids
|
|
|
|
|
+ ]
|
|
|
if unjoined_listed:
|
|
if unjoined_listed:
|
|
|
logger.warning(
|
|
logger.warning(
|
|
|
"Chatto WS: CHATTO_RESPOND_ROOMS lists room(s) we are not a"
|
|
"Chatto WS: CHATTO_RESPOND_ROOMS lists room(s) we are not a"
|
|
@@ -1850,9 +1852,11 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
logger.warning("Chatto: handoff thread — client unavailable")
|
|
logger.warning("Chatto: handoff thread — client unavailable")
|
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
- seed_text = f"🧵 Hermes handoff — **{(name or 'session').strip()[:80]}**"
|
|
|
|
|
try:
|
|
try:
|
|
|
- msg = await client.post_message(room_id=str(parent_chat_id), body=seed_text)
|
|
|
|
|
|
|
+ msg = await client.post_message(
|
|
|
|
|
+ room_id=str(parent_chat_id),
|
|
|
|
|
+ body=f"🧵 Hermes handoff — **{(name or 'session').strip()[:80]}**",
|
|
|
|
|
+ )
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
logger.warning(
|
|
logger.warning(
|
|
|
"Chatto: handoff thread seed-post failed for room %s: %s",
|
|
"Chatto: handoff thread seed-post failed for room %s: %s",
|
|
@@ -2081,8 +2085,7 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
def _event_room_and_message_id(self, event: MessageEvent) -> tuple[str, str]:
|
|
def _event_room_and_message_id(self, event: MessageEvent) -> tuple[str, str]:
|
|
|
"""Extract room_id and message_id from a MessageEvent."""
|
|
"""Extract room_id and message_id from a MessageEvent."""
|
|
|
message_id = event.message_id or ""
|
|
message_id = event.message_id or ""
|
|
|
- chat_id = event.source.chat_id
|
|
|
|
|
- return chat_id, message_id
|
|
|
|
|
|
|
+ return event.source.chat_id, message_id
|
|
|
|
|
|
|
|
async def on_processing_start(self, event: MessageEvent) -> None:
|
|
async def on_processing_start(self, event: MessageEvent) -> None:
|
|
|
"""Record the turn as open, then add an 👀 (eyes) reaction.
|
|
"""Record the turn as open, then add an 👀 (eyes) reaction.
|
|
@@ -2458,8 +2461,7 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
when ``is_temp``. ``(None, False)`` means the entry is unusable.
|
|
when ``is_temp``. ``(None, False)`` means the entry is unusable.
|
|
|
"""
|
|
"""
|
|
|
if image_url.startswith(("http://", "https://")):
|
|
if image_url.startswith(("http://", "https://")):
|
|
|
- parsed = urlsplit(image_url)
|
|
|
|
|
- ext = os.path.splitext(parsed.path)[1] or ".png"
|
|
|
|
|
|
|
+ ext = os.path.splitext(urlsplit(image_url).path)[1] or ".png"
|
|
|
tmp_fd, tmp_path = tempfile.mkstemp(suffix=ext, prefix="chatto_img_")
|
|
tmp_fd, tmp_path = tempfile.mkstemp(suffix=ext, prefix="chatto_img_")
|
|
|
os.close(tmp_fd)
|
|
os.close(tmp_fd)
|
|
|
try:
|
|
try:
|