ashlynn/TBHFileSharingBotPublic · Bot Template
Share files quickly and securely with @TBHFileSharingBot. Send files up to 4 GB and receive instant sharing links for Telegram or direct sharing. With secure encryption, inline mode, and a simple workflow, sharing files from any Telegram chat is fast and effortless.
Utilityfile-sharinginline-modetelegram-linkencryptionwebhookhtml
11 commands0 envUpdated 53m agoCreated Sep 26, 2025
commands/_.js
javascript · 186 lines
1/**#command2name: *3answer: 4keyboard: 5parse_mode: 6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12 13if (message && message.startsWith("/start ")) {14 return; 15}16 17if (!PUBLIC_BOT && user.id !== BOT_OWNER) {18 const accessText = `*Access forbidden.*19 20This is a private file Sharing bot.21 22*Deploy your own:*23Get the source code From TBH Store and deploy your own instance for unlimited access.`;24 25 Bot.sendMessage(accessText);26 return;27}28 29if (msg.document) {30 const fileId = msg.document.file_id;31 const fileName = msg.document.file_name;32 const fileType = msg.document.mime_type;33 const fileSize = msg.document.file_size;34 35 let saveResult = await Api.sendDocument({36 chat_id: BOT_CHANNEL,37 document: fileId38 });39 40 if (saveResult.ok) {41 const hash = hashText(saveResult.result.message_id);42 const telegramLink = `https://t.me/${BOT_USERNAME}?start=${hash}`;43 44 const responseText = `File processed successfully!45 46File Name: \`${fileName}\`47File Type: \`${fileType}\`48File Size: \`${Math.round(fileSize / 1024)} KB\`49File Hash: \`${hash}\`50 51*Choose sharing method:*`;52 53 const keyboard = [54 [55 { text: "Telegram Link", url: telegramLink },56 { text: "Inline Share", switch_inline_query: hash }57 ]58 ];59 60 Api.sendMessage({61 text: responseText,62 reply_markup: { inline_keyboard: keyboard }63 });64 } else {65 Bot.sendMessage("Failed to save file. Please try again.");66 }67 68} else if (msg.audio) {69 const fileId = msg.audio.file_id;70 const fileName = msg.audio.file_name || "audio_file";71 const fileType = msg.audio.mime_type;72 const fileSize = msg.audio.file_size;73 74 let saveResult = await Api.sendDocument({75 chat_id: BOT_CHANNEL,76 document: fileId77 });78 79 if (saveResult.ok) {80 const hash = hashText(saveResult.result.message_id);81 const telegramLink = `https://t.me/${BOT_USERNAME}?start=${hash}`;82 83 const responseText = `Audio file processed!84 85File Name: \`${fileName}\`86File Type: \`${fileType}\`87File Size: \`${Math.round(fileSize / 1024)} KB\`88File Hash: \`${hash}\``;89 90 const keyboard = [91 [92 { text: "Telegram Link", url: telegramLink },93 { text: "Inline Share", switch_inline_query: hash }94 ]95 ];96 97 Api.sendMessage({98 text: responseText,99 reply_markup: { inline_keyboard: keyboard }100 });101 }102 103} else if (msg.video) {104 const fileId = msg.video.file_id;105 const fileName = msg.video.file_name || "video_file";106 const fileType = msg.video.mime_type;107 const fileSize = msg.video.file_size;108 109 let saveResult = await Api.sendDocument({110 chat_id: BOT_CHANNEL,111 document: fileId112 });113 114 if (saveResult.ok) {115 const hash = hashText(saveResult.result.message_id);116 const telegramLink = `https://t.me/${BOT_USERNAME}?start=${hash}`;117 118 const responseText = `Video file processed!119 120File Name: \`${fileName}\`121File Type: \`${fileType}\`122File Size: \`${Math.round(fileSize / 1024)} KB\`123File Hash: \`${hash}\``;124 125 const keyboard = [126 [127 { text: "Telegram Link", url: telegramLink },128 { text: "Inline Share", switch_inline_query: hash }129 ]130 ];131 132 Api.sendMessage({133 text: responseText,134 reply_markup: { inline_keyboard: keyboard }135 });136 }137 138} else if (msg.photo) {139 const photo = msg.photo[msg.photo.length - 1];140 const fileId = photo.file_id;141 const fileName = photo.file_unique_id + '.jpg';142 const fileSize = photo.file_size;143 144 let saveResult = await Api.sendPhoto({145 chat_id: BOT_CHANNEL,146 photo: fileId147 });148 149 if (saveResult.ok) {150 const hash = hashText(saveResult.result.message_id);151 const telegramLink = `https://t.me/${BOT_USERNAME}?start=${hash}`;152 153 const responseText = `Photo processed!154 155File Name: \`${fileName}\`156File Size: \`${Math.round(fileSize / 1024)} KB\`157File Hash: \`${hash}\``;158 159 const keyboard = [160 [161 { text: "Telegram Link", url: telegramLink },162 { text: "Inline Share", switch_inline_query: hash }163 ]164 ];165 166 Api.sendMessage({167 text: responseText,168 reply_markup: { inline_keyboard: keyboard }169 });170 }171 172} else {173 const helpText = `Send me any file to get sharing links!174 175*Supported formats:*176Documents (PDF, DOC, etc.)177Videos (MP4, AVI, etc.)178Audio (MP3, WAV, etc.)179Images (JPG, PNG, etc.)180 181*File limits:*182- Telegram Bot: 20MB183- Channel Storage: 4GB`;184 185 Bot.sendMessage(helpText);186}