Skip to content

Commit 6f51e1e

Browse files
committed
tracking message recognization improved
1 parent 4646406 commit 6f51e1e

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

bot.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ bot.command("help", (ctx) => {
4949
reply_markup,
5050
}
5151
);
52-
} catch (e) {}
52+
} catch (e) { }
5353
});
5454

5555
bot.command("track", async (ctx) => {
56-
const productUrl = ctx.message.text.replace("/track ", "");
56+
const productUrlMessage = ctx.message.text.replace("/track ", "");
57+
const productUrl = "http" + productUrlMessage.split("http")[1].split(" ")[0].replace("dl.", "www.")
5758
if (isUrl(productUrl)) {
5859
const merchant = productUrl
5960
.replace("www.", "")
@@ -89,7 +90,7 @@ bot.command("track", async (ctx) => {
8990
`<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}`,
9091
{ parse_mode: "HTML", reply_markup }
9192
);
92-
} catch (e) {}
93+
} catch (e) { }
9394
} else {
9495
await ctx.api.editMessageText(
9596
ctx.chat.id,
@@ -174,7 +175,7 @@ bot.command("broadcast", async (ctx) => {
174175
},
175176
}
176177
);
177-
} catch (e) {}
178+
} catch (e) { }
178179
})
179180
);
180181
}
@@ -247,14 +248,10 @@ const track = async () => {
247248
);
248249
bot.api.sendMessage(
249250
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
251+
`<a href="${details.image}"> </a><b>Price has been ${details.price > product.price ? "increased" : "decreased"
252+
} by ${Math.abs(product.price - details.price)}</b>. \n\n<b>${details.title
253+
}</b>\n\nCurrent Price: <b>${details.price}</b>\nLink: <a href="${details.link
254+
}">${product.merchant}</a>\n\nTo stop tracking send /stop_${product.tracking_id
258255
}`,
259256
{
260257
parse_mode: "HTML",
@@ -273,11 +270,11 @@ const track = async () => {
273270
},
274271
}
275272
);
276-
} catch (e) {}
273+
} catch (e) { }
277274
}
278275
})
279276
);
280-
} catch (e) {}
277+
} catch (e) { }
281278
};
282279

283280
bot.catch((err) => {

0 commit comments

Comments
 (0)