Merge pull request #380 from drauber/qr_translation

Add translate capabilities to QRMessages in CW
This commit is contained in:
Davidson Gomes
2024-01-29 11:30:00 -03:00
committed by GitHub
9 changed files with 68 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ import path from 'path';
import { ConfigService, HttpServer, ChatWoot} from '../../config/env.config';
import { Logger } from '../../config/logger.config';
import i18next from '../../utils/i18n';
import { ICache } from '../abstract/abstract.cache';
import { ChatwootDto } from '../dto/chatwoot.dto';
import { InstanceDto } from '../dto/instance.dto';
@@ -1998,7 +1999,8 @@ export class ChatwootService {
this.logger.verbose('event qrcode.updated');
if (body.statusCode === 500) {
this.logger.verbose('qrcode error');
const erroQRcode = `🚨 QRCode generation limit reached, to generate a new QRCode, send the 'init' message again.`;
const erroQRcode = `🚨 ${i18next.t('qrlimitreached')}`;
this.logger.verbose('send message to chatwoot');
return await this.createBotMessage(instance, erroQRcode, 'incoming');
@@ -2014,9 +2016,9 @@ export class ChatwootService {
writeFileSync(fileName, fileData, 'utf8');
this.logger.verbose('send qrcode to chatwoot');
await this.createBotQr(instance, 'QRCode successfully generated!', 'incoming', fileName);
await this.createBotQr(instance, i18next.t('qrgeneratedsuccesfully'), 'incoming', fileName);
let msgQrCode = `⚡️ QRCode successfully generated!\n\nScan this QR code within the next 40 seconds.`;
let msgQrCode = `⚡️${i18next.t('qrgeneratedsuccesfully')}\n\n${i18next.t('scanqr')}`;
if (body?.qrcode?.pairingCode) {
msgQrCode =