Comparing version 1.0.1 to 1.0.2
@@ -79,2 +79,4 @@ import EventEmitter from "events"; | ||
const messageObject = new Message(msg); | ||
if (messageObject.isSelf && !this.options.selfListen) | ||
continue; | ||
this.onMessageCallback(messageObject); | ||
@@ -89,2 +91,4 @@ this.emit("message", messageObject); | ||
const messageObject = new GroupMessage(msg); | ||
if (messageObject.isSelf && !this.options.selfListen) | ||
continue; | ||
this.onMessageCallback(messageObject); | ||
@@ -91,0 +95,0 @@ this.emit("message", messageObject); |
@@ -39,3 +39,2 @@ import { ListenerBase, ListenerOptions } from "./apis/listen.js"; | ||
language?: string; | ||
options?: ListenerOptions; | ||
}; | ||
@@ -47,3 +46,3 @@ export declare class Zalo { | ||
private listenerOptions?; | ||
constructor(credentials: Credentials); | ||
constructor(credentials: Credentials, options?: ListenerOptions); | ||
private parseCookies; | ||
@@ -50,0 +49,0 @@ private validateParams; |
@@ -23,3 +23,3 @@ import cryptojs from "crypto-js"; | ||
export class Zalo { | ||
constructor(credentials) { | ||
constructor(credentials, options) { | ||
this.enableEncryptParam = true; | ||
@@ -32,3 +32,3 @@ this.validateParams(credentials); | ||
appContext.secretKey = null; | ||
this.listenerOptions = credentials.options; | ||
this.listenerOptions = options; | ||
} | ||
@@ -35,0 +35,0 @@ parseCookies(cookie) { |
{ | ||
"name": "zca-js", | ||
"version": "1.0.1", | ||
"description": "", | ||
"version": "1.0.2", | ||
"description": "Unofficial Zalo API for JavaScript", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "type": "module", |
@@ -20,7 +20,12 @@ # ZCA-JS | ||
const zalo = new Zalo({ | ||
cookies: "your_cookies_here", | ||
imei: "your_imei_here", | ||
userAgent: "your_user_agent_here", | ||
}); | ||
const zalo = new Zalo( | ||
{ | ||
cookies: "your_cookies_here", | ||
imei: "your_imei_here", | ||
userAgent: "your_user_agent_here", | ||
}, | ||
{ | ||
selfListen: true, | ||
}, | ||
); | ||
@@ -36,7 +41,12 @@ const api = await zalo.login(); | ||
const zalo = new Zalo({ | ||
j2cookie: JSON.parse(fs.readFileSync("./cookies.json", "utf-8")), | ||
imei: "your_imei_here", | ||
userAgent: "your_user_agent_here", | ||
}); | ||
const zalo = new Zalo( | ||
{ | ||
j2cookie: JSON.parse(fs.readFileSync("./cookies.json", "utf-8")), | ||
imei: "your_imei_here", | ||
userAgent: "your_user_agent_here", | ||
}, | ||
{ | ||
selfListen: true, | ||
}, | ||
); | ||
@@ -49,2 +59,3 @@ const api = await zalo.login(); | ||
- `userAgent`: Your browser user agent. Must be from the same browser you get cookies. | ||
- `selfListen`: Listen for messages sent by yourself. Default is `false`. | ||
@@ -51,0 +62,0 @@ ### Listen for new messages |
@@ -26,3 +26,3 @@ { | ||
"module": "NodeNext" /* Specify what module code is generated. */, | ||
"rootDir": "./src", /* Specify the root folder within your source files. */ | ||
"rootDir": "./src" /* Specify the root folder within your source files. */, | ||
"moduleResolution": "NodeNext" /* Specify how TypeScript looks up a file from a given module specifier. */, | ||
@@ -48,3 +48,3 @@ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ | ||
/* Emit */ | ||
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ | ||
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, | ||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */ | ||
@@ -55,3 +55,3 @@ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ | ||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ | ||
"outDir": "./dist", /* Specify an output folder for all emitted files. */ | ||
"outDir": "./dist" /* Specify an output folder for all emitted files. */, | ||
// "removeComments": true, /* Disable emitting comments. */ | ||
@@ -106,7 +106,3 @@ // "noEmit": true, /* Disable emitting files from a compilation. */ | ||
}, | ||
"exclude": [ | ||
"examples", | ||
"test", | ||
"dist" | ||
] | ||
"exclude": ["examples", "test", "dist"] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111475
165
2469