@arcaelas/whatsapp 1.0.21 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/API.md +776 -0
  2. package/DOC.md +532 -0
  3. package/build/Chat.d.ts +335 -0
  4. package/build/Chat.js +396 -0
  5. package/build/Chat.js.map +1 -0
  6. package/build/Contact.d.ts +828 -0
  7. package/build/Contact.js +188 -0
  8. package/build/Contact.js.map +1 -0
  9. package/build/Message.d.ts +525 -0
  10. package/build/Message.js +445 -0
  11. package/build/Message.js.map +1 -0
  12. package/build/WhatsApp.d.ts +68 -0
  13. package/build/WhatsApp.js +399 -0
  14. package/build/WhatsApp.js.map +1 -0
  15. package/build/index.d.ts +11 -107
  16. package/build/index.js +1 -1
  17. package/build/index.js.map +3 -3
  18. package/build/store/driver/FileEngine.d.ts +23 -0
  19. package/build/store/driver/FileEngine.js +90 -0
  20. package/build/store/driver/FileEngine.js.map +1 -0
  21. package/build/store/driver/RedisEngine.d.ts +38 -0
  22. package/build/store/driver/RedisEngine.js +69 -0
  23. package/build/store/driver/RedisEngine.js.map +1 -0
  24. package/build/store/engine.d.ts +54 -0
  25. package/build/store/engine.js +7 -0
  26. package/build/store/engine.js.map +1 -0
  27. package/build/store/index.d.ts +8 -0
  28. package/build/store/index.js +12 -0
  29. package/build/store/index.js.map +1 -0
  30. package/context7.json +4 -0
  31. package/package.json +59 -52
  32. package/tsconfig.json +25 -25
  33. package/build/model/base.d.ts +0 -28
  34. package/build/model/base.js +0 -65
  35. package/build/model/base.js.map +0 -1
  36. package/build/model/chat.d.ts +0 -112
  37. package/build/model/chat.js +0 -105
  38. package/build/model/chat.js.map +0 -1
  39. package/build/model/contact.d.ts +0 -16
  40. package/build/model/contact.js +0 -22
  41. package/build/model/contact.js.map +0 -1
  42. package/build/model/message.d.ts +0 -159
  43. package/build/model/message.js +0 -206
  44. package/build/model/message.js.map +0 -1
  45. package/build/static/Store.d.ts +0 -137
  46. package/build/static/Store.js +0 -238
  47. package/build/static/Store.js.map +0 -1
  48. package/build/static/useCache.d.ts +0 -12
  49. package/build/static/useCache.js +0 -43
  50. package/build/static/useCache.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import * as Baileys from 'baileys';
