-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.ts
More file actions
123 lines (101 loc) · 3.39 KB
/
types.ts
File metadata and controls
123 lines (101 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Shared types and constants for the WeChat Channel plugin.
*/
// ── Account ──────────────────────────────────────────────────────────────────
export interface AccountData {
token: string;
baseUrl: string;
accountId: string;
userId?: string;
savedAt: string;
}
// ── Allowlist ────────────────────────────────────────────────────────────────
export interface AllowEntry {
id: string;
nickname: string;
}
export interface Allowlist {
allowed: AllowEntry[];
auto_allow_next: boolean;
}
// ── Chat Log ─────────────────────────────────────────────────────────────────
export interface ChatLogEntry {
ts: string;
direction: "in" | "out";
from: string;
text: string;
}
// ── WeChat Message ───────────────────────────────────────────────────────────
export interface MediaInfo {
encrypt_query_param?: string;
aes_key?: string;
}
export interface TextItem {
text?: string;
}
export interface RefMessage {
message_item?: MessageItem;
title?: string;
}
export interface MessageItem {
type?: number;
text_item?: TextItem;
image_item?: { media?: MediaInfo; aeskey?: string };
voice_item?: { media?: MediaInfo; text?: string };
file_item?: { media?: MediaInfo; file_name?: string };
video_item?: { media?: MediaInfo };
ref_msg?: RefMessage;
}
export interface WeixinMessage {
from_user_id?: string;
to_user_id?: string;
client_id?: string;
session_id?: string;
message_type?: number;
message_state?: number;
item_list?: MessageItem[];
context_token?: string;
create_time_ms?: number;
}
export interface GetUpdatesResp {
ret?: number;
errcode?: number;
errmsg?: string;
msgs?: WeixinMessage[];
get_updates_buf?: string;
longpolling_timeout_ms?: number;
}
export interface DownloadedMedia {
type: "image" | "voice" | "file" | "video";
filePath: string;
fileName: string;
}
// ── Message Constants ────────────────────────────────────────────────────────
export const MSG_TYPE_USER = 1;
export const MSG_ITEM_TEXT = 1;
export const MSG_ITEM_VOICE = 3;
export const MSG_TYPE_BOT = 2;
export const MSG_STATE_FINISH = 2;
// Upload media types (different from message item types!)
export const UPLOAD_MEDIA_TYPE = { IMAGE: 1, VIDEO: 2, FILE: 3 } as const;
// ── Heartbeat ────────────────────────────────────────────────────────────────
export interface HBFixed {
hour: number;
minute: number;
label?: string;
}
export interface HBConfig {
fixed: HBFixed[];
random: {
active_start: number;
active_end: number;
daily_count: number;
min_per_hour: number;
};
}
export interface HBScheduleEntry {
hour: number;
minute: number;
type: "fixed" | "random";
label?: string;
}