Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /CIRISAI_CIRISAgent /ciris_engine /protocols /adapters /message.py
| """ | |
| Minimal protocol for messages across different adapters. | |
| """ | |
| from typing import Any, Dict, Optional, Protocol, Union, runtime_checkable | |
| class MessageProtocol(Protocol): | |
| """ | |
| Minimal protocol that all adapter messages must satisfy. | |
| Based on actual usage in AdaptiveFilterService. | |
| """ | |
| def content(self) -> Optional[str]: | |
| """The text content of the message""" | |
| ... | |
| def user_id(self) -> Optional[str]: | |
| """ID of the user who sent the message""" | |
| ... | |
| def author_id(self) -> Optional[str]: | |
| """Alternative field for user ID (Discord uses this)""" | |
| ... | |
| def channel_id(self) -> Optional[str]: | |
| """ID of the channel where message was sent""" | |
| ... | |
| def message_id(self) -> Optional[str]: | |
| """Unique ID of the message""" | |
| ... | |
| def id(self) -> Optional[str]: | |
| """Alternative field for message ID""" | |
| ... | |
| def is_dm(self) -> Optional[bool]: | |
| """Whether this is a direct message""" | |
| ... | |
| class MessageDict(dict[str, Any]): | |
| """ | |
| Simple dict wrapper that implements MessageProtocol. | |
| This allows plain dicts to be used as messages while | |
| still providing type safety. | |
| """ | |
| def content(self) -> Optional[str]: | |
| return self.get("content") | |
| def user_id(self) -> Optional[str]: | |
| return self.get("user_id") | |
| def author_id(self) -> Optional[str]: | |
| return self.get("author_id") | |
| def channel_id(self) -> Optional[str]: | |
| return self.get("channel_id") | |
| def message_id(self) -> Optional[str]: | |
| return self.get("message_id") | |
| def id(self) -> Optional[str]: | |
| return self.get("id") | |
| def is_dm(self) -> Optional[bool]: | |
| return self.get("is_dm") | |
| # Type alias for messages | |
| Message = Union[MessageProtocol, Dict[str, Any]] | |
Xet Storage Details
- Size:
- 2.06 kB
- Xet hash:
- b50dc78a14be27cde80a0ec28d62b284e9dc6518ab4413bbe42b4aa6aa124d8e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.