|
|
@@ -77,6 +77,7 @@ try:
|
|
|
MessageMention, # type: ignore[import-untyped]
|
|
|
MessagePostedEvent, # type: ignore[import-untyped]
|
|
|
)
|
|
|
+ from chattolib._pb.chatto.api.v1 import presence_pb2 # type: ignore[import-untyped]
|
|
|
from chattolib.client import (
|
|
|
ChattoClient,
|
|
|
)
|
|
|
@@ -2664,11 +2665,30 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
changed_user_id
|
|
|
and (user := self._user_cache.get(changed_user_id)) is not None
|
|
|
):
|
|
|
- user.presence_status = event.payload.status
|
|
|
+ # The realtime payload carries the proto enum as a plain int
|
|
|
+ # (or proto enum wrapper); chattolib's own bot.py coerces the
|
|
|
+ # same field the same way — read the wire shape, never
|
|
|
+ # ``.name`` directly, which raised AttributeError on every
|
|
|
+ # presence change and dropped inbound messages inside the
|
|
|
+ # reconnect gaps that followed.
|
|
|
+ raw_status = event.payload.status
|
|
|
+ if isinstance(raw_status, PresenceStatus):
|
|
|
+ status = raw_status
|
|
|
+ else:
|
|
|
+ proto_name = presence_pb2.PresenceStatus.Name(int(raw_status))
|
|
|
+ status = next(
|
|
|
+ (
|
|
|
+ member
|
|
|
+ for member in PresenceStatus
|
|
|
+ if member.value == proto_name
|
|
|
+ ),
|
|
|
+ PresenceStatus.UNSPECIFIED,
|
|
|
+ )
|
|
|
+ user.presence_status = status
|
|
|
logger.debug(
|
|
|
"Chatto: patched presence of %s to %s",
|
|
|
changed_user_id,
|
|
|
- event.payload.status.name,
|
|
|
+ status.name,
|
|
|
)
|
|
|
|
|
|
elif event.kind in ("user_joined_room", "user_left_room"):
|