2
- import Base from './base';
3
- import Message, { MessageOptions } from './message';
4
- /**
5
- * @module Chat
6
- * @description
7
- * Represents a chat in WhatsApp.
8
- */
9
- export default class Chat extends Base<Baileys.Chat> {
10
- get raw(): {
11
- id: string;
12
- messages?: (Baileys.WAProto.IHistorySyncMsg[] | null) | undefined;
13
- newJid?: (string | null) | undefined;
14
- oldJid?: (string | null) | undefined;
15
- lastMsgTimestamp?: (number | Long | null) | undefined;
16
- unreadCount?: (number | null) | undefined;
17
- readOnly?: (boolean | null) | undefined;
18
- endOfHistoryTransfer?: (boolean | null) | undefined;
19
- ephemeralExpiration?: (number | null) | undefined;
20
- ephemeralSettingTimestamp?: (number | Long | null) | undefined;
21
- endOfHistoryTransferType?: (Baileys.WAProto.Conversation.EndOfHistoryTransferType | null) | undefined;
22
- conversationTimestamp?: (number | Long | null) | undefined;
23
- name?: (string | null) | undefined;
24
- pHash?: (string | null) | undefined;
25
- notSpam?: (boolean | null) | undefined;
26
- archived?: (boolean | null) | undefined;
27
- disappearingMode?: (Baileys.WAProto.IDisappearingMode | null) | undefined;
28
- unreadMentionCount?: (number | null) | undefined;
29
- markedAsUnread?: (boolean | null) | undefined;
30
- participant?: (Baileys.WAProto.IGroupParticipant[] | null) | undefined;
31
- tcToken?: (Uint8Array | null) | undefined;
32
- tcTokenTimestamp?: (number | Long | null) | undefined;
33
- contactPrimaryIdentityKey?: (Uint8Array | null) | undefined;
34
- pinned?: (number | null) | undefined;
35
- muteEndTime?: (number | Long | null) | undefined;
36
- wallpaper?: (Baileys.WAProto.IWallpaperSettings | null) | undefined;
37
- mediaVisibility?: (Baileys.WAProto.MediaVisibility | null) | undefined;
38
- tcTokenSenderTimestamp?: (number | Long | null) | undefined;
39
- suspended?: (boolean | null) | undefined;
40
- terminated?: (boolean | null) | undefined;
41
- createdAt?: (number | Long | null) | undefined;
42
- createdBy?: (string | null) | undefined;
43
- description?: (string | null) | undefined;
44
- support?: (boolean | null) | undefined;
45
- isParentGroup?: (boolean | null) | undefined;
46
- parentGroupId?: (string | null) | undefined;
47
- isDefaultSubgroup?: (boolean | null) | undefined;
48
- displayName?: (string | null) | undefined;
49
- pnJid?: (string | null) | undefined;
50
- shareOwnPn?: (boolean | null) | undefined;
51
- pnhDuplicateLidThread?: (boolean | null) | undefined;
52
- lidJid?: (string | null) | undefined;
53
- username?: (string | null) | undefined;
54
- lidOriginType?: (string | null) | undefined;
55
- commentsCount?: (number | null) | undefined;
56
- locked?: (boolean | null) | undefined;
57
- systemMessageToInsert?: (Baileys.WAProto.PrivacySystemMessage | null) | undefined;
58
- capiCreatedGroup?: (boolean | null) | undefined;
59
- accountLid?: (string | null) | undefined;
60
- limitSharing?: (boolean | null) | undefined;
61
- limitSharingSettingTimestamp?: (number | Long | null) | undefined;
62
- limitSharingTrigger?: (Baileys.WAProto.LimitSharing.TriggerType | null) | undefined;
63
- limitSharingInitiatedByMe?: (boolean | null) | undefined;
64
- lastMessageRecvTimestamp?: number | undefined;
65
- };
66
- get id(): string;
67
- /**
68
- * @description
69
- * Returns the messages in this chat.
70
- * @returns Promise that resolves to an array of messages.
71
- */
72
- messages(): Promise<Message[]>;
73
- /**
74
- * @description
75
- * Sends a text message to this chat.
76
- * @param text The text to send.
77
- * @param options Additional options for the message.
78
- * @returns Promise that resolves to a boolean indicating success.
79
- */
80
- send(text: string, options?: {
81
- once: boolean;
82
- }): Promise<Message | null>;
83
- /**
84
- * @description
85
- * Sends a media message to this chat.
86
- * @param media The media to send.
87
- * @param options Additional options for the message.
88
- * @returns Promise that resolves to a boolean indicating success.
89
- */
90
- send(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<Message | null>;
91
- /**
92
- * @description
93
- * Updates the presence of this chat.
94
- * @param status The status to update to.
95
- * @returns Promise that resolves to a boolean indicating success.
96
- */
97
- presence(status: Baileys.WAPresence): Promise<boolean>;
98
- /**
99
- * @description
100
- * Updates the typing status of this chat.
101
- * @param on Whether to start or stop typing.
102
- * @returns Promise that resolves to a boolean indicating success.
103
- */
104
- typing(on?: boolean): Promise<boolean>;
105
- /**
106
- * @description
107
- * Updates the recording status of this chat.
108
- * @param on Whether to start or stop recording.
109
- * @returns Promise that resolves to a boolean indicating success.
110
- */
111
- recording(on?: boolean): Promise<boolean>;
112
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const base_1 = __importDefault(require("./base"));
7
- const message_1 = __importDefault(require("./message"));
8
- /**
9
- * @module Chat
10
- * @description
11
- * Represents a chat in WhatsApp.
12
- */
13
- class Chat extends base_1.default {
14
- get raw() {
15
- return this._;
16
- }
17
- get id() {
18
- return this.raw.id;
19
- }
20
- /**
21
- * @description
22
- * Returns the messages in this chat.
23
- * @returns Promise that resolves to an array of messages.
24
- */
25
- async messages() {
26
- return await this.$.tick(async (release, _, store) => {
27
- const messages = [];
28
- const keys = await store.engine.match(`chat/${this.id}/message/*/index`);
29
- for (const key of keys) {
30
- const [, , id] = key.match(/chat\/[^/]+\/message\/([^/]+)/);
31
- messages.push(new message_1.default(this.$, (await store.message.get(id))));
32
- }
33
- release();
34
- return messages;
35
- });
36
- }
37
- async send(content, options) {
38
- return this.$.tick(async (release, socket) => {
39
- let m;
40
- const _options = { type: 'text', ...options };
41
- try {
42
- if (typeof content === 'string') {
43
- m = await socket.sendMessage(this.id, {
44
- text: content,
45
- viewOnce: _options.once || false,
46
- });
47
- }
48
- else if (Buffer.isBuffer(content)) {
49
- m = await socket.sendMessage(this.id, {
50
- viewOnce: _options.once || false,
51
- ptv: !!(_options.type === 'video' && _options.ptv),
52
- ptt: !!(_options.type === 'audio' && _options.ptt),
53
- image: _options.type === 'image' ? content : undefined,
54
- audio: _options.type === 'audio' ? content : undefined,
55
- video: _options.type === 'video' ? content : undefined,
56
- });
57
- }
58
- }
59
- finally {
60
- release();
61
- }
62
- return m ? new message_1.default(this.$, m) : null;
63
- });
64
- }
65
- /**
66
- * @description
67
- * Updates the presence of this chat.
68
- * @param status The status to update to.
69
- * @returns Promise that resolves to a boolean indicating success.
70
- */
71
- async presence(status) {
72
- return await this.$.tick(async (release, socket) => {
73
- try {
74
- await socket.sendPresenceUpdate(status, this.id);
75
- return true;
76
- }
77
- catch {
78
- return false;
79
- }
80
- finally {
81
- release();
82
- }
83
- });
84
- }
85
- /**
86
- * @description
87
- * Updates the typing status of this chat.
88
- * @param on Whether to start or stop typing.
89
- * @returns Promise that resolves to a boolean indicating success.
90
- */
91
- async typing(on = true) {
92
- return await this.presence(on ? 'composing' : 'available');
93
- }
94
- /**
95
- * @description
96
- * Updates the recording status of this chat.
97
- * @param on Whether to start or stop recording.
98
- * @returns Promise that resolves to a boolean indicating success.
99
- */
100
- async recording(on = true) {
101
- return await this.presence(on ? 'recording' : 'available');
102
- }
103
- }
104
- exports.default = Chat;
105
- //# sourceMappingURL=chat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/model/chat.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAC1B,wDAAoD;AAEpD;;;;GAIG;AACH,MAAqB,IAAK,SAAQ,cAAkB;IAChD,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,EAAG,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,QAAQ,GAAc,E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,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,KAAc,IAAI;QAC9B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;CACJ;AA5GD,uBA4GC"}
@@ -1,16 +0,0 @@
1
- import * as Baileys from 'baileys';
2
- import Base from './base';
3
- export default class Contact extends Base<Baileys.Contact> {
4
- get raw(): {
5
- id: string;
6
- lid?: string | undefined;
7
- name?: string | undefined;
8
- notify?: string | undefined;
9
- verifiedName?: string | undefined;
10
- imgUrl?: string | null | undefined;
11
- status?: string | undefined;
12
- };
13
- get id(): string;
14
- get name(): string;
15
- get phone(): string;
16
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const base_1 = __importDefault(require("./base"));
7
- class Contact extends base_1.default {
8
- get raw() {
9
- return this._;
10
- }
11
- get id() {
12
- return this.raw.id;
13
- }
14
- get name() {
15
- return this.raw.name || this.raw.verifiedName || this.raw.id.split('@')[0];
16
- }
17
- get phone() {
18
- return this.raw.id.split('@')[0];
19
- }
20
- }
21
- exports.default = Contact;
22
- //# sourceMappingURL=contact.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contact.js","sourceRoot":"","sources":["../../src/model/contact.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAE1B,MAAqB,OAAQ,SAAQ,cAAqB;IACtD,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACvB,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ;AAbD,0BAaC"}
@@ -1,159 +0,0 @@
1
- import * as Baileys from 'baileys';
2
- import Base from './base';
3
- import Chat from './chat';
4
- type LikeEmoji = '👍' | '❤️' | '😂' | '😮' | '😢' | '👎' | '👌' | '🙏' | '👏' | '👏';
5
- export interface MessageOptions {
6
- /**
7
- * @description
8
- * The type of the message.
9
- * @default 'text'
10
- */
11
- type?: 'audio' | 'video' | 'image' | 'location';
12
- /**
13
- * @description
14
- * The caption for the image.
15
- */
16
- caption?: string;
17
- /**
18
- * @description
19
- * Whether the audio is a voice note.
20
- */
21
- ptt?: boolean;
22
- /**
23
- * @description
24
- * Whether the video is a video note.
25
- */
26
- ptv?: boolean;
27
- /**
28
- * @description
29
- * Whether the message is a view once message.
30
- */
31
- once?: boolean;
32
- }
33
- /**
34
- * @module Message
35
- * @description
36
- * Represents a message in WhatsApp.
37
- */
38
- export default class Message extends Base<Baileys.WAProto.IWebMessageInfo> {
39
- get raw(): {
40
- key: Baileys.WAProto.IMessageKey;
41
- message?: (Baileys.WAProto.IMessage | null) | undefined;
42
- messageTimestamp?: (number | Long | null) | undefined;
43
- status?: (Baileys.WAProto.WebMessageInfo.Status | null) | undefined;
44
- participant?: (string | null) | undefined;
45
- messageC2STimestamp?: (number | Long | null) | undefined;
46
- ignore?: (boolean | null) | undefined;
47
- starred?: (boolean | null) | undefined;
48
- broadcast?: (boolean | null) | undefined;
49
- pushName?: (string | null) | undefined;
50
- mediaCiphertextSha256?: (Uint8Array | null) | undefined;
51
- multicast?: (boolean | null) | undefined;
52
- urlText?: (boolean | null) | undefined;
53
- urlNumber?: (boolean | null) | undefined;
54
- messageStubType?: (Baileys.WAProto.WebMessageInfo.StubType | null) | undefined;
55
- clearMedia?: (boolean | null) | undefined;
56
- messageStubParameters?: (string[] | null) | undefined;
57
- duration?: (number | null) | undefined;
58
- labels?: (string[] | null) | undefined;
59
- paymentInfo?: (Baileys.WAProto.IPaymentInfo | null) | undefined;
60
- finalLiveLocation?: (Baileys.WAProto.Message.ILiveLocationMessage | null) | undefined;
61
- quotedPaymentInfo?: (Baileys.WAProto.IPaymentInfo | null) | undefined;
62
- ephemeralStartTimestamp?: (number | Long | null) | undefined;
63
- ephemeralDuration?: (number | null) | undefined;
64
- ephemeralOffToOn?: (boolean | null) | undefined;
65
- ephemeralOutOfSync?: (boolean | null) | undefined;
66
- bizPrivacyStatus?: (Baileys.WAProto.WebMessageInfo.BizPrivacyStatus | null) | undefined;
67
- verifiedBizName?: (string | null) | undefined;
68
- mediaData?: (Baileys.WAProto.IMediaData | null) | undefined;
69
- photoChange?: (Baileys.WAProto.IPhotoChange | null) | undefined;
70
- userReceipt?: (Baileys.WAProto.IUserReceipt[] | null) | undefined;
71
- reactions?: (Baileys.WAProto.IReaction[] | null) | undefined;
72
- quotedStickerData?: (Baileys.WAProto.IMediaData | null) | undefined;
73
- futureproofData?: (Uint8Array | null) | undefined;
74
- statusPsa?: (Baileys.WAProto.IStatusPSA | null) | undefined;
75
- pollUpdates?: (Baileys.WAProto.IPollUpdate[] | null) | undefined;
76
- pollAdditionalMetadata?: (Baileys.WAProto.IPollAdditionalMetadata | null) | undefined;
77
- agentId?: (string | null) | undefined;
78
- statusAlreadyViewed?: (boolean | null) | undefined;
79
- messageSecret?: (Uint8Array | null) | undefined;
80
- keepInChat?: (Baileys.WAProto.IKeepInChat | null) | undefined;
81
- originalSelfAuthorUserJidString?: (string | null) | undefined;
82
- revokeMessageTimestamp?: (number | Long | null) | undefined;
83
- pinInChat?: (Baileys.WAProto.IPinInChat | null) | undefined;
84
- premiumMessageInfo?: (Baileys.WAProto.IPremiumMessageInfo | null) | undefined;
85
- is1PBizBotMessage?: (boolean | null) | undefined;
86
- isGroupHistoryMessage?: (boolean | null) | undefined;
87
- botMessageInvokerJid?: (string | null) | undefined;
88
- commentMetadata?: (Baileys.WAProto.ICommentMetadata | null) | undefined;
89
- eventResponses?: (Baileys.WAProto.IEventResponse[] | null) | undefined;
90
- reportingTokenInfo?: (Baileys.WAProto.IReportingTokenInfo | null) | undefined;
91
- newsletterServerId?: (number | Long | null) | undefined;
92
- eventAdditionalMetadata?: (Baileys.WAProto.IEventAdditionalMetadata | null) | undefined;
93
- isMentionedInStatus?: (boolean | null) | undefined;
94
- statusMentions?: (string[] | null) | undefined;
95
- targetMessageId?: (Baileys.WAProto.IMessageKey | null) | undefined;
96
- messageAddOns?: (Baileys.WAProto.IMessageAddOn[] | null) | undefined;
97
- statusMentionMessageInfo?: (Baileys.WAProto.IStatusMentionMessage | null) | undefined;
98
- isSupportAiMessage?: (boolean | null) | undefined;
99
- statusMentionSources?: (string[] | null) | undefined;
100
- supportAiCitations?: (Baileys.WAProto.ICitation[] | null) | undefined;
101
- botTargetId?: (string | null) | undefined;
102
- };
103
- get isMe(): boolean;
104
- get role(): "assistant" | "user";
105
- get author(): {
106
- id: string;
107
- name: string | null;
108
- phone: string | null;
109
- };
110
- get type(): "audio" | "video" | "image" | "location" | "text" | "unknown";
111
- content(): Promise<string | Buffer>;
112
- /**
113
- * @description
114
- * Returns the chat associated with this message.
115
- * @returns Promise that resolves to the chat.
116
- */
117
- chat(): Promise<Chat>;
118
- /**
119
- * @description
120
- * Replies to this message.
121
- * @param content The content to reply with.
122
- * @param options Additional options for the reply.
123
- * @returns Promise that resolves to a boolean indicating success.
124
- */
125
- reply(text: string, options?: {
126
- once: boolean;
127
- }): Promise<Message | null>;
128
- reply(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<Message | null>;
129
- /**
130
- * @description
131
- * Marks this message as read.
132
- * @returns Promise that resolves to a boolean indicating success.
133
- */
134
- seen(): Promise<boolean>;
135
- /**
136
- * @description
137
- * Likes this message.
138
- * @param emoji The emoji to use for the like.
139
- * @returns Promise that resolves to a boolean indicating success.
140
- */
141
- like(emoji: LikeEmoji): Promise<boolean>;
142
- /**
143
- * @deprecated
144
- * @description
145
- * Forwards this message to another chat.
146
- * @param chat_id The ID of the chat to forward the message to.
147
- * @returns Promise that resolves to a boolean indicating success.
148
- */
149
- forward(chat_id: string): Promise<boolean>;
150
- /**
151
- * @deprecated
152
- * @description
153
- * Deletes this message.
154
- * @param forall Whether to delete for all participants.
155
- * @returns Promise that resolves to a boolean indicating success.
156
- */
157
- delete(forall?: boolean): Promise<boolean>;
158
- }
159
- export {};
@@ -1,206 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const Baileys = __importStar(require("baileys"));
40
- const base_1 = __importDefault(require("./base"));
41
- const chat_1 = __importDefault(require("./chat"));
42
- /**
43
- * @module Message
44
- * @description
45
- * Represents a message in WhatsApp.
46
- */
47
- class Message extends base_1.default {
48
- get raw() {
49
- return this._;
50
- }
51
- get isMe() {
52
- return !!this.raw.key.fromMe;
53
- }
54
- get role() {
55
- return this.isMe ? 'assistant' : 'user';
56
- }
57
- get author() {
58
- const phone = this.raw.key.remoteJid?.split('@')[0] ?? null;
59
- return {
60
- id: this.raw.key.remoteJid,
61
- name: this.raw.key.fromMe ? 'me' : this.raw.key.participant || this.raw.pushName || phone,
62
- phone,
63
- };
64
- }
65
- get type() {
66
- switch (Baileys.getContentType(this.raw.message)) {
67
- case 'extendedTextMessage':
68
- return 'text';
69
- case 'imageMessage':
70
- return 'image';
71
- case 'audioMessage':
72
- return 'audio';
73
- case 'videoMessage':
74
- return 'video';
75
- case 'locationMessage':
76
- return 'location';
77
- default:
78
- return 'unknown';
79
- }
80
- }
81
- async content() {
82
- // prettier-ignore
83
- return this.type === 'text' ? this.raw.message.extendedTextMessage.text : this.$.tick(async (release, socket) => {
84
- return await Baileys.downloadMediaMessage(this.raw, 'buffer', {}, {
85
- logger: socket.logger,
86
- reuploadRequest: socket.updateMediaMessage,
87
- }).finally(() => release());
88
- });
89
- }
90
- /**
91
- * @description
92
- * Returns the chat associated with this message.
93
- * @returns Promise that resolves to the chat.
94
- */
95
- async chat() {
96
- // prettier-ignore
97
- return this.$.tick(async (release, _, store) => {
98
- return new chat_1.default(this.$, (await store.chat.get(this.raw.key.remoteJid).finally(() => release())));
99
- });
100
- }
101
- async reply(content, options) {
102
- return this.$.tick(async (release, socket) => {
103
- let m;
104
- const _options = { type: 'text', ...options };
105
- // prettier-ignore
106
- if (typeof content === 'string') {
107
- m = await socket.sendMessage(this.raw.key.remoteJid, {
108
- text: content,
109
- viewOnce: _options.once || false,
110
- }, { quoted: this.raw });
111
- }
112
- else if (Buffer.isBuffer(content)) {
113
- m = await socket.sendMessage(this.raw.key.remoteJid, {
114
- viewOnce: _options.once || false,
115
- ptv: !!(_options.type === 'video' && _options.ptv),
116
- ptt: !!(_options.type === 'audio' && _options.ptt),
117
- image: _options.type === 'image' ? content : undefined,
118
- audio: _options.type === 'audio' ? content : undefined,
119
- video: _options.type === 'video' ? content : undefined,
120
- }, { quoted: this.raw });
121
- }
122
- release();
123
- return m ? new Message(this.$, m) : null;
124
- });
125
- }
126
- /**
127
- * @description
128
- * Marks this message as read.
129
- * @returns Promise that resolves to a boolean indicating success.
130
- */
131
- async seen() {
132
- return this.$.tick(async (release, socket) => {
133
- try {
134
- await socket.readMessages([this.raw.key]);
135
- return true;
136
- }
137
- catch {
138
- return false;
139
- }
140
- finally {
141
- release();
142
- }
143
- });
144
- }
145
- /**
146
- * @description
147
- * Likes this message.
148
- * @param emoji The emoji to use for the like.
149
- * @returns Promise that resolves to a boolean indicating success.
150
- */
151
- async like(emoji) {
152
- return this.$.tick(async (release, socket) => {
153
- await socket.sendMessage(this.raw.key.remoteJid, {
154
- react: { text: emoji, key: this.raw.key },
155
- });
156
- release();
157
- return true;
158
- });
159
- }
160
- /**
161
- * @deprecated
162
- * @description
163
- * Forwards this message to another chat.
164
- * @param chat_id The ID of the chat to forward the message to.
165
- * @returns Promise that resolves to a boolean indicating success.
166
- */
167
- async forward(chat_id) {
168
- return this.$.tick(async (release, socket) => {
169
- await socket.sendMessage(chat_id, {
170
- forward: { key: this.raw.key },
171
- });
172
- release();
173
- return true;
174
- });
175
- }
176
- /**
177
- * @deprecated
178
- * @description
179
- * Deletes this message.
180
- * @param forall Whether to delete for all participants.
181
- * @returns Promise that resolves to a boolean indicating success.
182
- */
183
- async delete(forall = false) {
184
- return this.$.tick(async (release, socket) => {
185
- if (forall) {
186
- await socket.sendMessage(this.raw.key.remoteJid, {
187
- delete: this.raw.key,
188
- });
189
- }
190
- else {
191
- // prettier-ignore
192
- await socket.chatModify({
193
- deleteForMe: {
194
- key: this.raw.key,
195
- deleteMedia: this.type !== 'text',
196
- timestamp: this.raw.messageTimestamp,
197
- },
198
- }, this.raw.key.remoteJid);
199
- }
200
- release();
201
- return true;
202
- });
203
- }
204
- }
205
- exports.default = Message;
206
- //# sourceMappingURL=message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/model/message.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,kDAA0B;AAC1B,kDAA0B;AAiC1B;;;;GAIG;AACH,MAAqB,OAAQ,SAAQ,cAAqC;IACtE,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAC5D,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAY,IAAI,IAAI,CAAC,GAA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