Get VIN from tg bot

This commit is contained in:
Selim Mustafaev 2025-01-03 18:22:54 +03:00
parent e79f6a398b
commit 9f4ab0f1cd
2 changed files with 25 additions and 5 deletions

View File

@ -56,8 +56,22 @@ class TGProvider {
await this.tgClient.viewMessage(id, this.chat.id); await this.tgClient.viewMessage(id, this.chat.id);
let report = this.parseReport(text); let report = this.parseReport(text);
if(vin01token && report.generalInfo.vin) { let vin = report.generalInfo?.vin;
console.log('Found vin: ', report.generalInfo.vin); if(!vin && report.insurance?.plateNumber == number && report.insurance?.vin) {
vin = report.insurance?.vin;
if(report.generalInfo) {
report.generalInfo.vin = vin;
} else {
report.generalInfo = {
plateNumber: number,
vin: vin
};
}
}
if(vin01token && vin) {
console.log('Found vin: ', vin);
let vin01report = await Vin01Provider.getReportVin(report.generalInfo.vin, null, vin01token); let vin01report = await Vin01Provider.getReportVin(report.generalInfo.vin, null, vin01token);
if(vin01report.ownershipPeriods?.length > 0) { if(vin01report.ownershipPeriods?.length > 0) {
report.ownershipPeriods = vin01report.ownershipPeriods; report.ownershipPeriods = vin01report.ownershipPeriods;
@ -96,7 +110,7 @@ class TGProvider {
let generalInfo = null; let generalInfo = null;
let insurance = null; let insurance = null;
for(let item of result) { for(let item of result) {
let block = Utils.removeNullFields(this.parseBlock(item)); let block = Utils.removeNullFields(this.parseBlock(item));
if(block.sts) { if(block.sts) {

View File

@ -341,11 +341,17 @@ router.post('/checkGbTg', async (req, res) => {
if (report?.generalInfo?.vin?.match(vinRegex)) { if (report?.generalInfo?.vin?.match(vinRegex)) {
let updatedFields = { let updatedFields = {
vin1: report.generalInfo.vin, vin1: report.generalInfo.vin,
color: report.generalInfo.color,
sts: report.generalInfo.sts,
updatedDate: Date.now(), updatedDate: Date.now(),
}; };
if(report.generalInfo.color) {
updatedFields.color = report.generalInfo.color;
}
if(report.generalInfo.sts) {
updatedFields.sts = report.generalInfo.sts;
}
if (report.insurance) { if (report.insurance) {
let osagoFound = let osagoFound =
vehicle.osagoContracts?.some((elem) => { vehicle.osagoContracts?.some((elem) => {