types.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // 飞书消息类型
  2. export type FeishuMsgType = 'text' | 'post' | 'interactive';
  3. // 接收者 ID 类型
  4. export type ReceiveIdType = 'open_id' | 'user_id' | 'union_id' | 'email' | 'chat_id';
  5. // 文本消息内容
  6. export interface TextContent {
  7. text: string;
  8. }
  9. // 富文本消息内容
  10. export interface PostContent {
  11. zh_cn?: {
  12. title?: string;
  13. content: Array<Array<{
  14. tag: 'text' | 'a' | 'at';
  15. text?: string;
  16. href?: string;
  17. user_id?: string;
  18. }>>;
  19. };
  20. }
  21. // 发送消息请求体(Webhook 方式)
  22. export interface SendMessageRequest {
  23. webhook_url: string;
  24. msg_type: FeishuMsgType;
  25. content: TextContent | PostContent | any;
  26. }
  27. // 发送消息到个人请求体(API 方式)
  28. export interface SendToUserRequest {
  29. receive_id_type: ReceiveIdType;
  30. receive_id: string;
  31. msg_type: FeishuMsgType;
  32. content: any;
  33. }
  34. // 批量发送消息到多人请求体
  35. export interface SendToMultipleUsersRequest {
  36. receive_id_type: ReceiveIdType;
  37. receive_ids: string[];
  38. msg_type: FeishuMsgType;
  39. content: any;
  40. }
  41. // 飞书 API 响应
  42. export interface FeishuResponse {
  43. code: number;
  44. msg: string;
  45. data?: any;
  46. }