From 6e6db166b4ea7580d3ab1f1af55dcc257a42b10f Mon Sep 17 00:00:00 2001 From: "sati.ac" Date: Mon, 31 Jul 2023 13:31:07 +0300 Subject: [PATCH] chore(Sati): add option for short logging --- package.json | 2 +- src/Sati.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5c4be93..6980b38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sati", - "version": "0.2.3", + "version": "0.2.4", "description": "next generation anti-captcha", "license": "MIT", "repository": { diff --git a/src/Sati.ts b/src/Sati.ts index e4b9301..0507bfb 100644 --- a/src/Sati.ts +++ b/src/Sati.ts @@ -22,6 +22,7 @@ import { events, methods, tasks, Task } from './types' */ export class Sati extends EventEmitter { private socket: SatiSocket + private shortLogging: boolean private awaitedTasks: { [ index: number ]: { resolve(data: any): void, @@ -30,8 +31,9 @@ export class Sati extends EventEmitter { } = Object.create(null) /** @param token your api token. get it at https://sati.ac/dashboard */ - constructor({ token }: { token: string }) { + constructor({ token, shortLogging = false }: { token: string, shortLogging?: boolean }) { super() + this.shortLogging = shortLogging this.socket = new SatiSocket(token) this.socket.on('event', ({ type, data }) => { this.emit(type as keyof events, data) @@ -63,7 +65,11 @@ export class Sati extends EventEmitter { const awaited = this.awaitedTasks[task.id] if(task.state === 'error') { - awaited.reject(new SatiError(`unable to solve ${task.type} task #${task.id}`)) + let message = `unable to solve ${task.type} task` + if(!this.shortLogging) { + message += ` #${task.id}` + } + awaited.reject(new SatiError(message)) } else if(task.state === 'success') { awaited.resolve(task) }