This commit is contained in:
Cedric Hoelzl 2020-07-02 14:33:34 +02:00
parent 7b15a686b5
commit e9c4eea32f
2 changed files with 28 additions and 10 deletions

View File

@ -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"});
});

View File

@ -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);
}
});