Chat API
The Chat API module is specifically responsible for querying and managing chat information, helping plugins obtain and manage different chat streams.
Import Method
python
from src.plugin_system import chat_api
# or
from src.plugin_system.apis import chat_apiMain Functions
1. Get All Chat Streams
python
def get_all_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:Args:
platform: Platform filter, default is "qq", can useSpecialTypes.ALL_PLATFORMSfrom theSpecialTypesenum class to get chat streams from all platforms.
Returns:
List[ChatStream]: Chat stream list
2. Get Group Chat Streams
python
def get_group_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:Args:
platform: Platform filter, default is "qq", can useSpecialTypes.ALL_PLATFORMSfrom theSpecialTypesenum class to get group chat streams from all platforms.
Returns:
List[ChatStream]: Group chat stream list
3. Get Private Chat Streams
python
def get_private_streams(platform: Optional[str] | SpecialTypes = "qq") -> List[ChatStream]:Args:
platform: Platform filter, default is "qq", can useSpecialTypes.ALL_PLATFORMSfrom theSpecialTypesenum class to get private chat streams from all platforms.
Returns:
List[ChatStream]: Private chat stream list
4. Get Chat Stream by Group ID
python
def get_stream_by_group_id(group_id: str, platform: Optional[str] | SpecialTypes = "qq") -> Optional[ChatStream]:Args:
group_id: Group chat IDplatform: Platform filter, default is "qq", can useSpecialTypes.ALL_PLATFORMSfrom theSpecialTypesenum class to get group chat streams from all platforms.
Returns:
Optional[ChatStream]: Chat stream object, returns None if not found
5. Get Private Chat Stream by User ID
python
def get_stream_by_user_id(user_id: str, platform: Optional[str] | SpecialTypes = "qq") -> Optional[ChatStream]:Args:
user_id: User IDplatform: Platform filter, default is "qq", can useSpecialTypes.ALL_PLATFORMSfrom theSpecialTypesenum class to get private chat streams from all platforms.
Returns:
Optional[ChatStream]: Chat stream object, returns None if not found
6. Get Chat Stream Type
python
def get_stream_type(chat_stream: ChatStream) -> str:Args:
chat_stream: Chat stream object
Returns:
str: Chat stream type, possible values includeprivate(private chat stream),group(group chat stream), andunknown(unknown type).
7. Get Chat Stream Information
python
def get_stream_info(chat_stream: ChatStream) -> Dict[str, Any]:Args:
chat_stream: Chat stream object
Returns:
Dict[str, Any]: Detailed information about the chat stream, including but not limited to:stream_id: Chat stream IDplatform: Platform nametype: Chat stream typegroup_id: Group chat IDgroup_name: Group chat nameuser_id: User IDuser_name: User name
8. Get Chat Stream Statistics Summary
python
def get_streams_summary() -> Dict[str, int]:Returns:
Dict[str, int]: Chat stream statistics summary, containing the following keys:total_streams: Total number of chat streamsgroup_streams: Number of group chat streamsprivate_streams: Number of private chat streamsqq_streams: Number of QQ platform streams
Notes
- Most functions will throw exceptions when parameters are invalid, please ensure your program handles these exceptions.
- The
ChatStreamobject contains complete chat information, including user information, group information, etc.