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);
let report = this.parseReport(text);
if(vin01token && report.generalInfo.vin) {
console.log('Found vin: ', report.generalInfo.vin);
let 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);
if(vin01report.ownershipPeriods?.length > 0) {
report.ownershipPeriods = vin01report.ownershipPeriods;

View File

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