From e9c4eea32fff50156fe83bd28d7c450bffa5a521 Mon Sep 17 00:00:00 2001 From: Cedric Hoelzl Date: Thu, 2 Jul 2020 14:33:34 +0200 Subject: [PATCH] kk --- config.js | 29 ++++++++++++++++++++++++----- manual.js | 9 ++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/config.js b/config.js index 802b99c..82705e2 100644 --- a/config.js +++ b/config.js @@ -58,7 +58,7 @@ var token = function(data) { -async function get_tracking(trck_ids){ +const get_tracing = async function(trck_ids){ var data = { "data": [],"guid":"","timeZoneOffset":-120 }; for(var id of trck_ids){ @@ -88,14 +88,33 @@ async function get_tracking(trck_ids){ var results = []; for(var rr of res.dat){ if(rr.track) - results.push({id:rr.no, date:rr.track.z0.a, loc:rr.track.z0.c, status:rr.track.z0.z}); + results.push({id:rr.no, date:rr.track.z0.a, loc:rr.track.z0.c, status:rr.track.z0.z, e: rr.track.e}); else - results.push({id:rr.no, date:'', loc:'', status:"Unknown"}); + results.push({id:rr.no, date:'', loc:'', status:"Unknown", e:0}); } return results; }); } + +const tracking_status = function(e){ + switch(e/10){ + case 0: return "Not Found"; + case 1: return "In Transit"; + case 2: return "Expired"; + case 3: + if(e == 35){ + return "Undelivered"; + }else{ + return "Pick Up"; + } + case 4: return "Delivered"; + case 5: return "Warning"; + case 6: return ""; + default: return "Unknown"; + } +} + //=== MAIN MODULE CONFIG module.exports = function(){ @@ -138,7 +157,7 @@ module.exports = function(){ return get_tracking(ids).then(res=>{ var text = "*Tracking*\n\n"; for(var rr of res){ - text+=`[*${rr.id}*](${tracking.getTrackingUrl(rr.id)})\n_${rr.date?rr.date:'Unknown'} - ${rr.loc?rr.loc:'Unknown'}_\n${rr.status}\n\n`; + text+=`[${rr.id}](${tracking.getTrackingUrl(rr.id)}) - _${tracking_status(rr.e)}_\n_${rr.date?rr.date:'Unknown'} - ${rr.loc?rr.loc:'Unknown'}_\n${rr.status}\n\n`; } return event.reply( text, {"reply_markup":Markup.inlineKeyboard(kb),"parse_mode":"Markdown"}); }); @@ -172,7 +191,7 @@ module.exports = function(){ return get_tracking(res).then(res=>{ var text = `*Tracking* (Updated: ${new Date().toLocaleString()})\n\n`; for(var rr of res){ - text+=`[*${rr.id}*](${tracking.getTrackingUrl(rr.id)})\n_${rr.date?rr.date:'Unknown'} - ${rr.loc?rr.loc:'Unknown'}_\n${rr.status}\n\n`; + text+=`[${rr.id}](${tracking.getTrackingUrl(rr.id)}) - _${tracking_status(rr.e)}_\n_${rr.date?rr.date:'Unknown'} - ${rr.loc?rr.loc:'Unknown'}_\n${rr.status}\n\n`; } return event.editMessageText( text, {"reply_markup":Markup.inlineKeyboard(kb),"parse_mode":"Markdown"}); }); diff --git a/manual.js b/manual.js index 51729f1..232b9b8 100644 --- a/manual.js +++ b/manual.js @@ -79,11 +79,10 @@ async function get_tracking(trck_ids, guid){ .then(res => res.json()); } -get_tracking(['99'],'').then(res=>{ +get_tracking(['UM219234572US','993711592316210394','994034719400788396'],'').then(res=>{ console.log(res.dat); - console.log(res.dat[0].track.zex); - console.log(res.dat[0].track.z0); - console.log(res.dat[0].track.z1); - console.log(tracking.getTrackingUrl('99')); + for(var d of res.dat){ + // console.log(d.track); + } });