@arcaelas/whatsapp 1.0.2

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.
@@ -0,0 +1,56 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const Baileys = __importStar(require("baileys"));
37
+ class Base {
38
+ constructor($, _) {
39
+ this.$ = $;
40
+ this._ = _;
41
+ }
42
+ toJSON() {
43
+ const o = {};
44
+ for (const k in this) {
45
+ if (typeof this[k] === 'function')
46
+ continue;
47
+ o[k] = this[k];
48
+ }
49
+ return o;
50
+ }
51
+ toString() {
52
+ return JSON.stringify(this.toJSON(), Baileys.BufferJSON.replacer);
53
+ }
54
+ }
55
+ exports.default = Base;
56
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/model/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AAKnC,MAAqB,IAAI;IACrB,YAA+B,CAA0B,EAAqB,CAAe;QAA9D,MAAC,GAAD,CAAC,CAAyB;QAAqB,MAAC,GAAD,CAAC,CAAc;IAAI,CAAC;IAClG,MAAM;QACF,MAAM,CAAC,GAAQ,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;gBAAE,SAAS;YAC5C,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACJ;AAbD,uBAaC"}
@@ -0,0 +1,15 @@
1
+ import * as Baileys from 'baileys';
2
+ import Base from './base';
3
+ import Message, { MessageOptions } from './message';
4
+ export default class Chat extends Base<Baileys.Chat> {
5
+ send(text: string, options?: {
6
+ once: boolean;
7
+ }): Promise<boolean>;
8
+ send(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<boolean>;
9
+ messages(): Promise<Message[]>;
10
+ pin(): Promise<boolean>;
11
+ seen(): Promise<boolean>;
12
+ mute(time?: number): Promise<boolean>;
13
+ presence(status: Baileys.WAPresence): Promise<boolean>;
14
+ delete(): Promise<boolean>;
15
+ }
@@ -0,0 +1,103 @@
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
+ class Chat extends base_1.default {
9
+ async send(content, options) {
10
+ return this.$.tick(async (socket) => {
11
+ try {
12
+ const _options = { type: 'text', ...options };
13
+ if (typeof content === 'string') {
14
+ await socket.sendMessage(this._.id, {
15
+ text: content,
16
+ viewOnce: _options.once || false,
17
+ });
18
+ return true;
19
+ }
20
+ else if (Buffer.isBuffer(content)) {
21
+ await socket.sendMessage(this._.id, {
22
+ viewOnce: _options.once || false,
23
+ ptv: !!(_options.type === 'video' && _options.ptv),
24
+ ptt: !!(_options.type === 'audio' && _options.ptt),
25
+ image: _options.type === 'image' ? content : undefined,
26
+ audio: _options.type === 'audio' ? content : undefined,
27
+ video: _options.type === 'video' ? content : undefined,
28
+ });
29
+ return true;
30
+ }
31
+ }
32
+ catch { }
33
+ return false;
34
+ });
35
+ }
36
+ async messages() {
37
+ return await this.$.tick(async (_, store) => {
38
+ const messages = [];
39
+ if (store.engine.scan) {
40
+ for (const key of await store.engine.scan(`chat/${this._.id}/message/*`)) {
41
+ const id = key.slice(`chat/${this._.id}/message/`.length);
42
+ messages.push(new message_1.default(this.$, (await store.message.get(id))));
43
+ }
44
+ }
45
+ else {
46
+ for await (const key of store.engine.keys()) {
47
+ if (key.startsWith(`chat/${this._.id}/message/`)) {
48
+ const id = key.slice(`chat/${this._.id}/message/`.length);
49
+ messages.push(new message_1.default(this.$, (await store.message.get(id))));
50
+ }
51
+ }
52
+ }
53
+ return messages;
54
+ });
55
+ }
56
+ async pin() {
57
+ return await this.$.tick(async (socket) => {
58
+ // prettier-ignore
59
+ await socket.chatModify({
60
+ pin: true,
61
+ lastMessages: [this._.messages[this._.messages.length - 1].message],
62
+ }, this._.id);
63
+ return true;
64
+ });
65
+ }
66
+ async seen() {
67
+ return await this.$.tick(async (socket) => {
68
+ // prettier-ignore
69
+ await socket.chatModify({
70
+ markRead: true,
71
+ lastMessages: [this._.messages[this._.messages.length - 1].message],
72
+ }, this._.id);
73
+ return true;
74
+ });
75
+ }
76
+ async mute(time = 0) {
77
+ return await this.$.tick(async (socket) => {
78
+ // prettier-ignore
79
+ await socket.chatModify({
80
+ mute: time || null,
81
+ lastMessages: [this._.messages[this._.messages.length - 1].message],
82
+ }, this._.id);
83
+ return true;
84
+ });
85
+ }
86
+ async presence(status) {
87
+ return await this.$.tick(async (socket) => {
88
+ await socket.sendPresenceUpdate(status, this._.id);
89
+ return true;
90
+ });
91
+ }
92
+ async delete() {
93
+ return this.$.tick(async (socket) => {
94
+ await socket.chatModify({
95
+ delete: true,
96
+ lastMessages: [this._.messages[this._.messages.length - 1].message],
97
+ }, this._.id);
98
+ return true;
99
+ });
100
+ }
101
+ }
102
+ exports.default = Chat;
103
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/model/chat.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAC1B,wDAAoD;AAEpD,MAAqB,IAAK,SAAQ,cAAkB;IAIhD,KAAK,CAAC,IAAI,CAAC,OAAuC,EAAE,OAAa;QAC7D,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAS,CAAC;gBACrE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBAC9B,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;wBAChC,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI,KAAK;qBACnC,CAAC,CAAC;oBACH,OAAO,IAAI,CAAC;gBAChB,CAAC;qBAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,C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,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,MAAM,MAAM,CAAC,UAAU,CAAC;gBACpB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,QAAS,CAAC,IAAI,CAAC,CAAC,CAAC,QAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAQ,CAAC;aACzE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACd,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAnGD,uBAmGC"}
@@ -0,0 +1,19 @@
1
+ import * as Baileys from 'baileys';
2
+ import Base from './base';
3
+ export interface MessageOptions {
4
+ type?: "audio" | "video" | "image" | "location";
5
+ caption?: string;
6
+ ptt?: boolean;
7
+ ptv?: boolean;
8
+ once?: boolean;
9
+ }
10
+ export default class Message extends Base<Baileys.WAProto.IWebMessageInfo> {
11
+ reply(text: string, options?: {
12
+ once: boolean;
13
+ }): Promise<boolean>;
14
+ reply(media: Baileys.WAMediaUpload, options: MessageOptions): Promise<boolean>;
15
+ seen(): Promise<boolean>;
16
+ delete(forall?: boolean): Promise<boolean>;
17
+ like(emoji: string): Promise<boolean>;
18
+ forward(chat_id: string): Promise<boolean>;
19
+ }
@@ -0,0 +1,81 @@
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 Message extends base_1.default {
8
+ async reply(content, options) {
9
+ return this.$.tick(async (socket) => {
10
+ // prettier-ignore
11
+ const _options = { type: 'text', ...options };
12
+ if (typeof content === 'string') {
13
+ await socket.sendMessage(this._.key.remoteJid, {
14
+ text: content,
15
+ viewOnce: _options.once || false,
16
+ }, { quoted: this._ });
17
+ return true;
18
+ }
19
+ else if (Buffer.isBuffer(content)) {
20
+ await socket.sendMessage(this._.key.remoteJid, {
21
+ viewOnce: _options.once || false,
22
+ ptv: !!(_options.type === 'video' && _options.ptv),
23
+ ptt: !!(_options.type === 'audio' && _options.ptt),
24
+ image: _options.type === 'image' ? content : undefined,
25
+ audio: _options.type === 'audio' ? content : undefined,
26
+ video: _options.type === 'video' ? content : undefined,
27
+ }, { quoted: this._ });
28
+ return true;
29
+ }
30
+ return false;
31
+ });
32
+ }
33
+ async seen() {
34
+ return this.$.tick(async (socket) => {
35
+ // prettier-ignore
36
+ await socket.chatModify({
37
+ markRead: true,
38
+ lastMessages: [this._],
39
+ }, this._.key.remoteJid);
40
+ return true;
41
+ });
42
+ }
43
+ async delete(forall = false) {
44
+ return this.$.tick(async (socket) => {
45
+ if (forall) {
46
+ await socket.sendMessage(this._.key.remoteJid, {
47
+ delete: this._.key,
48
+ });
49
+ }
50
+ else {
51
+ // prettier-ignore
52
+ await socket.chatModify({
53
+ deleteForMe: {
54
+ key: this._.key,
55
+ deleteMedia: true,
56
+ timestamp: this._.messageTimestamp,
57
+ },
58
+ }, this._.key.remoteJid);
59
+ }
60
+ return true;
61
+ });
62
+ }
63
+ async like(emoji) {
64
+ return this.$.tick(async (socket) => {
65
+ await socket.sendMessage(this._.key.remoteJid, {
66
+ react: { text: emoji, key: this._.key, },
67
+ });
68
+ return true;
69
+ });
70
+ }
71
+ async forward(chat_id) {
72
+ return this.$.tick(async (socket) => {
73
+ await socket.sendMessage(chat_id, {
74
+ forward: { key: this._.key },
75
+ });
76
+ return true;
77
+ });
78
+ }
79
+ }
80
+ exports.default = Message;
81
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/model/message.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAW1B,MAAqB,OAAQ,SAAQ,cAAqC;IAItE,KAAK,CAAC,KAAK,CAAC,OAAY,EAAE,OAAa;QACnC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KA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,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,SAAU,EAAE;gBAC5C,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG;aAC3C,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAe;QACzB,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,MAAM,MAAM,CAAC,WAAW,CAAC,OAAQ,EAAE;gBAC/B,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE;aAC/B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA7ED,0BA6EC"}
@@ -0,0 +1,160 @@
1
+ import * as Baileys from 'baileys';
2
+ /**
3
+ * @module Store
4
+ * @description
5
+ * Minimal contract that any persistence backend used by **@arcaelas/whatsapp**
6
+ * must implement.
7
+ *
8
+ * - **Strict key–value model** &rarr; **all keys are `string`**.
9
+ * - **Values can only be `string` or `null`**.
10
+ * - **The interface itself does *not* handle serialization**.
11
+ * Implementations decide whether to apply `JSON.stringify`/`JSON.parse`,
12
+ * BSON, Base64, etc. — as long as they expose/consume `string | null`.
13
+ *
14
+ * This design works from an in‑memory `Map` up to Redis, SQLite, or even S3,
15
+ * while keeping a uniform, fully‑asynchronous API.
16
+ */
17
+ export interface Engine {
18
+ /**
19
+ * Check whether a key exists.
20
+ *
21
+ * @param key Key to test.
22
+ * @returns `true` if present; `false` otherwise.
23
+ *
24
+ * @example
25
+ * const logged = await store.has('session');
26
+ */
27
+ has(key: string): Promise<boolean>;
28
+ /**
29
+ * Retrieve the value associated with a key.
30
+ *
31
+ * @param key Key to read.
32
+ * @param fallback Default value if the key is missing (`null` if omitted).
33
+ * @returns Stored `string` or `fallback`.
34
+ *
35
+ * @example
36
+ * const raw = await store.get('user:123'); // '{"name":"Miguel"}'
37
+ */
38
+ get(key: string, fallback?: string | null): Promise<string | null>;
39
+ /**
40
+ * Store a **string value**.
41
+ *
42
+ * > Passing `null` or `undefined` deletes the key (same as `delete()`).
43
+ *
44
+ * @param key Destination key.
45
+ * @param value String to save, or `null` to remove.
46
+ * @returns `true` on success; `false` on failure.
47
+ *
48
+ * @example
49
+ * await store.set('token', 'abc123');
50
+ */
51
+ set(key: string, value: string | null): Promise<boolean>;
52
+ /**
53
+ * Remove a key.
54
+ *
55
+ * @param key Key to delete.
56
+ * @returns `true` if removed; `false` if it did not exist.
57
+ *
58
+ * @example
59
+ * await store.delete('cache:config');
60
+ */
61
+ delete(key: string): Promise<boolean>;
62
+ /**
63
+ * Iterate over all keys.
64
+ *
65
+ * @returns `AsyncGenerator` yielding each key.
66
+ *
67
+ * @example
68
+ * for await (const key of store.keys()) console.log(key);
69
+ */
70
+ keys(): AsyncGenerator<string>;
71
+ /**
72
+ * Iterate over all values (`string | null`).
73
+ *
74
+ * @returns `AsyncGenerator` yielding each value.
75
+ *
76
+ * @example
77
+ * for await (const value of store.values()) console.log(value);
78
+ */
79
+ values(): AsyncGenerator<string | null>;
80
+ /**
81
+ * Iterate over `[key, value]` pairs.
82
+ *
83
+ * @returns `AsyncGenerator<[string, string | null]>`.
84
+ *
85
+ * @example
86
+ * for await (const [k, v] of store.entries()) console.log(k, v);
87
+ */
88
+ entries(): AsyncGenerator<[string, string | null]>;
89
+ /**
90
+ * Remove **all** keys.
91
+ *
92
+ * @returns `true` when the store is empty; `false` if an error occurred.
93
+ *
94
+ * @example
95
+ * await store.clear();
96
+ */
97
+ clear(): Promise<boolean>;
98
+ /**
99
+ * (Optional) Filter keys using a **glob pattern** (`*` as wildcard).
100
+ *
101
+ * - `user:*` → everything starting with `user:`
102
+ * - `log:*:error` → simultaneous prefix and suffix
103
+ *
104
+ * @param pattern Glob pattern.
105
+ * @returns Array of matching keys.
106
+ *
107
+ * @example
108
+ * const keys = await store.scan?.('user:*:active');
109
+ */
110
+ scan?(pattern: string): Promise<string[]>;
111
+ }
112
+ export default class Store {
113
+ readonly engine: Engine;
114
+ constructor(engine: Engine);
115
+ document: {
116
+ set: (filename: string, content: any) => Promise<boolean>;
117
+ get: <T>(filename: string) => Promise<T | null>;
118
+ has: (filename: string) => Promise<boolean>;
119
+ delete: (filename: string) => Promise<boolean>;
120
+ keys: () => {
121
+ [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
122
+ };
123
+ values: () => {
124
+ [Symbol.asyncIterator](): AsyncGenerator<any, void, unknown>;
125
+ };
126
+ entries: () => {
127
+ [Symbol.asyncIterator](): AsyncGenerator<readonly [string, any], void, unknown>;
128
+ };
129
+ };
130
+ chat: {
131
+ set: (chat: Baileys.Chat) => Promise<boolean>;
132
+ get: (id: string) => Promise<Baileys.Chat | null>;
133
+ has: (id: string) => Promise<boolean>;
134
+ delete: (id: string) => Promise<boolean>;
135
+ keys: () => {
136
+ [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
137
+ };
138
+ values: () => {
139
+ [Symbol.asyncIterator](): AsyncGenerator<Baileys.Chat, void, unknown>;
140
+ };
141
+ entries: () => {
142
+ [Symbol.asyncIterator](): AsyncGenerator<readonly [string, Baileys.Chat], void, unknown>;
143
+ };
144
+ };
145
+ message: {
146
+ set: (message: Baileys.WAProto.IWebMessageInfo) => Promise<boolean>;
147
+ get: (id: string) => Promise<Baileys.WAProto.IWebMessageInfo | null>;
148
+ has: (id: string) => Promise<boolean>;
149
+ delete: (id: string) => Promise<boolean>;
150
+ keys: () => {
151
+ [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
152
+ };
153
+ values: () => {
154
+ [Symbol.asyncIterator](): AsyncGenerator<Baileys.WAProto.IWebMessageInfo, void, unknown>;
155
+ };
156
+ entries: () => {
157
+ [Symbol.asyncIterator](): AsyncGenerator<readonly [string, Baileys.WAProto.IWebMessageInfo], void, unknown>;
158
+ };
159
+ };
160
+ }