fix(all): Unified sleep functions in util.ts.

This commit is contained in:
Rodrigo Rodriguez 2024-01-10 15:01:02 -03:00
parent f83c3577bc
commit 99da0001d7
87 changed files with 154 additions and 162 deletions

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -53,6 +53,7 @@ import MicrosoftGraph from '@microsoft/microsoft-graph-client';
import { Spinner } from 'cli-spinner';
import * as publicIp from 'public-ip';
import { AccessToken, TokenCredential } from '@azure/core-auth';
import { GBUtil } from '../../../src/util.js';
const WebSiteResponseTimeout = 900;
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
@ -453,11 +454,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
// const nlpa = await this.createNLPAuthoring(name, `${name}-nlpa`, instance.cloudLocation);
// instance.nlpEndpoint = nlp.properties.endpoint;
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
GBLog.info(`Deploying Bot...`);
instance.botEndpoint = 'TODO: remove this column.';
@ -479,7 +475,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
);
GBLog.info(`Waiting one minute to finish NLP service and keys creation...`);
await sleep(60000);
await GBUtil.sleep(60000);
// keys = await this.cognitiveClient.accounts.listKeys(name, textAnalytics.name);
// instance.textAnalyticsKey = keys.key1;
keys = await this.cognitiveClient.accounts.listKeys(name, spellChecker.name);
@ -585,13 +581,8 @@ export class AzureDeployerService implements IGBInstallationDeployer {
return;
}
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await sleep(30000);
await GBUtil.sleep(30000);
// MSFT has changed without warnings.

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |
@ -60,6 +60,7 @@ import { ActivityTypes } from 'botbuilder';
const { List, Buttons } = pkg;
import mime from 'mime-types';
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
import { GBUtil } from '../../../src/util.js';
/**
* Default check interval for user replay
@ -861,16 +862,11 @@ export class DialogKeywords {
// Wait for the user to answer.
let sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
min.cbMap[userId] = {};
min.cbMap[userId]['promise'] = '!GBHEAR';
while (min.cbMap[userId].promise === '!GBHEAR') {
await sleep(DEFAULT_HEAR_POLL_INTERVAL);
await GBUtil.sleep(DEFAULT_HEAR_POLL_INTERVAL);
}
const answer = min.cbMap[userId].promise;

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \__/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -6,7 +6,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -71,6 +71,7 @@ import {
} from '@azure/storage-blob';
import { md5 } from 'js-md5';
import { GBUtil } from '../../../src/util.js';
/**
* @fileoverview General Bots server core.
@ -1729,25 +1730,20 @@ export class SystemKeywords {
result = await fetch(url, options);
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
if (result.status === 401) {
GBLog.info(`Waiting 5 secs. before retrynig HTTP 401 GET: ${url}`);
await sleep(5 * 1000);
await GBUtil.sleep(5 * 1000);
throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`);
}
if (result.status === 429) {
GBLog.info(`Waiting 1min. before retrying HTTP 429 GET: ${url}`);
await sleep(60 * 1000);
await GBUtil.sleep(60 * 1000);
throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`);
}
if (result.status === 503) {
GBLog.info(`Waiting 1h before retrynig GET 503: ${url}`);
await sleep(60 * 60 * 1000);
await GBUtil.sleep(60 * 60 * 1000);
throw new Error(`BASIC: HTTP:${result.status} retry: ${result.statusText}.`);
}

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -61,6 +61,7 @@ import TextToSpeechV1 from 'ibm-watson/text-to-speech/v1.js';
import { IamAuthenticator } from 'ibm-watson/auth/index.js';
import * as marked from 'marked';
import Translate from '@google-cloud/translate';
import { GBUtil } from '../../../src/util.js';
/**
* Provides basic services for handling messages and dispatching to back-end
@ -613,11 +614,6 @@ export class GBConversationalService {
// tslint:enable:no-unsafe-any
public async sendMarkdownToMobile(min: GBMinInstance, step: GBDialogStep, mobile: string, text: string) {
let sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
enum State {
InText,
InImage,
@ -681,7 +677,7 @@ export class GBConversationalService {
} else {
await this.sendToMobile(min, mobile, currentText, conversationId);
}
await sleep(3000);
await GBUtil.sleep(3000);
currentText = '';
state = State.InText;
} else if (c === '!') {
@ -701,7 +697,7 @@ export class GBConversationalService {
} else {
await this.sendToMobile(min, mobile, currentText, conversationId);
}
await sleep(3000);
await GBUtil.sleep(3000);
}
currentText = '';
state = State.InEmbedAddressBegin;
@ -715,7 +711,7 @@ export class GBConversationalService {
? currentEmbedUrl
: urlJoin(GBServer.globals.publicAddress, currentEmbedUrl);
await this.sendFile(min, step, mobile, url, null);
await sleep(5000);
await GBUtil.sleep(5000);
currentEmbedUrl = '';
} else {
currentEmbedUrl = currentEmbedUrl.concat(c);
@ -734,7 +730,7 @@ export class GBConversationalService {
} else {
await this.sendToMobile(min, mobile, currentText, conversationId);
}
await sleep(2900);
await GBUtil.sleep(2900);
}
currentText = '';
state = State.InImageCaption;
@ -763,7 +759,7 @@ export class GBConversationalService {
: urlJoin(GBServer.globals.publicAddress, currentImage);
await this.sendFile(min, step, mobile, url, currentCaption);
currentCaption = '';
await sleep(4500);
await GBUtil.sleep(4500);
currentImage = '';
} else {
currentImage = currentImage.concat(c);
@ -1206,12 +1202,6 @@ export class GBConversationalService {
public async broadcast(min: GBMinInstance, message: string) {
GBLog.info(`Sending broadcast notifications...`);
let sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
const service = new SecService();
const users = await service.getAllUsers(min.instance.instanceId);
await CollectionUtil.asyncForEach(users, async user => {

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -38,8 +38,6 @@ import Path from 'path';
import express from 'express';
import child_process from 'child_process';
import rimraf from 'rimraf';
import vhost from 'vhost';
import urlJoin from 'url-join';
import Fs from 'fs';
import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBDeployer, IGBInstance, IGBPackage } from 'botlib';
@ -57,6 +55,7 @@ import { TeamsService } from '../../teams.gblib/services/TeamsService.js';
import MicrosoftGraph from '@microsoft/microsoft-graph-client';
import { GBLogEx } from './GBLogEx.js';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { GBUtil } from '../../../src/util.js';
/**
* Deployer service for bots, themes, ai and more.
@ -330,12 +329,7 @@ export class GBDeployer implements IGBDeployer {
if (res.status !== 200 && res.status !== 202) {
throw res.bodyAsText;
}
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
sleep(5000);
GBUtil.sleep(5000);
}
/**

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -92,6 +92,7 @@ import { createKoaHttpServer } from '../../basic.gblib/index.js';
import { DebuggerService } from '../../basic.gblib/services/DebuggerService.js';
import { ImageProcessingServices } from '../../basic.gblib/services/ImageProcessingServices.js';
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices.js';
import { GBUtil } from '../../../src/util.js';
/**
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
@ -369,11 +370,6 @@ export class GBMinService {
GBServer.globals.debugConversationId = conversationId;
const steps = process.env.TEST_MESSAGE.split(';');
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await CollectionUtil.asyncForEach(steps, async step => {
client.apis.Conversations.Conversations_PostActivity({
@ -389,7 +385,7 @@ export class GBMinService {
}
});
await sleep(3000);
await GBUtil.sleep(3000);
});
// Generates MS Teams manifest.

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -48,6 +48,7 @@ import urlJoin from 'url-join';
import { GBDeployer } from './GBDeployer.js';
import { GBMinService } from './GBMinService.js';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { GBUtil } from '../../../src/util.js';
const puppeteer = require('puppeteer-extra');
const hidden = require('puppeteer-extra-plugin-stealth');
const { executablePath } = require('puppeteer');
@ -178,13 +179,7 @@ export class GBSSR {
waitUntil: 'networkidle0'
});
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await sleep(6000);
await GBUtil.sleep(6000);
// Inject <base> on page to relative resources load properly.

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -86,12 +86,6 @@ export class QualityDialog extends IGBDialog {
content: Messages[locale].great_thanks
}
});
let sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await service.insertQuestionAlternate(min.instance.instanceId, user.lastQuestion, user.lastQuestionId);
// Updates values to perform Bot Analytics.

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -7,7 +7,7 @@
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model,this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
@ -50,6 +50,7 @@ import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js';
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import e from 'express';
import { GBUtil } from '../../../src/util.js';
const { WAState, List, Buttons, Client, MessageMedia } = pkg;
/**
@ -180,13 +181,8 @@ export class WhatsappDirectLine extends GBService {
// Keeps the chat list cleaned.
const chats = await client.getChats();
await CollectionUtil.asyncForEach(chats, async chat => {
const sleep = ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
const wait = Math.floor(Math.random() * 5000) + 1000;
await sleep(wait);
await GBUtil.sleep(wait);
if (chat.isGroup) {
// await chat.clearMessages();
} else if (!chat.pinned) {

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -5,7 +5,7 @@
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |

View file

@ -1,6 +1,48 @@
/*****************************************************************************\
| ® |
| |
| |
| |
| |
| |
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of pragmatismo.com.br. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
/**
* @fileoverview General Bots local utility.
*/
const caseInsensitive = (listOrRow) => {
'use strict';
export class GBUtil {
public static sleep(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
public static caseInsensitive(listOrRow) {
if (!listOrRow) {
@ -23,3 +65,5 @@ const caseInsensitive = (listOrRow) => {
return createCaseInsensitiveProxy(listOrRow);
}
};
}