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 51m agoCreated Sep 26, 2025
commands/_inline_query.js
javascript · 173 lines
1/**#command2name: /inline_query3answer: 4keyboard: 5parse_mode: 6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12 13const query = request.query;14 15if (!PUBLIC_BOT && user.id !== BOT_OWNER) {16 const results = [{17 type: 'article',18 id: '1',19 title: 'Access Forbidden',20 description: 'Deploy your own FileSharing bot',21 input_message_content: {22 message_text: '*Access forbidden.*\nDeploy your own FileSharing bot for unlimited access.',23 parse_mode: 'Markdown'24 }25 }];26 27 Api.answerInlineQuery({28 inline_query_id: request.id,29 results: JSON.stringify(results),30 cache_time: 131 });32 return;33}34 35if (!query || query.length < 10) {36 const results = [{37 type: 'article',38 id: '1',39 title: 'File Share Bot',40 description: 'Send file hash to share files',41 input_message_content: {42 message_text: '*File Share Bot*\n\nSend me files to get sharing links!\nUse: @' + BOT_USERNAME + ' <file_hash>',43 parse_mode: 'Markdown'44 }45 }];46 47 Api.answerInlineQuery({48 inline_query_id: request.id,49 results: JSON.stringify(results),50 cache_time: 151 });52 return;53}54 55try {56 const messageId = deHashText(query);57 58 let editResult = await Api.editMessageCaption({59 chat_id: BOT_CHANNEL,60 message_id: messageId,61 caption: generateUUID()62 });63 64 if (editResult.ok) {65 const data = editResult.result;66 let results = [];67 68 if (data.document) {69 results = [{70 type: 'document',71 id: '1',72 title: data.document.file_name || "Document",73 document_file_id: data.document.file_id,74 description: data.document.mime_type,75 reply_markup: {76 inline_keyboard: [[77 { text: "Share Again", switch_inline_query_current_chat: query }78 ]]79 }80 }];81 } else if (data.audio) {82 results = [{83 type: 'audio',84 id: '1',85 audio_file_id: data.audio.file_id,86 title: data.audio.title || data.audio.file_name || "Audio File",87 performer: data.audio.performer || "Unknown",88 reply_markup: {89 inline_keyboard: [[90 { text: "Share Again", switch_inline_query_current_chat: query }91 ]]92 }93 }];94 } else if (data.video) {95 results = [{96 type: 'video',97 id: '1',98 video_file_id: data.video.file_id,99 title: data.video.file_name || "Video File",100 description: data.video.mime_type || "Video",101 reply_markup: {102 inline_keyboard: [[103 { text: "Share Again", switch_inline_query_current_chat: query }104 ]]105 }106 }];107 } else if (data.photo) {108 results = [{109 type: 'photo',110 id: '1',111 photo_file_id: data.photo[data.photo.length - 1].file_id,112 title: "Photo",113 reply_markup: {114 inline_keyboard: [[115 { text: "Share Again", switch_inline_query_current_chat: query }116 ]]117 }118 }];119 } else {120 // File type not supported121 results = [{122 type: 'article',123 id: '1',124 title: 'Unsupported File Type',125 description: 'This file type is not supported for inline sharing',126 input_message_content: {127 message_text: '*Unsupported File Type*\n\nThis file cannot be shared via inline mode.',128 parse_mode: 'Markdown'129 }130 }];131 }132 133 Api.answerInlineQuery({134 inline_query_id: request.id,135 results: JSON.stringify(results),136 cache_time: 1137 });138 } else {139 const results = [{140 type: 'article',141 id: '1',142 title: 'File Not Found',143 description: 'The requested file was not found or access denied',144 input_message_content: {145 message_text: '*File Not Found*\n\nThe requested file was not found or you do not have access to it.',146 parse_mode: 'Markdown'147 }148 }];149 150 Api.answerInlineQuery({151 inline_query_id: request.id,152 results: JSON.stringify(results),153 cache_time: 1154 });155 }156} catch (error) {157 const results = [{158 type: 'article',159 id: '1',160 title: 'Invalid File Hash',161 description: 'The provided hash is invalid or corrupted',162 input_message_content: {163 message_text: '*Invalid File Hash*\n\nThe provided file hash is invalid or corrupted. Please check and try again.',164 parse_mode: 'Markdown'165 }166 }];167 168 Api.answerInlineQuery({169 inline_query_id: request.id,170 results: JSON.stringify(results),171 cache_time: 1172 });173}