This commit is contained in:
Cedric Hoelzl 2020-07-02 14:11:52 +02:00
parent f62f800bef
commit f2072591ae
2 changed files with 10 additions and 3 deletions

View File

@ -5,6 +5,7 @@ const Markup = require('telegraf/markup');
const Extra = require('telegraf/extra'); const Extra = require('telegraf/extra');
const db_js = require('./db.js'); const db_js = require('./db.js');
const tracking = require('./tracking.js');
var db = new db_js("17track"); var db = new db_js("17track");
@ -137,7 +138,7 @@ module.exports = function(){
return get_tracking(ids).then(res=>{ return get_tracking(ids).then(res=>{
var text = "*Tracking*\n\n"; var text = "*Tracking*\n\n";
for(var rr of res){ for(var rr of res){
text+=`*${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)})*\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"}); return event.reply( text, {"reply_markup":Markup.inlineKeyboard(kb),"parse_mode":"Markdown"});
}); });
@ -171,7 +172,7 @@ module.exports = function(){
return get_tracking(res).then(res=>{ return get_tracking(res).then(res=>{
var text = `*Tracking* (Updated: ${new Date().toLocaleString()})\n\n`; var text = `*Tracking* (Updated: ${new Date().toLocaleString()})\n\n`;
for(var rr of res){ for(var rr of res){
text+=`*${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)})*\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"}); return event.editMessageText( text, {"reply_markup":Markup.inlineKeyboard(kb),"parse_mode":"Markdown"});
}); });

View File

@ -1,6 +1,8 @@
const http = require('https'); const http = require('https');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const tracking = require('./tracking.js');
const track_url = 'https://t.17track.net/restapi/track'; const track_url = 'https://t.17track.net/restapi/track';
var cnvrt = function(v) { var cnvrt = function(v) {
@ -77,7 +79,11 @@ async function get_tracking(trck_ids, guid){
.then(res => res.json()); .then(res => res.json());
} }
get_tracking(['9999999999999'],'').then(res=>{ get_tracking(['993711592316210394'],'').then(res=>{
console.log(res.dat); 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('993711592316210394'));
}); });