Get VIN from tg bot
This commit is contained in:
parent
e79f6a398b
commit
9f4ab0f1cd
@ -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;
|
||||||
|
|||||||
@ -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) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user