-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmessage.ts
More file actions
167 lines (152 loc) · 4.58 KB
/
message.ts
File metadata and controls
167 lines (152 loc) · 4.58 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* Wechaty Puppet Unified Schema for Message
*/
export enum MessageType {
Unknown = 0,
Attachment = 1, // Attach(6),
Audio = 2, // Audio(1), Voice(34)
Contact = 3, // ShareCard(42)
ChatHistory = 4, // ChatHistory(19)
Emoticon = 5, // Sticker: Emoticon(15), Emoticon(47)
Image = 6, // Img(2), Image(3)
Text = 7, // Text(1)
Location = 8, // Location(48)
MiniProgram = 9, // MiniProgram(33)
GroupNote = 10, // GroupNote(53)
Transfer = 11, // Transfers(2000)
RedEnvelope = 12, // RedEnvelopes(2001)
Recalled = 13, // Recalled(10002)
Url = 14, // Url(5)
Video = 15, // Video(4), Video(43)
Post = 16, // Moment, Channel, Tweet, etc
Channel = 17, // Channel
}
/**
* Huan(202001): Wechat Server Message Type Value (to be confirmed.)
*/
export enum WechatAppMessageType {
Text = 1,
Img = 2,
Audio = 3,
Video = 4,
Url = 5,
Attach = 6,
Open = 7,
Emoji = 8,
VoiceRemind = 9,
ScanGood = 10,
Good = 13,
Emotion = 15,
CardTicket = 16,
RealtimeShareLocation = 17,
ChatHistory = 19,
MiniProgram = 33,
Transfers = 2000,
RedEnvelopes = 2001,
ReaderType = 100001,
}
/**
* Wechat Server Message Type Value (to be confirmed)
* Huan(202001): The Windows(PC) DLL match the following numbers.
*
* Huan(202111): 17(RealTimeLocation) & 6 (File) ?
* @see https://zhuanlan.zhihu.com/p/22474033
*/
export enum WechatMessageType {
Text = 1,
Image = 3,
Voice = 34,
VerifyMsg = 37,
PossibleFriendMsg = 40,
ShareCard = 42,
Video = 43,
Emoticon = 47,
Location = 48,
App = 49,
VoipMsg = 50,
StatusNotify = 51,
VoipNotify = 52,
VoipInvite = 53,
MicroVideo = 62,
Transfer = 2000, // 转账
RedEnvelope = 2001, // 红包
MiniProgram = 2002, // 小程序
GroupInvite = 2003, // 群邀请
File = 2004, // 文件消息
SysNotice = 9999,
Sys = 10000,
Recalled = 10002, // NOTIFY 服务通知
}
/** @hidden */
export interface MessagePayloadBase {
id : string,
/**
* Huan(202203): replace `fromId` by `talkerId`, `toId` by `listenerId` #187
* @link https://github.com/wechaty/puppet/issues/187
*/
talkerId: string,
filename? : string,
text? : string,
timestamp : number, // Huan(202001): we support both seconds & milliseconds in Wechaty now.
type : MessageType,
}
/** @hidden */
export interface MessagePayloadRoom {
/**
* Huan(202203): `toId` will be removed with v2.0
* replace `toId` by `listenerId`
* @link https://github.com/wechaty/puppet/issues/187
*
* @deprecated use `listenerId` instead
*/
toId?: string,
listenerId?: string
/**
* Huan(202203): `fromId` will be removed with v2.0
* replace `fromId` by `talkerId`
* @link https://github.com/wechaty/puppet/issues/187
*
* @deprecated use `talkerId` instead
*/
fromId? : string,
mentionIdList?: string[], // Mentioned Contacts' Ids
roomId : string,
}
/** @hidden */
export interface MessagePayloadTo {
/**
* Huan(202203): `fromId` will be removed with v2.0
* replace `fromId` by `talkerId`
* @link https://github.com/wechaty/puppet/issues/187
*
* @deprecated use `talkerId` instead
*/
fromId?: string
roomId?: string
/**
* Huan(202203): `toId` will be removed with v2.0
* replace `toId` by `listenerId`
* @link https://github.com/wechaty/puppet/issues/187
*
* @deprecated use `listenerId` instead
*/
toId?: string
listenerId: string // if to is not set, then room must be set
}
export type MessagePayload = MessagePayloadBase
& (
MessagePayloadRoom
| MessagePayloadTo
)
export interface MessageQueryFilter {
fromId? : string,
id? : string,
roomId? : string
text? : string | RegExp,
toId? : string,
type? : MessageType,
}
/** @hidden */
export type MessagePayloadFilterFunction = (payload: MessagePayload) => boolean
/** @hidden */
export type MessagePayloadFilterFactory = (query: MessageQueryFilter) => MessagePayloadFilterFunction