@imjxsx/wapi 1.1.0-beta → 1.2.0
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.
- package/README.md +1 -1
- package/dist/cache/contacts.js +2 -2
- package/dist/cache/contacts.js.map +7 -1
- package/dist/cache/groups.js +2 -2
- package/dist/cache/groups.js.map +7 -1
- package/dist/cache/index.js +2 -3
- package/dist/cache/index.js.map +7 -1
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +2 -0
- package/dist/core/auth/index.js.map +7 -0
- package/dist/{auth → core/auth}/local.d.ts +1 -1
- package/dist/core/auth/local.d.ts.map +1 -0
- package/dist/core/auth/local.js +2 -0
- package/dist/core/auth/local.js.map +7 -0
- package/dist/{auth → core/auth}/mongo.d.ts +1 -1
- package/dist/core/auth/mongo.d.ts.map +1 -0
- package/dist/core/auth/mongo.js +2 -0
- package/dist/core/auth/mongo.js.map +7 -0
- package/dist/{auth → core/auth}/redis.d.ts +1 -1
- package/dist/core/auth/redis.d.ts.map +1 -0
- package/dist/core/auth/redis.js +2 -0
- package/dist/core/auth/redis.js.map +7 -0
- package/dist/{bot → core}/bot.d.ts +7 -5
- package/dist/core/bot.d.ts.map +1 -0
- package/dist/core/bot.js +2 -0
- package/dist/core/bot.js.map +7 -0
- package/dist/{context → core/context}/context.d.ts +3 -2
- package/dist/core/context/context.d.ts.map +1 -0
- package/dist/core/context/context.js +2 -0
- package/dist/core/context/context.js.map +7 -0
- package/dist/{context → core/context}/message.d.ts +5 -5
- package/dist/core/context/message.d.ts.map +1 -0
- package/dist/core/context/message.js +2 -0
- package/dist/core/context/message.js.map +7 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +7 -1
- package/dist/types/bot.d.ts +1 -1
- package/dist/types/bot.d.ts.map +1 -1
- package/dist/types/bot.js +1 -2
- package/dist/types/bot.js.map +7 -1
- package/dist/types/context.d.ts +19 -0
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/context.js +1 -2
- package/dist/types/context.js.map +7 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -4
- package/dist/types/index.js.map +7 -1
- package/dist/utils/converters.d.ts +3 -0
- package/dist/utils/converters.d.ts.map +1 -0
- package/dist/utils/converters.js +2 -0
- package/dist/utils/converters.js.map +7 -0
- package/dist/utils/crypto.js +2 -33
- package/dist/utils/crypto.js.map +7 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -7
- package/dist/utils/index.js.map +7 -1
- package/dist/utils/jid.d.ts +1 -2
- package/dist/utils/jid.d.ts.map +1 -1
- package/dist/utils/jid.js +2 -22
- package/dist/utils/jid.js.map +7 -1
- package/dist/utils/message-builder.js +3 -61
- package/dist/utils/message-builder.js.map +7 -1
- package/dist/utils/utils.js +2 -4
- package/dist/utils/utils.js.map +7 -1
- package/dist/utils/validators.d.ts +11 -0
- package/dist/utils/validators.d.ts.map +1 -0
- package/dist/utils/validators.js +2 -0
- package/dist/utils/validators.js.map +7 -0
- package/package.json +16 -14
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -4
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/local.d.ts.map +0 -1
- package/dist/auth/local.js +0 -117
- package/dist/auth/local.js.map +0 -1
- package/dist/auth/mongo.d.ts.map +0 -1
- package/dist/auth/mongo.js +0 -120
- package/dist/auth/mongo.js.map +0 -1
- package/dist/auth/redis.d.ts.map +0 -1
- package/dist/auth/redis.js +0 -116
- package/dist/auth/redis.js.map +0 -1
- package/dist/bot/bot.d.ts.map +0 -1
- package/dist/bot/bot.js +0 -62
- package/dist/bot/bot.js.map +0 -1
- package/dist/bot/disconnect.d.ts +0 -4
- package/dist/bot/disconnect.d.ts.map +0 -1
- package/dist/bot/disconnect.js +0 -12
- package/dist/bot/disconnect.js.map +0 -1
- package/dist/bot/events/connection-update.d.ts +0 -4
- package/dist/bot/events/connection-update.d.ts.map +0 -1
- package/dist/bot/events/connection-update.js +0 -84
- package/dist/bot/events/connection-update.js.map +0 -1
- package/dist/bot/events/contacts-update.d.ts +0 -3
- package/dist/bot/events/contacts-update.d.ts.map +0 -1
- package/dist/bot/events/contacts-update.js +0 -22
- package/dist/bot/events/contacts-update.js.map +0 -1
- package/dist/bot/events/creds-update.d.ts +0 -3
- package/dist/bot/events/creds-update.d.ts.map +0 -1
- package/dist/bot/events/creds-update.js +0 -17
- package/dist/bot/events/creds-update.js.map +0 -1
- package/dist/bot/events/groups-update.d.ts +0 -3
- package/dist/bot/events/groups-update.d.ts.map +0 -1
- package/dist/bot/events/groups-update.js +0 -22
- package/dist/bot/events/groups-update.js.map +0 -1
- package/dist/bot/events/index.d.ts +0 -6
- package/dist/bot/events/index.d.ts.map +0 -1
- package/dist/bot/events/index.js +0 -6
- package/dist/bot/events/index.js.map +0 -1
- package/dist/bot/events/message-upsert.d.ts +0 -3
- package/dist/bot/events/message-upsert.d.ts.map +0 -1
- package/dist/bot/events/message-upsert.js +0 -57
- package/dist/bot/events/message-upsert.js.map +0 -1
- package/dist/bot/index.d.ts +0 -2
- package/dist/bot/index.d.ts.map +0 -1
- package/dist/bot/index.js +0 -2
- package/dist/bot/index.js.map +0 -1
- package/dist/bot/login.d.ts +0 -3
- package/dist/bot/login.d.ts.map +0 -1
- package/dist/bot/login.js +0 -41
- package/dist/bot/login.js.map +0 -1
- package/dist/bot/logout.d.ts +0 -4
- package/dist/bot/logout.d.ts.map +0 -1
- package/dist/bot/logout.js +0 -10
- package/dist/bot/logout.js.map +0 -1
- package/dist/bot/utils.d.ts +0 -10
- package/dist/bot/utils.d.ts.map +0 -1
- package/dist/bot/utils.js +0 -101
- package/dist/bot/utils.js.map +0 -1
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js +0 -142
- package/dist/context/context.js.map +0 -1
- package/dist/context/index.d.ts +0 -3
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -3
- package/dist/context/index.js.map +0 -1
- package/dist/context/message.d.ts.map +0 -1
- package/dist/context/message.js +0 -170
- package/dist/context/message.js.map +0 -1
- package/dist/types/message.d.ts +0 -15
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/message.js +0 -2
- package/dist/types/message.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -9
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -72
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -21
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -68
- package/dist/utils/helpers.js.map +0 -1
- /package/dist/{auth → core/auth}/index.d.ts +0 -0
package/README.md
CHANGED
package/dist/cache/contacts.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=contacts.js.map
|
|
1
|
+
const t=new Map;export{t as contacts};
|
|
2
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cache/contacts.ts"],
|
|
4
|
+
"sourcesContent": ["interface IContact {\n jid: string;\n pn: string;\n name: string;\n}\nexport const contacts = new Map<string, IContact>();"],
|
|
5
|
+
"mappings": "AAKO,MAAMA,EAAW,IAAI",
|
|
6
|
+
"names": ["contacts"]
|
|
7
|
+
}
|
package/dist/cache/groups.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=groups.js.map
|
|
1
|
+
const t=new Map;export{t as groups};
|
|
2
|
+
//# sourceMappingURL=groups.js.map
|
package/dist/cache/groups.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cache/groups.ts"],
|
|
4
|
+
"sourcesContent": ["import type { GroupMetadata } from \"baileys\";\n\nexport const groups = new Map<string, GroupMetadata>();"],
|
|
5
|
+
"mappings": "AAEO,MAAMA,EAAS,IAAI",
|
|
6
|
+
"names": ["groups"]
|
|
7
|
+
}
|
package/dist/cache/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./contacts.js";export*from"./groups.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cache/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cache/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./contacts.js\";\nexport * from \"./groups.js\";"],
|
|
5
|
+
"mappings": "AAAA,WAAc,gBACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/core/auth/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,KAAK,CAAC,CAAsB;IAC7B,IAAI,EAAE,IAAI,CAAC;gBACN,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;YAQ3B,GAAG;YA0BH,GAAG;YAmBH,MAAM;IAYP,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IA6C7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createHash as h}from"node:crypto";import c from"node:path";import{initAuthCreds as f,proto as y}from"baileys";import{AES256GCM as m,isBuffer as d,isString as u,isUint8Array as l,isUUID as g}from"../../utils/index.js";import n from"node:fs";class B{directory;aes;cache=new Map;creds;uuid;constructor(s,t){if(!g(s))throw new Error(`'${s}' is not a valid UUID.`);this.directory=c.isAbsolute(t)?c.join(t,s):c.resolve(t,s),this.aes=new m(s),this.uuid=s}async get(s){const t=h("md5").update(s).digest("hex"),i=c.join(this.directory,`${t}.enc`);try{await n.promises.access(i)}catch{return null}const r=this.cache.get(t)??await n.promises.readFile(i);if(!d(r))return null;this.cache.set(t,r);const a=this.aes.decrypt(r);return d(a)?JSON.parse(a.toString("utf8"),(p,e)=>e?.type!=="Buffer"&&!u(e?.data)?e:Buffer.from(e.data,"base64")):null}async set(s,t){const i=h("md5").update(s).digest("hex"),r=c.join(this.directory,`${i}.enc`),a=JSON.stringify(t,(p,e)=>!d(e)&&!l(e)&&e?.type!=="Buffer"?e:{type:"Buffer",data:Buffer.from(e.data??e).toString("base64")}),o=this.aes.encrypt(Buffer.from(a,"utf8"));d(o)&&(await n.promises.writeFile(r,o),this.cache.set(i,o))}async delete(s){const t=h("md5").update(s).digest("hex"),i=c.join(this.directory,`${t}.enc`);try{await n.promises.access(i)}catch{return}await n.promises.unlink(i),this.cache.delete(t)}async init(){try{await n.promises.access(this.directory)}catch{await n.promises.mkdir(this.directory,{recursive:!0})}this.creds=await this.get("creds")??f();const s={get:async(t,i)=>{const r={},a=[];for(const o of i){const p=async()=>{let e=await this.get(`${t}-${o}`);e!==null&&t==="app-state-sync-key"&&(e=y.Message.AppStateSyncKeyData.fromObject(e)),r[o]=e};a.push(p())}return await Promise.all(a),r},set:async t=>{const i=[];for(const r of Object.keys(t))if(t[r])for(const a of Object.keys(t[r])){const o=t[r][a],p=o?this.set(`${r}-${a}`,o):this.delete(`${r}-${a}`);i.push(p)}await Promise.all(i)}};return{creds:this.creds,keys:s}}async save(){if(!this.creds)throw new Error("Credentials not loaded.");await this.set("creds",this.creds)}async remove(){await n.promises.rm(this.directory,{recursive:!0,force:!0}),this.cache.clear()}}export{B as LocalAuth};
|
|
2
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/auth/local.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash, type UUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { initAuthCreds, proto, SignalDataSet, type AuthenticationCreds, type SignalDataTypeMap, type SignalKeyStore } from \"baileys\";\nimport type { IBotAuthInit } from \"../../types/index.js\";\nimport { AES256GCM, isBuffer, isString, isUint8Array, isUUID } from \"../../utils/index.js\";\nimport fs from \"node:fs\";\n\nexport class LocalAuth {\n private directory: string;\n private aes: AES256GCM;\n private cache = new Map<string, Buffer>();\n private creds?: AuthenticationCreds;\n public uuid: UUID;\n constructor(uuid: UUID, directory: string) {\n if (!isUUID(uuid)) {\n throw new Error(`'${uuid}' is not a valid UUID.`);\n }\n this.directory = path.isAbsolute(directory) ? path.join(directory, uuid) : path.resolve(directory, uuid);\n this.aes = new AES256GCM(uuid);\n this.uuid = uuid;\n }\n private async get<T>(key: string): Promise<T | null> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const filepath = path.join(this.directory, `${md5}.enc`);\n try {\n await fs.promises.access(filepath);\n }\n catch {\n return null;\n }\n const encrypted = this.cache.get(md5) ?? await fs.promises.readFile(filepath);\n if (!isBuffer(encrypted)) {\n return null;\n }\n this.cache.set(md5, encrypted);\n const decrypted = this.aes.decrypt(encrypted);\n if (!isBuffer(decrypted)) {\n return null;\n }\n const parsed = JSON.parse(decrypted.toString(\"utf8\"), (_, value) => {\n if (value?.type !== \"Buffer\" && !isString(value?.data)) {\n return value;\n }\n return Buffer.from(value.data, \"base64\");\n });\n return parsed;\n }\n private async set(key: string, value: any): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const filepath = path.join(this.directory, `${md5}.enc`);\n const stringified = JSON.stringify(value, (_, value) => {\n if (!isBuffer(value) && !isUint8Array(value) && value?.type !== \"Buffer\") {\n return value;\n }\n return {\n type: \"Buffer\",\n data: Buffer.from(value.data ?? value).toString(\"base64\"),\n };\n });\n const encrypted = this.aes.encrypt(Buffer.from(stringified, \"utf8\"));\n if (!isBuffer(encrypted)) {\n return;\n }\n await fs.promises.writeFile(filepath, encrypted);\n this.cache.set(md5, encrypted);\n }\n private async delete(key: string): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const filepath = path.join(this.directory, `${md5}.enc`);\n try {\n await fs.promises.access(filepath);\n }\n catch {\n return;\n }\n await fs.promises.unlink(filepath);\n this.cache.delete(md5);\n }\n public async init(): Promise<IBotAuthInit> {\n try {\n await fs.promises.access(this.directory);\n }\n catch {\n await fs.promises.mkdir(this.directory, { recursive: true });\n }\n this.creds = await this.get<AuthenticationCreds>(\"creds\") ?? initAuthCreds();\n const keys: SignalKeyStore = {\n get: async (type, ids) => {\n const value: Record<string, SignalDataTypeMap[typeof type]> = {};\n const tasks: Promise<void>[] = [];\n for (const id of ids) {\n const task = async () => {\n let data = await this.get<any>(`${type}-${id}`);\n if (data !== null && type === \"app-state-sync-key\") {\n data = proto.Message.AppStateSyncKeyData.fromObject(data);\n }\n value[id] = data;\n };\n tasks.push(task());\n }\n await Promise.all(tasks);\n return value;\n },\n set: async (data) => {\n const tasks: Promise<void>[] = [];\n for (const type of (Object.keys(data) as (keyof SignalDataSet)[])) {\n if (!data[type]) {\n continue;\n }\n for (const id of Object.keys(data[type])) {\n const value = data[type][id];\n const task = value ? this.set(`${type}-${id}`, value) : this.delete(`${type}-${id}`);\n tasks.push(task);\n }\n }\n await Promise.all(tasks);\n },\n };\n return {\n creds: this.creds,\n keys,\n };\n }\n public async save(): Promise<void> {\n if (!this.creds) {\n throw new Error(\"Credentials not loaded.\");\n }\n await this.set(\"creds\", this.creds);\n }\n public async remove(): Promise<void> {\n await fs.promises.rm(this.directory, { recursive: true, force: true });\n this.cache.clear();\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAA6B,cACtC,OAAOC,MAAU,YACjB,OAAS,iBAAAC,EAAe,SAAAC,MAAmG,UAE3H,OAAS,aAAAC,EAAW,YAAAC,EAAU,YAAAC,EAAU,gBAAAC,EAAc,UAAAC,MAAc,uBACpE,OAAOC,MAAQ,UAER,MAAMC,CAAU,CACb,UACA,IACA,MAAQ,IAAI,IACZ,MACD,KACP,YAAYC,EAAYC,EAAmB,CACzC,GAAI,CAACJ,EAAOG,CAAI,EACd,MAAM,IAAI,MAAM,IAAIA,CAAI,wBAAwB,EAElD,KAAK,UAAYV,EAAK,WAAWW,CAAS,EAAIX,EAAK,KAAKW,EAAWD,CAAI,EAAIV,EAAK,QAAQW,EAAWD,CAAI,EACvG,KAAK,IAAM,IAAIP,EAAUO,CAAI,EAC7B,KAAK,KAAOA,CACd,CACA,MAAc,IAAOE,EAAgC,CACnD,MAAMC,EAAMd,EAAW,KAAK,EAAE,OAAOa,CAAG,EAAE,OAAO,KAAK,EAChDE,EAAWd,EAAK,KAAK,KAAK,UAAW,GAAGa,CAAG,MAAM,EACvD,GAAI,CACF,MAAML,EAAG,SAAS,OAAOM,CAAQ,CACnC,MACM,CACJ,OAAO,IACT,CACA,MAAMC,EAAY,KAAK,MAAM,IAAIF,CAAG,GAAK,MAAML,EAAG,SAAS,SAASM,CAAQ,EAC5E,GAAI,CAACV,EAASW,CAAS,EACrB,OAAO,KAET,KAAK,MAAM,IAAIF,EAAKE,C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
|
|
6
|
+
"names": ["createHash", "path", "initAuthCreds", "proto", "AES256GCM", "isBuffer", "isString", "isUint8Array", "isUUID", "fs", "LocalAuth", "uuid", "directory", "key", "md5", "filepath", "encrypted", "decrypted", "_", "value", "stringified", "keys", "type", "ids", "tasks", "id", "task", "data"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UUID } from "node:crypto";
|
|
2
2
|
import type { Collection, Document } from "mongodb";
|
|
3
|
-
import type { IBotAuthInit } from "
|
|
3
|
+
import type { IBotAuthInit } from "../../types/index.js";
|
|
4
4
|
interface IAuthState extends Document {
|
|
5
5
|
uuid: UUID;
|
|
6
6
|
key: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../../src/core/auth/mongo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,UAAU,UAAW,SAAQ,QAAQ;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,KAAK,CAAC,CAAsB;IACpC,OAAO,CAAC,UAAU,CAAyB;IACpC,IAAI,EAAE,IAAI,CAAC;gBACN,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC;YAQ5C,GAAG;YA0BH,GAAG;YAsBH,MAAM;IAIP,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAuC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createHash as d}from"node:crypto";import{initAuthCreds as u,proto as p}from"baileys";import{AES256GCM as f,isBuffer as c,isString as y,isUint8Array as h,isUUID as l}from"../../utils/index.js";class k{aes;cache=new Map;creds;collection;uuid;constructor(r,t){if(!l(r))throw new Error(`'${r}' is not a valid UUID.`);this.collection=t,this.aes=new f(r),this.uuid=r}async get(r){const t=d("md5").update(r).digest("hex");let i=this.cache.get(t);if(!i){const o=await this.collection.findOne({uuid:this.uuid,key:t});if(!o)return null;i=Buffer.from(o.encrypted,"base64")}if(!c(i))return null;this.cache.set(t,i);const s=this.aes.decrypt(i);return c(s)?JSON.parse(s.toString("utf8"),(o,e)=>e?.type!=="Buffer"&&!y(e?.data)?e:Buffer.from(e.data,"base64")):null}async set(r,t){const i=d("md5").update(r).digest("hex"),s=JSON.stringify(t,(o,e)=>!c(e)&&!h(e)&&e?.type!=="Buffer"?e:{type:"Buffer",data:Buffer.from(e.data??e).toString("base64")}),n=this.aes.encrypt(Buffer.from(s,"utf8"));c(n)&&(await this.collection.updateOne({uuid:this.uuid,key:i},{$set:{encrypted:n.toString("base64")}},{upsert:!0}),this.cache.set(i,n))}async delete(r){const t=d("md5").update(r).digest("hex");await this.collection.deleteOne({uuid:this.uuid,key:t})}async init(){this.creds=await this.get("creds")??u();const r={get:async(t,i)=>{const s={},n=[];for(const o of i){const e=async()=>{let a=await this.get(`${t}-${o}`);a!==null&&t==="app-state-sync-key"&&(a=p.Message.AppStateSyncKeyData.fromObject(a)),s[o]=a};n.push(e())}return await Promise.all(n),s},set:async t=>{const i=[];for(const s of Object.keys(t))if(t[s])for(const n of Object.keys(t[s])){const o=t[s][n],e=o?this.set(`${s}-${n}`,o):this.delete(`${s}-${n}`);i.push(e)}await Promise.all(i)}};return{creds:this.creds,keys:r}}async save(){if(!this.creds)throw new Error("Credentials not loaded.");await this.set("creds",this.creds)}async remove(){await this.collection.deleteMany({uuid:this.uuid}),this.cache.clear()}}export{k as MongoAuth};
|
|
2
|
+
//# sourceMappingURL=mongo.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/auth/mongo.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash, type UUID } from \"node:crypto\";\nimport { initAuthCreds, proto, SignalDataSet, type AuthenticationCreds, type SignalDataTypeMap, type SignalKeyStore } from \"baileys\";\nimport type { Collection, Document } from \"mongodb\";\nimport { AES256GCM, isBuffer, isString, isUint8Array, isUUID } from \"../../utils/index.js\";\nimport type { IBotAuthInit } from \"../../types/index.js\";\n\ninterface IAuthState extends Document {\n uuid: UUID;\n key: string;\n encrypted: string;\n}\nexport class MongoAuth {\n private aes: AES256GCM;\n private cache = new Map<string, Buffer>();\n private creds?: AuthenticationCreds;\n private collection: Collection<IAuthState>;\n public uuid: UUID;\n constructor(uuid: UUID, collection: Collection<IAuthState>) {\n if (!isUUID(uuid)) {\n throw new Error(`'${uuid}' is not a valid UUID.`);\n }\n this.collection = collection;\n this.aes = new AES256GCM(uuid);\n this.uuid = uuid;\n }\n private async get<T>(key: string): Promise<T | null> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n let encrypted = this.cache.get(md5);\n if (!encrypted) {\n const document = await this.collection.findOne({ uuid: this.uuid, key: md5 });\n if (!document) {\n return null;\n }\n encrypted = Buffer.from(document.encrypted, \"base64\");\n }\n if (!isBuffer(encrypted)) {\n return null;\n }\n this.cache.set(md5, encrypted);\n const decrypted = this.aes.decrypt(encrypted);\n if (!isBuffer(decrypted)) {\n return null;\n }\n const parsed = JSON.parse(decrypted.toString(\"utf8\"), (_, value) => {\n if (value?.type !== \"Buffer\" && !isString(value?.data)) {\n return value;\n }\n return Buffer.from(value.data, \"base64\");\n });\n return parsed;\n }\n private async set(key: string, value: any): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const stringified = JSON.stringify(value, (_, value) => {\n if (!isBuffer(value) && !isUint8Array(value) && value?.type !== \"Buffer\") {\n return value;\n }\n return {\n type: \"Buffer\",\n data: Buffer.from(value.data ?? value).toString(\"base64\"),\n };\n });\n const encrypted = this.aes.encrypt(Buffer.from(stringified, \"utf8\"));\n if (!isBuffer(encrypted)) {\n return;\n }\n await this.collection.updateOne({ uuid: this.uuid, key: md5 }, {\n $set: {\n encrypted: encrypted.toString(\"base64\"),\n },\n }, { upsert: true });\n this.cache.set(md5, encrypted);\n }\n private async delete(key: string): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n await this.collection.deleteOne({ uuid: this.uuid, key: md5 });\n }\n public async init(): Promise<IBotAuthInit> {\n this.creds = await this.get<AuthenticationCreds>(\"creds\") ?? initAuthCreds();\n const keys: SignalKeyStore = {\n get: async (type, ids) => {\n const value: Record<string, SignalDataTypeMap[typeof type]> = {};\n const tasks: Promise<void>[] = [];\n for (const id of ids) {\n const task = async () => {\n let data = await this.get<any>(`${type}-${id}`);\n if (data !== null && type === \"app-state-sync-key\") {\n data = proto.Message.AppStateSyncKeyData.fromObject(data);\n }\n value[id] = data;\n };\n tasks.push(task());\n }\n await Promise.all(tasks);\n return value;\n },\n set: async (data) => {\n const tasks: Promise<void>[] = [];\n for (const type of (Object.keys(data) as (keyof SignalDataSet)[])) {\n if (!data[type]) {\n continue;\n }\n for (const id of Object.keys(data[type])) {\n const value = data[type][id];\n const task = value ? this.set(`${type}-${id}`, value) : this.delete(`${type}-${id}`);\n tasks.push(task);\n }\n }\n await Promise.all(tasks);\n },\n };\n return {\n creds: this.creds,\n keys,\n };\n }\n public async save(): Promise<void> {\n if (!this.creds) {\n throw new Error(\"Credentials not loaded.\");\n }\n await this.set(\"creds\", this.creds);\n }\n public async remove(): Promise<void> {\n await this.collection.deleteMany({ uuid: this.uuid });\n this.cache.clear();\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAA6B,cACtC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AAC,EAAG,CACxC,MAAMH,EAAQQ,EAAKL,CAAI,EAAEG,CAAE,EACrBC,EAAOP,EAAQ,KAAK,IAAI,GAAGG,CAAI,IAAIG,CAAE,GAAIN,CAAK,EAAI,KAAK,OAAO,GAAGG,CAAI,IAAIG,CAAE,EAAE,EACnFD,EAAM,KAAKE,CAAI,CACjB,CAEF,MAAM,QAAQ,IAAIF,CAAK,CACzB,CACF,EACA,MAAO,CACL,MAAO,KAAK,MACZ,KAAAH,CACF,CACF,CACA,MAAa,MAAsB,CACjC,GAAI,CAAC,KAAK,MACR,MAAM,IAAI,MAAM,yBAAyB,EAE3C,MAAM,KAAK,IAAI,QAAS,KAAK,KAAK,CACpC,CACA,MAAa,QAAwB,CACnC,MAAM,KAAK,WAAW,WAAW,CAAE,KAAM,KAAK,IAAK,CAAC,EACpD,KAAK,MAAM,MAAM,CACnB,CACF",
|
|
6
|
+
"names": ["createHash", "initAuthCreds", "proto", "AES256GCM", "isBuffer", "isString", "isUint8Array", "isUUID", "MongoAuth", "uuid", "collection", "key", "md5", "encrypted", "document", "decrypted", "_", "value", "stringified", "keys", "type", "ids", "tasks", "id", "task", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/core/auth/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,KAAK,CAAC,CAAsB;IACpC,OAAO,CAAC,KAAK,CAAQ;IACd,IAAI,EAAE,IAAI,CAAC;gBACN,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;YAStC,GAAG;YAmBH,GAAG;YAkBH,GAAG;IAKJ,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAuC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAQrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createHash as d}from"node:crypto";import{initAuthCreds as p,proto as f}from"baileys";import{AES256GCM as h,isBuffer as c,isString as y,isUint8Array as u,isUUID as m}from"../../utils/index.js";class v{prefix;aes;cache=new Map;creds;redis;uuid;constructor(e,t,i){if(!m(e))throw new Error(`'${e}' is not a valid UUID.`);this.prefix=`${i}:${e}:`,this.aes=new h(e),this.redis=t,this.uuid=e}async get(e){const t=d("md5").update(e).digest("hex"),i=this.cache.get(t)??await this.redis.getBuffer(`${this.prefix+t}`);if(!c(i))return null;this.cache.set(t,i);const r=this.aes.decrypt(i);return c(r)?JSON.parse(r.toString("utf8"),(n,s)=>s?.type!=="Buffer"&&!y(s?.data)?s:Buffer.from(s.data,"base64")):null}async set(e,t){const i=d("md5").update(e).digest("hex"),r=JSON.stringify(t,(n,s)=>!c(s)&&!u(s)&&s?.type!=="Buffer"?s:{type:"Buffer",data:Buffer.from(s.data??s).toString("base64")}),a=this.aes.encrypt(Buffer.from(r,"utf8"));c(a)&&(await this.redis.set(`${this.prefix+i}`,a),this.cache.set(i,a))}async del(e){const t=d("md5").update(e).digest("hex");await this.redis.del(`${this.prefix+t}`),this.cache.delete(t)}async init(){this.creds=await this.get("creds")??p();const e={get:async(t,i)=>{const r={},a=[];for(const n of i){const s=async()=>{let o=await this.get(`${t}-${n}`);o!==null&&t==="app-state-sync-key"&&(o=f.Message.AppStateSyncKeyData.fromObject(o)),r[n]=o};a.push(s())}return await Promise.all(a),r},set:async t=>{const i=[];for(const r of Object.keys(t))if(t[r])for(const a of Object.keys(t[r])){const n=t[r][a],s=n?this.set(`${r}-${a}`,n):this.del(`${r}-${a}`);i.push(s)}await Promise.all(i)}};return{creds:this.creds,keys:e}}async save(){if(!this.creds)throw new Error("Credentials not loaded.");await this.set("creds",this.creds)}async remove(){const e=await this.redis.keys(`${this.prefix}*`);e.length&&(await this.redis.del(...e),this.cache.clear())}}export{v as RedisAuth};
|
|
2
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/auth/redis.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash, type UUID } from \"node:crypto\";\nimport { initAuthCreds, proto, SignalDataSet, type AuthenticationCreds, type SignalDataTypeMap, type SignalKeyStore } from \"baileys\";\nimport type { Redis } from \"ioredis\";\nimport { type IBotAuthInit } from \"../../types/index.js\";\nimport { AES256GCM, isBuffer, isString, isUint8Array, isUUID } from \"../../utils/index.js\";\n\nexport class RedisAuth {\n private prefix: string;\n private aes: AES256GCM;\n private cache = new Map<string, Buffer>();\n private creds?: AuthenticationCreds;\n private redis: Redis;\n public uuid: UUID;\n constructor(uuid: UUID, redis: Redis, prefix: string) {\n if (!isUUID(uuid)) {\n throw new Error(`'${uuid}' is not a valid UUID.`);\n }\n this.prefix = `${prefix}:${uuid}:`;\n this.aes = new AES256GCM(uuid);\n this.redis = redis;\n this.uuid = uuid;\n }\n private async get<T>(key: string): Promise<T | null> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const encrypted = this.cache.get(md5) ?? await this.redis.getBuffer(`${this.prefix + md5}`);\n if (!isBuffer(encrypted)) {\n return null;\n }\n this.cache.set(md5, encrypted);\n const decrypted = this.aes.decrypt(encrypted);\n if (!isBuffer(decrypted)) {\n return null;\n }\n const parsed = JSON.parse(decrypted.toString(\"utf8\"), (_, value) => {\n if (value?.type !== \"Buffer\" && !isString(value?.data)) {\n return value;\n }\n return Buffer.from(value.data, \"base64\");\n });\n return parsed;\n }\n private async set(key: string, value: any): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n const stringified = JSON.stringify(value, (_, value) => {\n if (!isBuffer(value) && !isUint8Array(value) && value?.type !== \"Buffer\") {\n return value;\n }\n return {\n type: \"Buffer\",\n data: Buffer.from(value.data ?? value).toString(\"base64\"),\n };\n });\n const encrypted = this.aes.encrypt(Buffer.from(stringified, \"utf8\"));\n if (!isBuffer(encrypted)) {\n return;\n }\n await this.redis.set(`${this.prefix + md5}`, encrypted);\n this.cache.set(md5, encrypted);\n }\n private async del(key: string): Promise<void> {\n const md5 = createHash(\"md5\").update(key).digest(\"hex\");\n await this.redis.del(`${this.prefix + md5}`);\n this.cache.delete(md5);\n }\n public async init(): Promise<IBotAuthInit> {\n this.creds = await this.get<AuthenticationCreds>(\"creds\") ?? initAuthCreds();\n const keys: SignalKeyStore = {\n get: async (type, ids) => {\n const value: Record<string, SignalDataTypeMap[typeof type]> = {};\n const tasks: Promise<void>[] = [];\n for (const id of ids) {\n const task = async () => {\n let data = await this.get<any>(`${type}-${id}`);\n if (data !== null && type === \"app-state-sync-key\") {\n data = proto.Message.AppStateSyncKeyData.fromObject(data);\n }\n value[id] = data;\n };\n tasks.push(task());\n }\n await Promise.all(tasks);\n return value;\n },\n set: async (data) => {\n const tasks: Promise<void>[] = [];\n for (const type of (Object.keys(data) as (keyof SignalDataSet)[])) {\n if (!data[type]) {\n continue;\n }\n for (const id of Object.keys(data[type])) {\n const value = data[type][id];\n const task = value ? this.set(`${type}-${id}`, value) : this.del(`${type}-${id}`);\n tasks.push(task);\n }\n }\n await Promise.all(tasks);\n },\n };\n return {\n creds: this.creds,\n keys,\n };\n }\n public async save(): Promise<void> {\n if (!this.creds) {\n throw new Error(\"Credentials not loaded.\");\n }\n await this.set(\"creds\", this.creds);\n }\n public async remove(): Promise<void> {\n const keys = await this.redis.keys(`${this.prefix}*`);\n if (!keys.length) {\n return;\n }\n await this.redis.del(...keys);\n this.cache.clear();\n }\n}"],
|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IAAIG,CAAE,GAAIN,CAAK,EAAI,KAAK,IAAI,GAAGG,CAAI,IAAIG,CAAE,EAAE,EAChFD,EAAM,KAAKE,CAAI,CACjB,CAEF,MAAM,QAAQ,IAAIF,CAAK,CACzB,CACF,EACA,MAAO,CACL,MAAO,KAAK,MACZ,KAAAH,CACF,CACF,CACA,MAAa,MAAsB,CACjC,GAAI,CAAC,KAAK,MACR,MAAM,IAAI,MAAM,yBAAyB,EAE3C,MAAM,KAAK,IAAI,QAAS,KAAK,KAAK,CACpC,CACA,MAAa,QAAwB,CACnC,MAAMA,EAAO,MAAM,KAAK,MAAM,KAAK,GAAG,KAAK,MAAM,GAAG,EAC/CA,EAAK,SAGV,MAAM,KAAK,MAAM,IAAI,GAAGA,CAAI,EAC5B,KAAK,MAAM,MAAM,EACnB,CACF",
|
|
6
|
+
"names": ["createHash", "initAuthCreds", "proto", "AES256GCM", "isBuffer", "isString", "isUint8Array", "isUUID", "RedisAuth", "uuid", "redis", "prefix", "key", "md5", "encrypted", "decrypted", "_", "value", "stringified", "keys", "type", "ids", "tasks", "id", "task", "data"]
|
|
7
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Logger from "@imjxsx/logger";
|
|
2
2
|
import type { UUID } from "node:crypto";
|
|
3
3
|
import EventEmitter from "node:events";
|
|
4
|
-
import
|
|
4
|
+
import { Boom } from "@hapi/boom";
|
|
5
5
|
import type { BotStatus, BotWASocket, IBotAccount, IBotAuth, IBotEventMap, IBotSendMessageOptions, MiddlewareFn } from "../types/index.js";
|
|
6
|
-
import type
|
|
7
|
-
import { Context } from "
|
|
6
|
+
import { type AnyMessageContent, type GroupMetadata, type JidServer } from "baileys";
|
|
7
|
+
import { Context } from "./context/context.js";
|
|
8
8
|
export declare class Bot extends EventEmitter<IBotEventMap> {
|
|
9
9
|
uuid: UUID;
|
|
10
10
|
ws: BotWASocket | null;
|
|
@@ -13,8 +13,10 @@ export declare class Bot extends EventEmitter<IBotEventMap> {
|
|
|
13
13
|
status: BotStatus;
|
|
14
14
|
logger: Logger;
|
|
15
15
|
ping: number;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/** @private */
|
|
17
|
+
private middlewares;
|
|
18
|
+
/** @private */
|
|
19
|
+
private commands;
|
|
18
20
|
constructor(uuid: UUID, auth: IBotAuth, account: IBotAccount, logger?: Logger);
|
|
19
21
|
use(...middlewares: MiddlewareFn[]): void;
|
|
20
22
|
command(name: string, ...middlewares: MiddlewareFn[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/core/bot.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC3I,OAAO,EAAiC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAO/C,qBAAa,GAAI,SAAQ,YAAY,CAAC,YAAY,CAAC;IAC1C,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,SAAS,CAAW;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,SAAK;IAChB,eAAe;IACf,OAAO,CAAC,WAAW,CAAsB;IACzC,eAAe;IACf,OAAO,CAAC,QAAQ,CAAqC;gBACzC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM;IAWtE,GAAG,CAAC,GAAG,WAAW,EAAE,YAAY,EAAE,GAAG,IAAI;IAGzC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,YAAY,EAAE,GAAG,IAAI;IAMrD,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IA6L1C,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IASxC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,EAAE;IAgBxD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IA+B5B,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAwB/G,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAYzD,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY7D"}
|
package/dist/core/bot.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import M from"@imjxsx/logger";import A from"node:events";import{Boom as u}from"@hapi/boom";import{makeWASocket as k}from"baileys";import{Context as g}from"./context/context.js";import{decode as y,isGroup as w,isLid as m,isPn as l,normalize as v,toError as n}from"../utils/index.js";import b from"node:os";import{contacts as p,groups as c}from"../cache/index.js";import{Autolinker as B}from"autolinker";import{load as P}from"cheerio";class N extends A{uuid;ws=null;auth;account;status="close";logger;ping=0;middlewares=[];commands=new Map;constructor(r,e,s,t){super(),this.uuid=r,this.auth=e,this.account=s,this.logger=t??new M({name:`Bot ${this.uuid}`,colorize:process.env.NODE_ENV!=="production",level:process.env.NODE_ENV!=="production"?"TRACE":"INFO"})}use(...r){this.middlewares.push(...r)}command(r,...e){if(!r)throw new Error("The command name must be at least 1 character long.");this.commands.set(r,e)}async login(r){try{const e=await this.auth.init();this.ws=k({auth:e,browser:[b.platform(),"Firefox",b.release()],logger:this.logger.child({name:`WASocket ${this.uuid} `}),qrTimeout:6e4,markOnlineOnConnect:!0,syncFullHistory:!1,shouldSyncHistoryMessage:()=>!1,generateHighQualityLinkPreview:!0,linkPreviewImageThumbnailWidth:1980,shouldIgnoreJid:s=>!w(s)&&!l(s)&&!m(s),cachedGroupMetadata:async s=>c.get(s),version:[2,3e3,1027934701]}),this.ws.ev.on("creds.update",async()=>{try{await this.auth.save()}catch(s){this.emit("error",n(s))}}),this.ws.ev.on("connection.update",async s=>{try{if(s.qr)if(r==="otp"){if(!l(this.account.pn)){await this.disconnect(new u("The OTP code cannot be generated because a number was not provided.",{statusCode:400}));return}const t=await this.ws?.requestPairingCode(y(this.account.pn).jid);if(!t){await this.disconnect(new u(`An OTP code could not be generated for '@${y(this.account.pn).jid}'`,{statusCode:400}));return}this.emit("otp",t)}else this.emit("qr",s.qr);if(s.connection==="close"){this.ws?.ev.removeAllListeners(void 0);const t=new u(s.lastDisconnect?.error).output;switch(this.emit("close",`${t.payload.error} ${t.payload.statusCode}: ${t.payload.message}`),t.payload.statusCode){case 405:case 404:case 403:case 401:case 400:{await this.auth.remove(),this.ws=null,this.removeAllListeners(),this.status="close";break}case 503:{await new Promise(i=>setTimeout(i,3e4)),this.status="reconnecting",await this.login(r);break}case 515:{this.status="reconnecting",await this.login(r);break}default:await new Promise(i=>setTimeout(i,5e3)),this.status="reconnecting",await this.login(r)}return}else if(s.connection==="open"){const t=v(this.ws?.user?.lid),i=v(this.ws?.user?.id),o=this.ws?.user?.verifiedName??this.ws?.user?.name??"";if(!l(i)||!m(t)){await this.disconnect(new u("Restart required.",{statusCode:515}));return}this.account={jid:t,pn:i,name:o},p.set(t,{jid:t,pn:i,name:o}),this.status="open",this.emit("open",this.account);return}}catch(t){this.emit("error",n(t))}}),this.ws.ev.on("messages.upsert",async s=>{try{if(s.type!=="notify"||!s.messages.length)return;for(const t of s.messages){const i=new g(this,t);if(w(i.chat.jid)&&!c.has(i.chat.jid)){const a=await this.groupMetadata(i.chat.jid);a&&c.set(i.chat.jid,a)}m(i.from.jid)&&l(i.from.pn)&&p.set(i.from.jid,{jid:i.from.jid,pn:i.from.pn,name:i.from.name});const o=[...this.middlewares,...this.commands.get(i.commandName)??[]];if(o.length){let a=-1;const h=async d=>{if(d<=a)throw new Error("next() called multiple times.");a=d;const f=o[d];f&&await f(i,async()=>{await h(d+1)})};await h(0)}}}catch(t){this.emit("error",n(t))}}),this.ws.ev.on("contacts.update",s=>{try{for(const t of s){if(!m(t.id)||!p.has(t.id))continue;const i=t.verifiedName??t.notify,o=p.get(t.id);i&&o.name!==i&&(o.name=i)}}catch(t){this.emit("error",n(t))}}),this.ws.ev.on("groups.update",async s=>{try{for(const t of s){if(!w(t.id))continue;c.delete(t.id);const i=await this.groupMetadata(t.id);i&&c.set(t.id,i)}}catch(t){this.emit("error",n(t))}})}catch(e){this.emit("error",n(e))}}async disconnect(r){try{r??=new u("Intentional disconnection.",{statusCode:204}),this.ws?.end(r)}catch(e){this.emit("error",n(e))}}async logout(r){try{await this.ws?.logout(r?.message)}catch(e){this.emit("error",n(e))}}parseMentions(r,e){try{const s=new Set;for(const t of r.matchAll(/@(\d{7,})/g))t[1]&&s.add(`${t[1]}@${e}`);return Array.from(s.values())}catch(s){return this.emit("error",n(s)),[]}}parseLinks(r){try{const e=new Set,s=B.link(r,{urls:{schemeMatches:!0,ipV4Matches:!1,tldMatches:!0},email:!0,phone:!0,mention:!1,hashtag:!1,stripPrefix:!1,stripTrailingSlash:!1}),t=P(s);return t("a").each((i,o)=>{const a=t(o).attr("href");a&&e.add(a)}),Array.from(e.values())}catch(e){return this.emit("error",n(e)),[]}}async sendMessage(r,e,s){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");const t=performance.now(),i="text"in e&&e.text?e.text:"caption"in e&&e.caption?e.caption:"",o=this.parseMentions(i,s?.addressing==="lid"?"lid":"s.whatsapp.net"),a=await this.ws.sendMessage(r,{...e,mentions:"mentions"in e&&e.mentions?e.mentions.concat(...o):o},s);if(!a)return null;const h=performance.now();return this.ping=h-t,new g(this,a)}catch(t){return this.emit("error",n(t)),null}}async groupMetadata(r){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");return c.get(r)??await this.ws.groupMetadata(r)}catch(e){return this.emit("error",n(e)),null}}async profilePictureUrl(r){try{if(!this.ws?.ws.isOpen)throw new Error("The WASocket connection is not open.");return await this.ws.profilePictureUrl(r,"image")??"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg"}catch(e){return this.emit("error",n(e)),"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg"}}}export{N as Bot};
|
|
2
|
+
//# sourceMappingURL=bot.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/core/bot.ts"],
|
|
4
|
+
"sourcesContent": ["import Logger from \"@imjxsx/logger\";\nimport type { UUID } from \"node:crypto\";\nimport EventEmitter from \"node:events\";\nimport { Boom } from \"@hapi/boom\";\nimport type { BotStatus, BotWASocket, IBotAccount, IBotAuth, IBotEventMap, IBotSendMessageOptions, MiddlewareFn } from \"../types/index.js\";\nimport { BaileysEventMap, makeWASocket, type AnyMessageContent, type GroupMetadata, type JidServer } from \"baileys\";\nimport { Context } from \"./context/context.js\";\nimport { decode, isGroup, isLid, isPn, normalize, toError } from \"../utils/index.js\";\nimport os from \"node:os\";\nimport { contacts, groups } from \"../cache/index.js\";\nimport { Autolinker } from \"autolinker\";\nimport { load } from \"cheerio\";\n\nexport class Bot extends EventEmitter<IBotEventMap> {\n public uuid: UUID;\n public ws: BotWASocket | null = null;\n public auth: IBotAuth;\n public account: IBotAccount;\n public status: BotStatus = \"close\";\n public logger: Logger;\n public ping = 0;\n /** @private */\n private middlewares: MiddlewareFn[] = [];\n /** @private */\n private commands = new Map<string, MiddlewareFn[]>();\n constructor(uuid: UUID, auth: IBotAuth, account: IBotAccount, logger?: Logger) {\n super();\n this.uuid = uuid;\n this.auth = auth;\n this.account = account;\n this.logger = logger ?? new Logger({\n name: `Bot ${this.uuid}`,\n colorize: process.env[\"NODE_ENV\"] !== \"production\",\n level: process.env[\"NODE_ENV\"] !== \"production\" ? \"TRACE\" : \"INFO\",\n });\n }\n public use(...middlewares: MiddlewareFn[]): void {\n this.middlewares.push(...middlewares);\n }\n public command(name: string, ...middlewares: MiddlewareFn[]): void {\n if (!name) {\n throw new Error(\"The command name must be at least 1 character long.\");\n }\n this.commands.set(name, middlewares);\n }\n public async login(method: \"qr\" | \"otp\"): Promise<void> {\n try {\n const auth = await this.auth.init();\n this.ws = makeWASocket({\n auth,\n browser: [os.platform(), \"Firefox\", os.release()],\n logger: this.logger.child({ name: `WASocket ${this.uuid} ` }),\n qrTimeout: 60_000,\n markOnlineOnConnect: true,\n syncFullHistory: false,\n shouldSyncHistoryMessage: () => (false),\n generateHighQualityLinkPreview: true,\n linkPreviewImageThumbnailWidth: 1_980,\n shouldIgnoreJid: (jid) => {\n if (!isGroup(jid) && !isPn(jid) && !isLid(jid)) {\n return true;\n }\n return false;\n },\n cachedGroupMetadata: async (jid) => {\n return groups.get(jid);\n },\n version: [2, 3_000, 1_027_934_701],\n });\n this.ws.ev.on(\"creds.update\", async () => {\n try {\n await this.auth.save();\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"connection.update\", async (update) => {\n try {\n if (update.qr) {\n if (method === \"otp\") {\n if (!isPn(this.account.pn)) {\n await this.disconnect(new Boom(\"The OTP code cannot be generated because a number was not provided.\", { statusCode: 400 }));\n return;\n }\n const otp = await this.ws?.requestPairingCode(decode(this.account.pn).jid);\n if (!otp) {\n await this.disconnect(new Boom(`An OTP code could not be generated for '@${decode(this.account.pn).jid}'`, { statusCode: 400 }));\n return;\n }\n this.emit(\"otp\", otp);\n }\n else {\n this.emit(\"qr\", update.qr);\n }\n }\n if (update.connection === \"close\") {\n this.ws?.ev.removeAllListeners(undefined as unknown as keyof BaileysEventMap);\n const output = new Boom(update.lastDisconnect?.error).output;\n this.emit(\"close\", `${output.payload.error} ${output.payload.statusCode}: ${output.payload.message}`);\n switch (output.payload.statusCode) {\n case 405:\n case 404:\n case 403:\n case 401:\n case 400: {\n await this.auth.remove();\n this.ws = null;\n this.removeAllListeners();\n this.status = \"close\";\n break;\n }\n case 503: {\n await new Promise((resolve) => (setTimeout(resolve, 30_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n case 515: {\n this.status = \"reconnecting\";\n await this.login(method);\n break;\n }\n default: {\n await new Promise((resolve) => (setTimeout(resolve, 5_000)));\n this.status = \"reconnecting\";\n await this.login(method);\n }\n }\n return;\n }\n else if (update.connection === \"open\") {\n const jid = normalize(this.ws?.user?.lid);\n const pn = normalize(this.ws?.user?.id);\n const name = this.ws?.user?.verifiedName ?? this.ws?.user?.name ?? \"\";\n if (!isPn(pn) || !isLid(jid)) {\n await this.disconnect(new Boom(\"Restart required.\", { statusCode: 515 }));\n return;\n }\n this.account = { jid, pn, name };\n contacts.set(jid, { jid, pn, name });\n this.status = \"open\";\n this.emit(\"open\", this.account);\n return;\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"messages.upsert\", async (upsert) => {\n try {\n if (upsert.type !== \"notify\" || !upsert.messages.length) {\n return;\n }\n for (const message of upsert.messages) {\n const ctx = new Context(this, message);\n if (isGroup(ctx.chat.jid)) {\n if (!groups.has(ctx.chat.jid)) {\n const metadata = await this.groupMetadata(ctx.chat.jid);\n if (metadata) {\n groups.set(ctx.chat.jid, metadata);\n }\n }\n }\n if (isLid(ctx.from.jid) && isPn(ctx.from.pn)) {\n contacts.set(ctx.from.jid, { jid: ctx.from.jid, pn: ctx.from.pn, name: ctx.from.name });\n }\n const middlewares = [\n ...this.middlewares,\n ...(this.commands.get(ctx.commandName) ?? []),\n ];\n if (middlewares.length) {\n let index = -1;\n const runner = async (i: number): Promise<void> => {\n if (i <= index) {\n throw new Error(\"next() called multiple times.\");\n }\n index = i;\n const fn = middlewares[i];\n if (!fn) {\n return;\n }\n await fn(ctx, async () => {\n await runner(i + 1);\n });\n };\n await runner(0);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"contacts.update\", (updates) => {\n try {\n for (const update of updates) {\n if (!isLid(update.id) || !contacts.has(update.id)) {\n continue;\n }\n const name = update.verifiedName ?? update.notify;\n const contact = contacts.get(update.id)!;\n if (name && contact.name !== name) {\n contact.name = name;\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n this.ws.ev.on(\"groups.update\", async (updates) => {\n try {\n for (const update of updates) {\n if (!isGroup(update.id)) {\n continue;\n }\n groups.delete(update.id);\n const metadata = await this.groupMetadata(update.id);\n if (metadata) {\n groups.set(update.id, metadata);\n }\n }\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n });\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async disconnect(reason?: Boom): Promise<void> {\n try {\n reason ??= new Boom(\"Intentional disconnection.\", { statusCode: 204 });\n this.ws?.end(reason);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public async logout(reason?: Boom): Promise<void> {\n try {\n await this.ws?.logout(reason?.message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n }\n }\n public parseMentions(text: string, server: JidServer): string[] {\n try {\n const mentions = new Set<string>();\n for (const match of text.matchAll(/@(\\d{7,})/g)) {\n if (!match[1]) {\n continue;\n }\n mentions.add(`${match[1]}@${server}`);\n }\n return Array.from(mentions.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public parseLinks(text: string): string[] {\n try {\n const links = new Set<string>();\n const html = Autolinker.link(text, {\n urls: {\n schemeMatches: true,\n ipV4Matches: false,\n tldMatches: true,\n },\n email: true,\n phone: true,\n mention: false,\n hashtag: false,\n stripPrefix: false,\n stripTrailingSlash: false,\n });\n const $ = load(html);\n $(\"a\").each((_, el) => {\n const link = $(el).attr(\"href\");\n if (!link) {\n return;\n }\n links.add(link);\n });\n return Array.from(links.values());\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return [];\n }\n }\n public async sendMessage(jid: string, content: AnyMessageContent, options?: IBotSendMessageOptions): Promise<Context | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n const before = performance.now();\n const text = \"text\" in content && content.text ? content.text : \"caption\" in content && content.caption ? content.caption : \"\";\n const mentions = this.parseMentions(text, options?.addressing === \"lid\" ? \"lid\" : \"s.whatsapp.net\");\n const message = await this.ws.sendMessage(jid, {\n ...content,\n mentions: \"mentions\" in content && content.mentions ? content.mentions.concat(...mentions) : mentions,\n }, options);\n if (!message) {\n return null;\n }\n const after = performance.now();\n this.ping = after - before;\n return new Context(this, message);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async groupMetadata(jid: string): Promise<GroupMetadata | null> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return groups.get(jid) ?? await this.ws.groupMetadata(jid);\n }\n catch (e) {\n this.emit(\"error\", toError(e));\n return null;\n }\n }\n public async profilePictureUrl(jid: string): Promise<string> {\n try {\n if (!this.ws?.ws.isOpen) {\n throw new Error(\"The WASocket connection is not open.\");\n }\n return await this.ws.profilePictureUrl(jid, \"image\") ?? \"https://i.pinimg.com/736x/62/01/0d/62010d848b790a2336d1542fcda51789.jpg\";\n }\n catch (e) {\n this.emit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C,OACOP,EAAG,CACR,YAAK,KAAK,QAASf,EAAQe,CAAC,CAAC,EACtB,IACT,CACF,CACA,MAAa,cAAcD,EAA4C,CACrE,GAAI,CACF,GAAI,CAAC,KAAK,IAAI,GAAG,OACf,MAAM,IAAI,MAAM,sCAAsC,EAExD,OAAOX,EAAO,IAAIW,CAAG,GAAK,MAAM,KAAK,GAAG,cAAcA,CAAG,CAC3D,OACO,EAAG,CACR,YAAK,KAAK,QAASd,EAAQ,CAAC,CAAC,EACtB,IACT,CACF,CACA,MAAa,kBAAkBc,EAA8B,CAC3D,GAAI,CACF,GAAI,CAAC,KAAK,IAAI,GAAG,OACf,MAAM,IAAI,MAAM,sCAAsC,EAExD,OAAO,MAAM,KAAK,GAAG,kBAAkBA,EAAK,OAAO,GAAK,yEAC1D,OACO,EAAG,CACR,YAAK,KAAK,QAASd,EAAQ,CAAC,CAAC,EACtB,yEACT,CACF,CACF",
|
|
6
|
+
"names": ["Logger", "EventEmitter", "Boom", "makeWASocket", "Context", "decode", "isGroup", "isLid", "isPn", "normalize", "toError", "os", "contacts", "groups", "Autolinker", "load", "Bot", "uuid", "auth", "account", "logger", "middlewares", "name", "method", "jid", "e", "update", "otp", "output", "resolve", "pn", "upsert", "message", "ctx", "metadata", "index", "runner", "i", "fn", "updates", "contact", "reason", "text", "server", "mentions", "match", "links", "html", "$", "_", "el", "link", "content", "options", "before", "after"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type WAMessage } from "baileys";
|
|
2
|
-
import type { IReplyOptions, IReplyWithImageOptions, IReplyWithVideoOptions } from "
|
|
2
|
+
import type { IReplyOptions, IReplyWithAudioOptions, IReplyWithImageOptions, IReplyWithVideoOptions } from "../../types/context.js";
|
|
3
3
|
import { Message } from "./message.js";
|
|
4
|
-
import type { Bot } from "../bot
|
|
4
|
+
import type { Bot } from "../bot.js";
|
|
5
5
|
export declare class Context extends Message {
|
|
6
6
|
bot: Bot;
|
|
7
7
|
prefixUsed: string;
|
|
@@ -11,6 +11,7 @@ export declare class Context extends Message {
|
|
|
11
11
|
reply(text: string, options?: IReplyOptions): Promise<Context>;
|
|
12
12
|
replyWithImage(image: string | Buffer, options?: IReplyWithImageOptions): Promise<Context>;
|
|
13
13
|
replyWithVideo(video: string | Buffer, options?: IReplyWithVideoOptions): Promise<Context>;
|
|
14
|
+
replyWithAudio(video: string | Buffer, options?: IReplyWithAudioOptions): Promise<Context>;
|
|
14
15
|
replyWithSticker(sticker: Buffer, options?: IReplyOptions): Promise<Context>;
|
|
15
16
|
del(): Promise<void>;
|
|
16
17
|
edit(text: string): Promise<Context>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/context/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEpI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,OAAQ,SAAQ,OAAO;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,SAAM;IAChB,WAAW,SAAM;IACjB,IAAI,EAAE,MAAM,EAAE,CAAM;gBACf,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS;IAY3B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1F,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB5E,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBpC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAGzC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{downloadMediaMessage as a}from"baileys";import{isBuffer as o,isLink as r,toString as n}from"../../utils/index.js";import{Message as h}from"./message.js";class m extends h{bot;prefixUsed="";commandName="";args=[];constructor(e,s){if(super(e,s),this.bot=e,this.text){const t=(this.text.match(/^\s*([/!])\s*([a-zA-Z0-9_$>?-]+)(?:\s+(.+))?/i)??[]).filter(Boolean).map(i=>i.trim());t.length&&(this.prefixUsed=t[1]??"",this.commandName=(t[2]??"").toLowerCase(),this.args=(t[3]??"").split(/\s+/).filter(Boolean).map(i=>i.trim()))}}async reply(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");const t=await this.bot.sendMessage(this.chat.jid,{text:n(e),...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!t)throw new Error("The message could not be sent.");return t}async replyWithImage(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(r(e))t={url:e};else throw new Error("Image type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{image:t,mimetype:"image/jpeg",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithVideo(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(r(e))t={url:e};else throw new Error("Video type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{video:t,mimetype:"video/mp4",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithAudio(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");let t;if(o(e))t=e;else if(r(e))t={url:e};else throw new Error("Video type not supported.");const i=await this.bot.sendMessage(this.chat.jid,{audio:t,mimetype:"audio/mpeg",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!i)throw new Error("The message could not be sent.");return i}async replyWithSticker(e,s){if(!this.chat.jid)throw new Error("Unknown chat.");if(!o(e))throw new Error("Image type not supported.");const t=await this.bot.sendMessage(this.chat.jid,{sticker:e,mimetype:"image/webp",...s},{quoted:this.message,addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!t)throw new Error("The message could not be sent.");return t}async del(){if(!this.chat.jid)throw new Error("Unknown chat.");await this.bot.sendMessage(this.chat.jid,{delete:this.message.key})}async edit(e){if(!this.chat.jid)throw new Error("Unknown chat.");if(!this.message.key.fromMe)throw new Error(`The '${this.id}' message cannot be edited because it was not sent by the client.`);const s=await this.bot.sendMessage(this.chat.jid,{edit:this.message.key,text:n(e)},{addressing:this.chat.addressing==="lid"?"lid":"pn"});if(!s)throw new Error("The message could not be sent.");return s}async download(){return await a(this.message,"buffer",{})}}export{m as Context};
|
|
2
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/context/context.ts"],
|
|
4
|
+
"sourcesContent": ["import { downloadMediaMessage, type WAMediaUpload, type WAMessage } from \"baileys\";\nimport type { IReplyOptions, IReplyWithAudioOptions, IReplyWithImageOptions, IReplyWithVideoOptions } from \"../../types/context.js\";\nimport { isBuffer, isLink, toString } from \"../../utils/index.js\";\nimport { Message } from \"./message.js\";\nimport type { Bot } from \"../bot.js\";\n\nexport class Context extends Message {\n public bot: Bot;\n public prefixUsed = \"\";\n public commandName = \"\";\n public args: string[] = [];\n constructor(bot: Bot, message: WAMessage) {\n super(bot, message);\n this.bot = bot;\n if (this.text) {\n const match = (this.text.match(/^\\s*([/!])\\s*([a-zA-Z0-9_$>?-]+)(?:\\s+(.+))?/i) ?? []).filter(Boolean).map((v) => (v.trim()));\n if (match.length) {\n this.prefixUsed = match[1] ?? \"\";\n this.commandName = (match[2] ?? \"\").toLowerCase();\n this.args = (match[3] ?? \"\").split(/\\s+/).filter(Boolean).map((v) => (v.trim()));\n }\n }\n }\n public async reply(text: string, options?: IReplyOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n text: toString(text),\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithImage(image: string | Buffer, options?: IReplyWithImageOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(image)) {\n media = image;\n }\n else if (isLink(image)) {\n media = {\n url: image,\n };\n }\n else {\n throw new Error(\"Image type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n image: media,\n mimetype: \"image/jpeg\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithVideo(video: string | Buffer, options?: IReplyWithVideoOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(video)) {\n media = video;\n }\n else if (isLink(video)) {\n media = {\n url: video,\n };\n }\n else {\n throw new Error(\"Video type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n video: media,\n mimetype: \"video/mp4\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithAudio(video: string | Buffer, options?: IReplyWithAudioOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n let media: WAMediaUpload;\n if (isBuffer(video)) {\n media = video;\n }\n else if (isLink(video)) {\n media = {\n url: video,\n };\n }\n else {\n throw new Error(\"Video type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n audio: media,\n mimetype: \"audio/mpeg\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async replyWithSticker(sticker: Buffer, options?: IReplyOptions): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n if (!isBuffer(sticker)) {\n throw new Error(\"Image type not supported.\");\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n sticker,\n mimetype: \"image/webp\",\n ...options,\n }, {\n quoted: this.message,\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async del(): Promise<void> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n await this.bot.sendMessage(this.chat.jid, {\n delete: this.message.key,\n });\n }\n public async edit(text: string): Promise<Context> {\n if (!this.chat.jid) {\n throw new Error(\"Unknown chat.\");\n }\n if (!this.message.key.fromMe) {\n throw new Error(`The '${this.id}' message cannot be edited because it was not sent by the client.`);\n }\n const context = await this.bot.sendMessage(this.chat.jid, {\n edit: this.message.key,\n text: toString(text),\n }, {\n addressing: this.chat.addressing === \"lid\" ? \"lid\" : \"pn\",\n });\n if (!context) {\n throw new Error(\"The message could not be sent.\");\n }\n return context;\n }\n public async download(): Promise<Buffer> {\n return await downloadMediaMessage(this.message, \"buffer\", {});\n }\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,wBAAAA,MAAgE,UAEzE,OAAS,YAAAC,EAAU,UAAAC,EAAQ,YAAAC,MAAgB,uBAC3C,OAAS,WAAAC,MAAe,eAGjB,MAAMC,UAAgBD,CAAQ,CAC5B,IACA,WAAa,GACb,YAAc,GACd,KAAiB,CAAC,EACzB,YAAYE,EAAUC,EAAoB,CAGxC,GAFA,MAAMD,EAAKC,CAAO,EAClB,KAAK,IAAMD,EACP,KAAK,KAAM,CACb,MAAME,GAAS,KAAK,KAAK,MAAM,+CAA+C,GAAK,CAAC,GAAG,OAAO,OAAO,EAAE,IAAKC,GAAOA,EAAE,KAAK,CAAE,EACxHD,EAAM,SACR,KAAK,WAAaA,EAAM,CAAC,GAAK,GAC9B,KAAK,aAAeA,EAAM,CAAC,GAAK,IAAI,YAAY,EAChD,KAAK,MAAQA,EAAM,CAAC,GAAK,IAAI,MAAM,KAAK,EAAE,OAAO,OAAO,EAAE,IAAKC,GAAOA,EAAE,KAAK,CAAE,EAEnF,CACF,CACA,MAAa,MAAMC,EAAcC,EAA2C,CAC1E,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,MAAMC,EAAU,MAAM,KAAK,IAAI,YAAY,KAAK,KAAK,IAAK,CACxD,KAAMT,EAASO,CAAI,EACnB,GAAGC,CACL,EAAG,CACD,OAAQ,KAAK,QACb,WAAY,KAAK,KAAK,aAAe,MAAQ,MAAQ,IACvD,CAAC,EACD,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,gCAAgC,EAElD,OAAOA,CACT,CACA,MAAa,eAAeC,EAAwBF,EAAoD,CACtG,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,IAAIG,EACJ,GAAIb,EAASY,CAAK,EAChBC,EAAQD,UAEDX,EAAOW,CAAK,E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AM,IAAI,MAAM,gCAAgC,EAElD,OAAOA,CACT,CACA,MAAa,iBAAiBI,EAAiBL,EAA2C,CACxF,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,GAAI,CAACV,EAASe,CAAO,EACnB,MAAM,IAAI,MAAM,2BAA2B,EAE7C,MAAMJ,EAAU,MAAM,KAAK,IAAI,YAAY,KAAK,KAAK,IAAK,CACxD,QAAAI,EACA,SAAU,aACV,GAAGL,CACL,EAAG,CACD,OAAQ,KAAK,QACb,WAAY,KAAK,KAAK,aAAe,MAAQ,MAAQ,IACvD,CAAC,EACD,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,gCAAgC,EAElD,OAAOA,CACT,CACA,MAAa,KAAqB,CAChC,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,MAAM,KAAK,IAAI,YAAY,KAAK,KAAK,IAAK,CACxC,OAAQ,KAAK,QAAQ,GACvB,CAAC,CACH,CACA,MAAa,KAAKF,EAAgC,CAChD,GAAI,CAAC,KAAK,KAAK,IACb,MAAM,IAAI,MAAM,eAAe,EAEjC,GAAI,CAAC,KAAK,QAAQ,IAAI,OACpB,MAAM,IAAI,MAAM,QAAQ,KAAK,EAAE,mEAAmE,EAEpG,MAAME,EAAU,MAAM,KAAK,IAAI,YAAY,KAAK,KAAK,IAAK,CACxD,KAAM,KAAK,QAAQ,IACnB,KAAMT,EAASO,CAAI,CACrB,EAAG,CACD,WAAY,KAAK,KAAK,aAAe,MAAQ,MAAQ,IACvD,CAAC,EACD,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,gCAAgC,EAElD,OAAOA,CACT,CACA,MAAa,UAA4B,CACvC,OAAO,MAAMZ,EAAqB,KAAK,QAAS,SAAU,CAAC,CAAC,CAC9D,CACF",
|
|
6
|
+
"names": ["downloadMediaMessage", "isBuffer", "isLink", "toString", "Message", "Context", "bot", "message", "match", "v", "text", "options", "context", "image", "media", "video", "sticker"]
|
|
7
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type WAMessage } from "baileys";
|
|
2
|
-
import type { IChat, IFrom
|
|
3
|
-
import type { Bot } from "../bot
|
|
1
|
+
import { proto, type WAMessage } from "baileys";
|
|
2
|
+
import type { IChat, IFrom } from "../../types/index.js";
|
|
3
|
+
import type { Bot } from "../bot.js";
|
|
4
4
|
export declare class Message {
|
|
5
5
|
message: WAMessage;
|
|
6
6
|
chat: IChat;
|
|
7
7
|
from: IFrom;
|
|
8
|
-
type:
|
|
8
|
+
type: keyof proto.IMessage;
|
|
9
9
|
id: string;
|
|
10
10
|
timestamp: number;
|
|
11
11
|
hash: string;
|
|
12
12
|
mimetype: string;
|
|
13
|
-
size: number;
|
|
14
13
|
text: string;
|
|
14
|
+
size: number;
|
|
15
15
|
mentions: string[];
|
|
16
16
|
links: string[];
|
|
17
17
|
quoted?: Message;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/core/context/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAIrC,qBAAa,OAAO;IACX,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,KAAK,CAKhB;IACK,IAAI,EAAE,KAAK,CAIhB;IACK,IAAI,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAkB;IAC5C,EAAE,SAAM;IACR,SAAS,SAAK;IACd,IAAI,SAAM;IACV,QAAQ,SAAM;IACd,IAAI,SAAM;IACV,IAAI,SAAK;IACT,QAAQ,EAAE,MAAM,EAAE,CAAM;IACxB,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;gBACZ,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS;IAoBxC,OAAO,CAAC,SAAS;IAwDjB,OAAO,CAAC,KAAK;CAsDd"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import m from"long";import{isGroup as d,isLid as o,isLink as g,isPn as p,isString as r}from"../../utils/index.js";import{contacts as f,groups as u}from"../../cache/index.js";class h{message;chat={jid:"",type:"unknown",addressing:"unknown",name:""};from={jid:"",pn:"",name:""};type="conversation";id="";timestamp=0;hash="";mimetype="";text="";size=0;mentions=[];links=[];quoted;constructor(a,s){this.message=s,this.id=this.message.key.id??"",this.timestamp=this.message.messageTimestamp?m.fromValue(this.message.messageTimestamp).toNumber():0,this.serialize(a),this.parse(a,this.message.message??{}),this.text&&(this.mentions.push(...a.parseMentions(this.text,this.chat.addressing==="lid"?"lid":"s.whatsapp.net")),this.links.push(...a.parseLinks(this.text))),this.quoted?(this.quoted.chat.type==="unknown"&&(this.quoted.chat=this.chat),delete this.quoted.quoted):delete this.quoted}serialize(a){if(this.message.key.remoteJid)if(d(this.message.key.remoteJid)){const s=this.message.key.remoteJid;this.chat={jid:s,type:"group",addressing:this.message.key.addressingMode==="lid"?"lid":"pn",name:u.get(s)?.subject??""}}else{const s=[this.message.key.remoteJid,this.message.key.remoteJidAlt],i=s.find(t=>o(t)),n=s.find(t=>p(t));(i||n)&&(this.chat={jid:i??"",pn:n,type:"private",addressing:"pn",name:Array.from(f.values()).find(t=>i&&i===t.jid||n&&n===t.pn)?.name??""})}if(this.message.key.participant){const s=[this.message.key.participant,this.message.key.participantAlt],i=this.message.key.fromMe?a.account.jid:s.find(t=>o(t)),n=this.message.key.fromMe?a.account.pn:s.find(t=>p(t));(i||n)&&(this.from={jid:i??"",pn:n??"",name:this.message.verifiedBizName??this.message.pushName??""})}else if(this.chat.type==="private"){const s=this.message.key.fromMe?a.account.jid:this.chat.jid,i=this.message.key.fromMe?a.account.pn:this.chat.pn;o(s)&&(this.from={jid:s,pn:i??"",name:this.message.verifiedBizName??this.message.pushName??""})}}parse(a,s){const i=Object.keys(s).find(e=>e!=="senderKeyDistributionMessage"&&e!=="messageContextInfo");if(!i||!s[i])return;switch(this.type=i,i){case"conversation":case"extendedTextMessage":{const e=s[i];this.text=(r(e)?e:e.text??"").trim(),this.size=this.text.length;break}case"viewOnceMessage":case"viewOnceMessageV2":case"viewOnceMessageV2Extension":case"documentWithCaptionMessage":{const e=s[i];this.parse(a,e.message??{});break}default:{const e=s[i];this.type=i,this.hash="fileSha256"in e&&e.fileSha256?Buffer.from(e.fileSha256).toString("hex"):"",this.mimetype="mimetype"in e&&e.mimetype?e.mimetype:"",this.text="text"in e&&e.text?e.text:"caption"in e&&e.caption?e.caption:"",this.size="fileLength"in e&&e.fileLength?m.fromValue(e.fileLength).toNumber():this.text.length;break}}const n=s[i],t=!r(n)&&"contextInfo"in n?n.contextInfo:{};if(this.mentions=t?.mentionedJid??[],t?.quotedMessage){const e={key:{remoteJid:t.remoteJid,fromMe:[a.account.jid,a.account.pn].some(c=>c===t.participant),id:t.stanzaId,participant:t.participant,addressingMode:o(t.participant)?"lid":"pn"},message:t.quotedMessage};this.quoted=new h(a,e)}t?.externalAdReply&&g(t.externalAdReply.sourceUrl)&&this.links.push(t.externalAdReply.sourceUrl)}}export{h as Message};
|
|
2
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/core/context/message.ts"],
|
|
4
|
+
"sourcesContent": ["import { proto, type WAMessage } from \"baileys\";\nimport type { IChat, IFrom } from \"../../types/index.js\";\nimport Long from \"long\";\nimport type { Bot } from \"../bot.js\";\nimport { isGroup, isLid, isLink, isPn, isString } from \"../../utils/index.js\";\nimport { contacts, groups } from \"../../cache/index.js\";\n\nexport class Message {\n public message: WAMessage;\n public chat: IChat = {\n jid: \"\",\n type: \"unknown\",\n addressing: \"unknown\",\n name: \"\",\n };\n public from: IFrom = {\n jid: \"\",\n pn: \"\",\n name: \"\",\n };\n public type: keyof proto.IMessage = \"conversation\";\n public id = \"\";\n public timestamp = 0;\n public hash = \"\";\n public mimetype = \"\";\n public text = \"\";\n public size = 0;\n public mentions: string[] = [];\n public links: string[] = [];\n public quoted?: Message;\n constructor(bot: Bot, message: WAMessage) {\n this.message = message;\n this.id = this.message.key.id ?? \"\";\n this.timestamp = this.message.messageTimestamp ? Long.fromValue(this.message.messageTimestamp).toNumber() : 0;\n this.serialize(bot);\n this.parse(bot, this.message.message ?? {});\n if (this.text) {\n this.mentions.push(...bot.parseMentions(this.text, this.chat.addressing === \"lid\" ? \"lid\" : \"s.whatsapp.net\"));\n this.links.push(...bot.parseLinks(this.text));\n }\n if (this.quoted) {\n if (this.quoted.chat.type === \"unknown\") {\n this.quoted.chat = this.chat;\n }\n delete this.quoted.quoted;\n }\n else {\n delete this.quoted;\n }\n }\n private serialize(bot: Bot): void {\n if (this.message.key.remoteJid) {\n if (isGroup(this.message.key.remoteJid)) {\n const jid = this.message.key.remoteJid;\n this.chat = {\n jid,\n type: \"group\",\n addressing: this.message.key.addressingMode === \"lid\" ? \"lid\" : \"pn\",\n name: groups.get(jid)?.subject ?? \"\",\n }\n }\n else {\n const jids = [\n this.message.key.remoteJid,\n this.message.key.remoteJidAlt,\n ];\n const jid = jids.find((v) => (isLid(v)));\n const pn = jids.find((v) => (isPn(v)));\n if (jid || pn) {\n this.chat = {\n jid: jid ?? \"\",\n pn,\n type: \"private\",\n addressing: \"pn\",\n name: Array.from(contacts.values()).find((v) => ((jid && jid === v.jid) || (pn && pn === v.pn)))?.name ?? \"\",\n };\n }\n }\n }\n if (this.message.key.participant) {\n const jids = [\n this.message.key.participant,\n this.message.key.participantAlt,\n ];\n const jid = this.message.key.fromMe ? bot.account.jid : jids.find((v) => (isLid(v)));\n const pn = this.message.key.fromMe ? bot.account.pn : jids.find((v) => (isPn(v)));\n if (jid || pn) {\n this.from = {\n jid: jid ?? \"\",\n pn: pn ?? \"\",\n name: this.message.verifiedBizName ?? this.message.pushName ?? \"\",\n };\n }\n }\n else if (this.chat.type === \"private\") {\n const jid = this.message.key.fromMe ? bot.account.jid : this.chat.jid;\n const pn = this.message.key.fromMe ? bot.account.pn : this.chat.pn;\n if (isLid(jid)) {\n this.from = {\n jid,\n pn: pn ?? \"\",\n name: this.message.verifiedBizName ?? this.message.pushName ?? \"\",\n };\n }\n }\n }\n private parse(bot: Bot, message: proto.IMessage): void {\n const type = (Object.keys(message) as (keyof proto.IMessage)[]).find((v) => (v !== \"senderKeyDistributionMessage\" && v !== \"messageContextInfo\"));\n if (!type || !message[type]) {\n return;\n }\n this.type = type;\n switch (type) {\n case \"conversation\":\n case \"extendedTextMessage\": {\n const m = message[type];\n this.text = (isString(m) ? m : m.text ?? \"\").trim();\n this.size = this.text.length;\n break;\n }\n case \"viewOnceMessage\":\n case \"viewOnceMessageV2\":\n case \"viewOnceMessageV2Extension\":\n case \"documentWithCaptionMessage\": {\n const m = message[type];\n this.parse(bot, m.message ?? {});\n break;\n }\n default: {\n const m = message[type];\n this.type = type;\n this.hash = \"fileSha256\" in m && m.fileSha256 ? Buffer.from(m.fileSha256).toString(\"hex\") : \"\";\n this.mimetype = \"mimetype\" in m && m.mimetype ? m.mimetype : \"\";\n this.text = \"text\" in m && m.text ? m.text : \"caption\" in m && m.caption ? m.caption : \"\";\n this.size = \"fileLength\" in m && m.fileLength ? Long.fromValue(m.fileLength).toNumber() : this.text.length;\n break;\n }\n }\n const m = message[type];\n const context = !isString(m) && \"contextInfo\" in m ? m.contextInfo : {};\n this.mentions = context?.mentionedJid ?? [];\n if (context?.quotedMessage) {\n const message: WAMessage = {\n key: {\n remoteJid: context.remoteJid,\n fromMe: [bot.account.jid, bot.account.pn].some((v) => (v === context.participant)),\n id: context.stanzaId,\n participant: context.participant,\n addressingMode: isLid(context.participant) ? \"lid\" : \"pn\",\n },\n message: context.quotedMessage,\n };\n this.quoted = new Message(bot, message);\n }\n if (context?.externalAdReply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ACzB,IAAK,CACH,UAAWO,EAAQ,UACnB,OAAQ,CAACR,EAAI,QAAQ,IAAKA,EAAI,QAAQ,EAAE,EAAE,KAAMI,GAAOA,IAAMI,EAAQ,WAAY,EACjF,GAAIA,EAAQ,SACZ,YAAaA,EAAQ,YACrB,eAAgBf,EAAMe,EAAQ,WAAW,EAAI,MAAQ,IACvD,EACA,QAASA,EAAQ,aACnB,EACA,KAAK,OAAS,IAAIT,EAAQC,EAAKC,CAAO,CACxC,CACIO,GAAS,iBACPd,EAAOc,EAAQ,gBAAgB,SAAS,GAC1C,KAAK,MAAM,KAAKA,EAAQ,gBAAgB,SAAS,CAGvD,CACF",
|
|
6
|
+
"names": ["Long", "isGroup", "isLid", "isLink", "isPn", "isString", "contacts", "groups", "Message", "bot", "message", "jid", "jids", "v", "pn", "type", "m", "context"]
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./auth/index.js";
|
|
2
|
-
export * from "./bot/index.js";
|
|
3
1
|
export * from "./cache/index.js";
|
|
4
|
-
export * from "./
|
|
2
|
+
export * from "./core/auth/index.js";
|
|
3
|
+
export * from "./core/bot.js";
|
|
5
4
|
export * from "./types/index.js";
|
|
6
|
-
export * from "./utils/
|
|
5
|
+
export * from "./utils/jid.js";
|
|
6
|
+
export * from "./utils/message-builder.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export * from "./cache/index.js";
|
|
4
|
-
export * from "./context/index.js";
|
|
5
|
-
export * from "./types/index.js";
|
|
6
|
-
export * from "./utils/index.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./cache/index.js";export*from"./core/auth/index.js";export*from"./core/bot.js";export*from"./types/index.js";export*from"./utils/jid.js";export*from"./utils/message-builder.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./cache/index.js\";\nexport * from \"./core/auth/index.js\";\nexport * from \"./core/bot.js\";\nexport * from \"./types/index.js\";\nexport * from \"./utils/jid.js\";\nexport * from \"./utils/message-builder.js\";"],
|
|
5
|
+
"mappings": "AAAA,WAAc,mBACd,WAAc,uBACd,WAAc,gBACd,WAAc,mBACd,WAAc,iBACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types/bot.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiscMessageGenerationOptions, AuthenticationCreds, SignalKeyStore, makeWASocket } from "baileys";
|
|
2
|
-
import type { Context } from "../context/context.js";
|
|
2
|
+
import type { Context } from "../core/context/context.js";
|
|
3
3
|
export interface IBotEventMap {
|
|
4
4
|
error: [error: Error];
|
|
5
5
|
close: [reason: string];
|
package/dist/types/bot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/types/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/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,CAAC,IAAI,CAAC,CAAC;AACzE,MAAM,WAAW,sBAAuB,SAAQ,4BAA4B;IAC1E,UAAU,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;CAC3B"}
|
package/dist/types/bot.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=bot.js.map
|
|
1
|
+
//# sourceMappingURL=bot.js.map
|
package/dist/types/bot.js.map
CHANGED
package/dist/types/context.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { proto } from "baileys";
|
|
1
2
|
export interface IReplyOptions {
|
|
2
3
|
mentions?: string[];
|
|
4
|
+
contextInfo?: proto.IContextInfo;
|
|
3
5
|
}
|
|
4
6
|
export interface IReplyWithImageOptions extends IReplyOptions {
|
|
5
7
|
caption?: string;
|
|
@@ -12,4 +14,21 @@ export interface IReplyWithVideoOptions extends IReplyOptions {
|
|
|
12
14
|
viewOnce?: boolean;
|
|
13
15
|
gifPlayback?: boolean;
|
|
14
16
|
}
|
|
17
|
+
export interface IReplyWithAudioOptions extends IReplyOptions {
|
|
18
|
+
mimetype?: string;
|
|
19
|
+
viewOnce?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type ChatType = "private" | "group" | "unknown";
|
|
22
|
+
export interface IChat {
|
|
23
|
+
jid: string;
|
|
24
|
+
pn?: string;
|
|
25
|
+
type: ChatType;
|
|
26
|
+
addressing: "pn" | "lid" | "unknown";
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IFrom {
|
|
30
|
+
jid: string;
|
|
31
|
+
pn: string;
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
15
34
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CAClC;AACD,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/types/context.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=context.js.map
|
|
1
|
+
//# sourceMappingURL=context.js.map
|