soumyadeep/TgDocsXBotPublic · Bot Template
TgDocsXBot is a Telegram bot template designed to help developers instantly look up Telegram Bot API documentation directly inside any chat using Inline Queries.
7 commands3 envUpdated 5d agoCreated Jun 10, 2026
commands/checkToken.js
javascript · 46 lines · click line # to share
1/**#command2name: checkToken3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12async function checkToken(message) {13 if (!message) return false;14 15 let tokenMatch = message.match(/[0-9]{8,10}:[a-zA-Z0-9_-]{35}/);16 if (!tokenMatch) return false;17 18 let potentialToken = tokenMatch[0];19 20 let botCheck = await HTTP.get({21 url: "https://api.telegram.org/bot" + potentialToken + "/getMe"22 });23 24 if (botCheck.ok && botCheck.data.ok) {25 Api.deleteMessage({26 chat_id: chat.id,27 message_id: request.message_id28 });29 30 let tag = `<a href="tg://user?id=${user.id}">${user.first_name || "user"}</a>`;31 32 let warningMsg = await Api.sendMessage({33 text: `${tag}, you shared a bot token. Please revoke it immediately from @BotFather. \n\nBe carefull never share your tokens in public chats.`,34 parse_mode: "HTML"35 });36 await sleep(30 * 1000);37 warningMsg.delete();38 return true;39 }40 41 return false;42}43 44module.exports = {45 checkToken46}