themasterofficial3/sahistavaloraXbotPublic · Bot Template
AIMulti-file sharing bot that lets users start an upload session with /upload, collect photos, videos, documents, audio, stickers and animations, then package them into a shareable start-link using Bot storage. The wildcard command watches for upload-mode messages and the finish action, /start with a hash param retrieves and sends stored files, /cancel aborts sessions, and /stats tracks user and command counters. Callback handling supports help/upload buttons, and the error command logs exceptions.
Utilityfile-sharinguploaddownloadshare-linkmediainline-keyboard
7 commands0 envUpdated 23d agoCreated Aug 14, 2026
commands/_.js
javascript · 135 lines
1/**#command2name: *3answer: 4keyboard: 5parse_mode: 6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/*command: * */13 14let message = update.message || null15 16// Handle file uploads when user is in upload mode17if (User.get("waiting_for_files") && message) {18 if (message.text === "✅ Finish Upload") {19 let files = User.get("uploaded_files") || []20 21 if (files.length === 0) {22 Bot.sendMessage(23 "❌ <b>No files uploaded!</b>\n\n" +24 "Please send some files first, then press ✅",25 {26 parse_mode: "HTML",27 reply_markup: { remove_keyboard: true }28 }29 )30 User.del("waiting_for_files")31 User.del("uploaded_files")32 return33 }34 35 let file_hash = generateFileHash()36 Bot.set(file_hash, {37 files: files,38 file_count: files.length,39 created_at: Date.now(),40 created_by: user.id41 }, "json")42 43 let share_link = `https://t.me/${bot.name}?start=${file_hash}`44 45 Bot.sendMessage(46 `✅ <b>Upload Complete!</b>\n\n` +47 `📦 <b>Files Uploaded:</b> ${files.length}\n` +48 `🔗 <b>Shareable Link:</b>\n<code>${share_link}</code>\n\n` +49 50 `💡 <i>Share this link with anyone to download all files</i>`,51 {52 parse_mode: "HTML",53 reply_markup: { remove_keyboard: true }54 }55 )56 57 User.del("waiting_for_files")58 User.del("uploaded_files")59 }60 61 else if (message.document || message.photo || message.video ||62 message.audio || message.voice || message.sticker ||63 message.animation) {64 65 let files = User.get("uploaded_files") || []66 let file_data = null67 68 if (message.photo) {69 file_data = {70 type: "photo",71 file_id: message.photo[message.photo.length - 1].file_id,72 caption: message.caption || ""73 }74 } else if (message.video) {75 file_data = { type: "video", file_id: message.video.file_id, caption: message.caption || "" }76 } else if (message.audio) {77 file_data = { type: "audio", file_id: message.audio.file_id }78 } else if (message.voice) {79 file_data = { type: "voice", file_id: message.voice.file_id }80 } else if (message.document) {81 file_data = { type: "document", file_id: message.document.file_id }82 } else if (message.animation) {83 file_data = { type: "animation", file_id: message.animation.file_id }84 } else if (message.sticker) {85 file_data = { type: "sticker", file_id: message.sticker.file_id }86 }87 88 if (file_data) {89 files.push(file_data)90 User.set("uploaded_files", files, "json")91 92 Bot.sendMessage(93 `✅ <b>File ${files.length} Added!</b>\n\n` +94 `📁 <b>Type:</b> ${file_data.type}\n` +95 `📊 <b>Total Files:</b> ${files.length}\n\n` +96 `💡 <i>Send more files or press '✅ Finish Upload' to complete</i>`,97 { parse_mode: "HTML" }98 )99 } else {100 Bot.sendMessage(101 "❌ <b>Unsupported file type!</b>\n\n" +102 "Please send only supported media files.",103 { parse_mode: "HTML" }104 )105 }106 }107 108 else if (message.text && message.text !== "✅ Finish Upload") {109 Bot.sendMessage(110 "📤 <b>Please send files only</b>\n\n" +111 "Supported: Photos, Videos, Documents, Audio, Voice, Stickers, Animations\n\n" +112 "💡 <i>Press '✅ Finish Upload' when done</i>",113 { parse_mode: "HTML" }114 )115 }116}117 118// Handle callback queries119if (update.callback_query) {120 let data = update.callback_query.data121 if (data === "start_upload") {122 Bot.runCommand("/upload")123 }124 Api.answerCallbackQuery({125 callback_query_id: update.callback_query.id126 })127}128 129// Helper: Generate file hash130function generateFileHash() {131 const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'132 let hash = ''133 for (let i = 0; i < 32; i++) hash += chars.charAt(Math.floor(Math.random() * chars.length))134 return hash135}