File size: 2,231 Bytes
5c59849
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
{
  "id": "c09783bd-6f0f-4e7d-b4a7-0c8251e7306c",
  "title": "catbox.js",
  "content": "this.zuckbotconfig = {\n  name: \"catbox\",\n  version: '2.3.1.2',\n  author: \"Nguyễn Thanh Tuấn\",\n  role: 0,\n  aliases: ['upcat'],\n  info: \"up ảnh, gif, mp3\",\n  Category: \"Tiện ích\",\n  usePrefix: false,\n  cd: 0,\n  shadowPrefix: false,\n  image : []\n};\n\nthis.onRun = async ({ api, event, args }) => {\n  const axios = require('axios');\n  const FormData = require('form-data');\n\n  if (!event.messageReply || !event.messageReply.attachments || event.messageReply.attachments.length === 0) {\n    return api.sendMessage('Bạn chưa gửi ảnh, gif, mp3!', event.threadID, event.messageID);\n  }\n\n  const attachments = event.messageReply.attachments;\n  const links = [];\n\n  for (const attachment of attachments) {\n    const validTypes = ['photo', 'video', 'audio', 'animated_image'];\n    if (!validTypes.includes(attachment.type)) continue;\n\n    const url = attachment.url;\n    const response = await axios.get(url, { responseType: 'arraybuffer' });\n    const buffer = Buffer.from(response.data, 'binary');\n\n    const form = new FormData();\n    form.append('reqtype', 'fileupload');\n    form.append('userhash', '');\n    form.append('fileToUpload', buffer, {\n      filename: `upload.${attachment.type === 'photo' ? 'png' : \n                 attachment.type === 'animated_image' ? 'gif' : \n                 attachment.type === 'video' ? 'mp4' : 'mp3'}`\n    });\n\n    const uploadResponse = await axios.post('https://catbox.moe/user/api.php', form, {\n      headers: form.getHeaders()\n    });\n\n    const data = uploadResponse.data;\n    if (data.startsWith('Error:')) {\n      return api.sendMessage('Có lỗi xảy ra khi up ảnh: ' + data, event.threadID, event.messageID);\n    }\n\n    links.push(data);\n  }\n\n  if (links.length === 0) {\n    return api.sendMessage('Không có đính kèm nào là ảnh, gif, mp3!', event.threadID, event.messageID);\n  }\n\n  return api.sendMessage('Đây là các link ảnh, gif, mp3 của bạn:\\n' + links.join('\\n'), event.threadID, event.messageID);\n};",
  "language": "javascript",
  "createdAt": 1755771126933,
  "updatedAt": 1755771126933
}