nonebot2/nonebot/adapters/ding/model.py

57 lines
1.2 KiB
Python
Raw Normal View History

2020-12-03 00:59:32 +08:00
from enum import Enum
2020-12-06 02:30:19 +08:00
from typing import List, Optional
2020-12-03 00:59:32 +08:00
from pydantic import BaseModel
class Headers(BaseModel):
sign: str
token: str
# ms
timestamp: int
class TextMessage(BaseModel):
content: str
class AtUsersItem(BaseModel):
dingtalkId: str
staffId: Optional[str]
class ConversationType(str, Enum):
private = '1'
group = '2'
class MessageModel(BaseModel):
chatbotUserId: str = None
conversationId: str = None
conversationType: ConversationType = None
2020-12-03 00:59:32 +08:00
# ms
createAt: int = None
isAdmin: bool = None
msgId: str = None
msgtype: str = None
senderCorpId: str = None
2020-12-03 00:59:32 +08:00
senderId: str = None
senderNick: str = None
sessionWebhook: str = None
# ms
sessionWebhookExpiredTime: int = None
text: Optional[TextMessage] = None
class PrivateMessageModel(MessageModel):
chatbotCorpId: str = None
conversationType: ConversationType = ConversationType.private
senderStaffId: str = None
class GroupMessageModel(MessageModel):
atUsers: List[AtUsersItem] = None
conversationType: ConversationType = ConversationType.group
conversationTitle: str = None
2020-12-03 00:59:32 +08:00
isInAtList: bool = None