@@ -49,7 +49,7 @@ bot.command("help", (ctx) => {
4949 reply_markup,
5050 }
5151 ) ;
52- } catch ( e ) { }
52+ } catch ( e ) { }
5353} ) ;
5454
5555bot . command ( "track" , async ( ctx ) => {
@@ -89,7 +89,7 @@ bot.command("track", async (ctx) => {
8989 `<a href="${ details . image } "> </a>\nTracking <b>${ details . title } </b>\n\nCurrent Price: <b>${ details . price } </b>\nLink: <a href="${ details . link } ">${ merchant } </a>\n\nTo stop tracking send /stop_${ tracking_id } ` ,
9090 { parse_mode : "HTML" , reply_markup }
9191 ) ;
92- } catch ( e ) { }
92+ } catch ( e ) { }
9393 } else {
9494 await ctx . api . editMessageText (
9595 ctx . chat . id ,
@@ -174,7 +174,7 @@ bot.command("broadcast", async (ctx) => {
174174 } ,
175175 }
176176 ) ;
177- } catch ( e ) { }
177+ } catch ( e ) { }
178178 } )
179179 ) ;
180180 }
@@ -227,57 +227,28 @@ const track = async () => {
227227 await Promise . all (
228228 products . result . map ( async ( product ) => {
229229 const details = await getProductDetails ( product . link , product . merchant ) ;
230- if (
231- details . ok &&
232- ! isNaN ( details . price ) &&
233- details . price !== product . price
234- ) {
230+ if ( details . ok && ! isNaN ( details . price ) && details . price !== product . price ) {
235231 try {
236- await manageProducts (
237- {
238- tracking_id : product . tracking_id ,
239- userId : product . userId ,
240- merchant : product . merchant ,
241- title : details . title ,
242- link : product . link ,
243- initPrice : product . price ,
244- price : details . price ,
245- } ,
246- "update"
247- ) ;
232+ await manageProducts ( { tracking_id : product . tracking_id , userId : product . userId , merchant : product . merchant , title : details . title , link : product . link , initPrice : product . price , price : details . price , } , "update" ) ;
248233 bot . api . sendMessage (
249234 product . userId ,
250- `<a href="${ details . image } "> </a><b>Price has been ${
251- details . price > product . price ? "increased" : "decreased"
252- } by ${ Math . abs ( product . price - details . price ) } </b>. \n\n<b>${
253- details . title
254- } </b>\n\nCurrent Price: <b>${ details . price } </b>\nLink: <a href="${
255- details . link
256- } ">${ product . merchant } </a>\n\nTo stop tracking send /stop_${
257- product . tracking_id
258- } `,
235+ `<a href="${ details . image } "> </a><b>Price has been ${ details . price > product . price ? "increased" : "decreased" } by ${ Math . abs ( product . price - details . price ) } </b>. \n\n<b>${ details . title } </b>\n\nCurrent Price: <b>${ details . price } </b>\nLink: <a href="${ details . link } ">${ product . merchant } </a>\n\nTo stop tracking send /stop_${ product . tracking_id } ` ,
259236 {
260237 parse_mode : "HTML" ,
261238 reply_markup : {
262239 inline_keyboard : [
263240 details ?. link
264241 ? ( [ { text : "Buy Now" , url : details . link } ] ,
265- [
266- {
267- text : "Stop Tracking - " + product . tracking_id ,
268- callback_data : `stopTracking` ,
269- } ,
270- ] )
242+ [ { text : "Stop Tracking - " + product . tracking_id , callback_data : `stopTracking` , } , ] )
271243 : [ ] ,
272- ] ,
273- } ,
274- }
275- ) ;
276- } catch ( e ) { }
244+ ]
245+ }
246+ } ) ;
247+ } catch ( e ) { bot . start ( ) }
277248 }
278249 } )
279250 ) ;
280- } catch ( e ) { }
251+ } catch ( e ) { }
281252} ;
282253
283254bot . catch ( ( err ) => {
0 commit comments