Merge branech 'master' of https://github.com/GeneralBots/BotServer
This commit is contained in:
commit
6a1e454afd
6 changed files with 145 additions and 67 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,3 +1,18 @@
|
||||||
|
## [2.0.175](https://github.com/GeneralBots/BotServer/compare/2.0.174...2.0.175) (2022-09-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **whatsapp.gblib:** SEND FILE and WPP providers. ([05260c0](https://github.com/GeneralBots/BotServer/commit/05260c0ee5cada86bae5dd30db48e8c65c3ed53e))
|
||||||
|
* **whatsapp.gblib:** SEND FILE and WPP providers. ([5261691](https://github.com/GeneralBots/BotServer/commit/5261691ba94708a9d75d9155898a13cf55137733))
|
||||||
|
|
||||||
|
## [2.0.174](https://github.com/GeneralBots/BotServer/compare/2.0.173...2.0.174) (2022-09-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **whatsapp.gblib:** .gbapp message subprocessing. ([c14a766](https://github.com/GeneralBots/BotServer/commit/c14a766047ec1cad9e52104a52a10afb93b8fd71))
|
||||||
|
|
||||||
## [2.0.173](https://github.com/GeneralBots/BotServer/compare/2.0.172...2.0.173) (2022-09-01)
|
## [2.0.173](https://github.com/GeneralBots/BotServer/compare/2.0.172...2.0.173) (2022-09-01)
|
||||||
|
|
||||||
|
|
||||||
|
|
48
CODE_OF_CONDUCT-pt-br.md
Normal file
48
CODE_OF_CONDUCT-pt-br.md
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# Código de Conduta do Convênio do Contribuinte
|
||||||
|
|
||||||
|
## Nosso Compromisso
|
||||||
|
|
||||||
|
No interesse de promover um ambiente aberto e acolhedor, nós, como colaboradores e mantenedores, nos comprometemos a tornar a participação em nosso projeto e nossa comunidade uma experiência livre de assédio para todos, independentemente de idade, tamanho corporal, deficiência, etnia, identidade e expressão de gênero, nível de experiência, nacionalidade, aparência pessoal, raça, religião ou identidade e orientação sexual.
|
||||||
|
|
||||||
|
##Nossos Padrões
|
||||||
|
|
||||||
|
Exemplos de comportamento que contribuem para a criação de um ambiente positivo incluem:
|
||||||
|
|
||||||
|
* Usando padrão (sem expressões idiomáticas), linguagem acolhedora e inclusiva
|
||||||
|
* Ser respeitoso com diferentes pontos de vista e experiências
|
||||||
|
* Aceitar graciosamente críticas construtivas
|
||||||
|
* Foco no que é melhor para a comunidade
|
||||||
|
* Mostrando empatia para com outros membros da comunidade
|
||||||
|
* Escrevendo pedaços gerais de código para que possa ser amplamente utilizado.
|
||||||
|
|
||||||
|
Exemplos de comportamento inaceitável por parte dos participantes incluem:
|
||||||
|
|
||||||
|
* O uso de linguagem ou imagens sexualizadas e atenção ou avanços sexuais indesejados
|
||||||
|
* Trolling, comentários insultuosos/depreciativos e ataques pessoais ou políticos
|
||||||
|
* Assédio público ou privado
|
||||||
|
* Publicar informações privadas de outras pessoas, como endereço físico ou eletrônico, sem permissão explícita
|
||||||
|
* Outras condutas que possam ser razoavelmente consideradas inadequadas em um ambiente profissional
|
||||||
|
* Chame uma pessoa com um nome diferente do declarado pela pessoa
|
||||||
|
|
||||||
|
## Nossas responsabilidades
|
||||||
|
|
||||||
|
Os mantenedores do projeto são responsáveis por esclarecer os padrões de comportamento aceitável e espera-se que tomem ações corretivas apropriadas e justas em resposta a quaisquer instâncias de comportamento inaceitável.
|
||||||
|
|
||||||
|
Os mantenedores do projeto têm o direito e a responsabilidade de remover, editar ou rejeitar comentários, commits, códigos, edições de wiki, problemas e outras contribuições que não estejam alinhadas a este Código de Conduta, ou banir temporária ou permanentemente qualquer colaborador por outros comportamentos que consideram inadequado, ameaçador, ofensivo ou prejudicial.
|
||||||
|
|
||||||
|
## Alcance
|
||||||
|
|
||||||
|
Este Código de Conduta se aplica tanto nos espaços do projeto quanto nos espaços públicos quando um indivíduo representa o projeto ou sua comunidade. Exemplos de representação de um projeto ou comunidade incluem o uso de um endereço de e-mail oficial do projeto, postagem por meio de uma conta oficial de mídia social ou atuação como representante designado em um evento online ou offline. A representação de um projeto pode ser melhor definida e esclarecida pelos mantenedores do projeto.
|
||||||
|
|
||||||
|
## Aplicação
|
||||||
|
|
||||||
|
Casos de comportamento abusivo, de assédio ou de outra forma inaceitável podem ser relatados entrando em contato com a equipe de segurança do Pragmatismo.io em security@pragmatismo.io. A equipe do projeto analisará e investigará todas as reclamações e responderá da maneira que julgar apropriada às circunstâncias. A equipe do projeto é obrigada a manter a confidencialidade em relação ao relator de um incidente. Mais detalhes de políticas de aplicação específicas podem ser postados separadamente.
|
||||||
|
|
||||||
|
Os mantenedores do projeto que não seguem ou aplicam o Código de Conduta de boa fé podem enfrentar repercussões temporárias ou permanentes conforme determinado por outros membros da liderança do projeto.
|
||||||
|
|
||||||
|
## Atribuição
|
||||||
|
|
||||||
|
Este Código de Conduta é adaptado do [Contributor Covenant][homepage], versão 1.4, disponível em [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[página inicial]: http://contributor-covenant.org
|
||||||
|
[versão]: http://contributor-covenant.org/version/1/4/
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "botserver",
|
"name": "botserver",
|
||||||
"version": "2.0.173",
|
"version": "2.0.175",
|
||||||
"description": "General Bot Community Edition open-core server.",
|
"description": "General Bot Community Edition open-core server.",
|
||||||
"main": "./boot.js",
|
"main": "./boot.js",
|
||||||
"bugs": "https://github.com/pragmatismo-io/BotServer/issues",
|
"bugs": "https://github.com/pragmatismo-io/BotServer/issues",
|
||||||
|
|
|
@ -637,17 +637,15 @@ export class GBMinService {
|
||||||
await min.whatsAppDirectLine.setup(true);
|
await min.whatsAppDirectLine.setup(true);
|
||||||
} else {
|
} else {
|
||||||
const minBoot = GBServer.globals.minBoot as any;
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
if (minBoot.instance.whatsappServiceUrl) {
|
min.whatsAppDirectLine = new WhatsappDirectLine(
|
||||||
min.whatsAppDirectLine = new WhatsappDirectLine(
|
min,
|
||||||
min,
|
min.botId,
|
||||||
min.botId,
|
min.instance.whatsappBotKey,
|
||||||
min.instance.whatsappBotKey,
|
minBoot.instance.whatsappServiceKey,
|
||||||
minBoot.instance.whatsappServiceKey,
|
minBoot.instance.whatsappServiceNumber,
|
||||||
minBoot.instance.whatsappServiceNumber,
|
minBoot.instance.whatsappServiceUrl
|
||||||
minBoot.instance.whatsappServiceUrl
|
);
|
||||||
);
|
await min.whatsAppDirectLine.setup(false);
|
||||||
await min.whatsAppDirectLine.setup(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setups default BOT Framework dialogs.
|
// Setups default BOT Framework dialogs.
|
||||||
|
|
|
@ -121,66 +121,76 @@ export class WhatsappDirectLine extends GBService {
|
||||||
switch (this.provider) {
|
switch (this.provider) {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
|
|
||||||
// Initialize the browser using a local profile for each bot.
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
|
if (minBoot.botId !== this.botId) {
|
||||||
|
|
||||||
const gbaiName = `${this.min.botId}.gbai`;
|
this.customClient = minBoot.whatsAppDirectLine.customClient;
|
||||||
let localName = Path.join('work', gbaiName, 'profile');
|
|
||||||
let client = this.customClient = new Client({
|
|
||||||
authStrategy: new LocalAuth({
|
|
||||||
clientId: this.min.botId,
|
|
||||||
dataPath: localName
|
|
||||||
}),
|
|
||||||
puppeteer: {
|
|
||||||
headless: false, args: ['--disable-features=site-per-process',
|
|
||||||
`--user-data-dir=${localName}`]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
client.initialize();
|
|
||||||
|
|
||||||
// Dispatches messages to the received method.
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
client.on('message', (async message => {
|
// Initialize the browser using a local profile for each bot.
|
||||||
await this.WhatsAppCallback(message, null);
|
|
||||||
}).bind(this));
|
|
||||||
|
|
||||||
client.on('qr', (async (qr) => {
|
const gbaiName = `${this.min.botId}.gbai`;
|
||||||
|
let localName = Path.join('work', gbaiName, 'profile');
|
||||||
|
let client = this.customClient = new Client({
|
||||||
|
authStrategy: new LocalAuth({
|
||||||
|
clientId: this.min.botId,
|
||||||
|
dataPath: localName
|
||||||
|
}),
|
||||||
|
puppeteer: {
|
||||||
|
headless: false, args: ['--disable-features=site-per-process',
|
||||||
|
`--user-data-dir=${localName}`]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
client.initialize();
|
||||||
|
|
||||||
const adminNumber = this.min.core.getParam(this.min.instance, 'Bot Admin Number', null);
|
// Dispatches messages to the received method.
|
||||||
const adminEmail = this.min.core.getParam(this.min.instance, 'Bot Admin E-mail', null);
|
|
||||||
|
|
||||||
// Sends QR Code to boot bot admin.
|
|
||||||
|
|
||||||
const msg = `Please, scan QR Code with for bot ${this.botId}.`;
|
|
||||||
GBLog.info(msg);
|
|
||||||
qrcode.generate(qr, { small: true, scale: 0.5 });
|
|
||||||
|
|
||||||
|
|
||||||
// While handling other bots uses boot instance of this class to send QR Codes.
|
client.on('message', (async message => {
|
||||||
|
await this.WhatsAppCallback(message, null);
|
||||||
|
}).bind(this));
|
||||||
|
|
||||||
if (this.botId !== GBServer.globals.minBoot.botId) {
|
client.on('qr', (async (qr) => {
|
||||||
|
|
||||||
const s = new DialogKeywords(null, null, null, null);
|
const adminNumber = this.min.core.getParam(this.min.instance, 'Bot Admin Number', null);
|
||||||
const qrBuf = await s.getQRCode(qr);
|
const adminEmail = this.min.core.getParam(this.min.instance, 'Bot Admin E-mail', null);
|
||||||
const gbaiName = `${this.min.botId}.gbai`;
|
|
||||||
const localName = Path.join('work', gbaiName, 'cache', `qr${GBAdminService.getRndReadableIdentifier()}.png`);
|
|
||||||
fs.writeFileSync(localName, qrBuf);
|
|
||||||
const url = urlJoin(
|
|
||||||
GBServer.globals.publicAddress,
|
|
||||||
this.min.botId,
|
|
||||||
'cache',
|
|
||||||
Path.basename(localName)
|
|
||||||
);
|
|
||||||
GBServer.globals.minBoot.whatsAppDirectLine.sendFileToDevice(adminNumber, url, Path.basename(localName), msg);
|
|
||||||
s.sendEmail(adminEmail, `Check your WhatsApp for bot ${this.botId}`, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).bind(this));
|
// Sends QR Code to boot bot admin.
|
||||||
|
|
||||||
client.on('authenticated', () => {
|
const msg = `Please, scan QR Code with for bot ${this.botId}.`;
|
||||||
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
GBLog.info(msg);
|
||||||
});
|
qrcode.generate(qr, { small: true, scale: 0.5 });
|
||||||
|
|
||||||
setUrl = false;
|
|
||||||
|
// While handling other bots uses boot instance of this class to send QR Codes.
|
||||||
|
|
||||||
|
if (this.botId !== GBServer.globals.minBoot.botId) {
|
||||||
|
|
||||||
|
const s = new DialogKeywords(null, null, null, null);
|
||||||
|
const qrBuf = await s.getQRCode(qr);
|
||||||
|
const gbaiName = `${this.min.botId}.gbai`;
|
||||||
|
const localName = Path.join('work', gbaiName, 'cache', `qr${GBAdminService.getRndReadableIdentifier()}.png`);
|
||||||
|
fs.writeFileSync(localName, qrBuf);
|
||||||
|
const url = urlJoin(
|
||||||
|
GBServer.globals.publicAddress,
|
||||||
|
this.min.botId,
|
||||||
|
'cache',
|
||||||
|
Path.basename(localName)
|
||||||
|
);
|
||||||
|
GBServer.globals.minBoot.whatsAppDirectLine.sendFileToDevice(adminNumber, url, Path.basename(localName), msg);
|
||||||
|
s.sendEmail(adminEmail, `Check your WhatsApp for bot ${this.botId}`, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}).bind(this));
|
||||||
|
|
||||||
|
client.on('authenticated', () => {
|
||||||
|
GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
setUrl = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'chatapi':
|
case 'chatapi':
|
||||||
|
@ -223,7 +233,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setUrl) {
|
if (setUrl && options) {
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
GBServer.globals.server.use(`/audios`, express.static('work'));
|
GBServer.globals.server.use(`/audios`, express.static('work'));
|
||||||
|
|
||||||
|
@ -648,8 +658,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
let options;
|
let options;
|
||||||
switch (this.provider) {
|
switch (this.provider) {
|
||||||
case 'GeneralBots':
|
case 'GeneralBots':
|
||||||
const attachment = MessageMedia.fromUrl(url);
|
const attachment = await MessageMedia.fromUrl(url);
|
||||||
await this.customClient.sendMessage(to += '@c.us', attachment, { caption: caption });
|
await this.customClient.sendMessage(to + '@c.us', attachment, { caption: caption });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'chatapi':
|
case 'chatapi':
|
||||||
|
@ -863,7 +873,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case "GeneralBots":
|
case "GeneralBots":
|
||||||
|
|
||||||
id = req.author.split('@')[0];
|
id = req.from.split('@')[0];
|
||||||
senderName = req._data.notifyName;
|
senderName = req._data.notifyName;
|
||||||
text = req.body;
|
text = req.body;
|
||||||
|
|
||||||
|
@ -1000,8 +1010,11 @@ export class WhatsappDirectLine extends GBService {
|
||||||
id,
|
id,
|
||||||
`Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar? Pode me falar que eu te ouço, me manda um aúdio.`
|
`Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar? Pode me falar que eu te ouço, me manda um aúdio.`
|
||||||
, null);
|
, null);
|
||||||
res.end();
|
if (res) {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// User wants to switch bots.
|
// User wants to switch bots.
|
||||||
|
@ -1037,7 +1050,10 @@ export class WhatsappDirectLine extends GBService {
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
res.end();
|
if (res) {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
activeMin = GBServer.globals.minInstances.filter(p => p.instance.instanceId === user.instanceId)[0];
|
||||||
if (activeMin === undefined) {
|
if (activeMin === undefined) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ export class GBServer {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static run() {
|
public static run() {
|
||||||
|
|
||||||
|
|
||||||
GBLog.info(`The Bot Server is in STARTING mode...`);
|
GBLog.info(`The Bot Server is in STARTING mode...`);
|
||||||
GBServer.globals = new RootData();
|
GBServer.globals = new RootData();
|
||||||
|
@ -112,6 +112,7 @@ export class GBServer {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
GBLog.info(`Now accepting connections on ${port}...`);
|
GBLog.info(`Now accepting connections on ${port}...`);
|
||||||
|
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
||||||
|
|
||||||
// Reads basic configuration, initialize minimal services.
|
// Reads basic configuration, initialize minimal services.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue