marriedtermiteblyi commited on
Commit
123a0a1
·
verified ·
1 Parent(s): 01d123d

put notes/3c70b474-ea8a-46dc-8f52-4750f669e0ae.json

Browse files
notes/3c70b474-ea8a-46dc-8f52-4750f669e0ae.json CHANGED
@@ -4,5 +4,5 @@
4
  "content": "const axios = require(\"axios\");\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\nconst BASE = \"https://twannote.vercel.app\";\nconst isUrl = s => /^https?:\\/\\//i.test(s);\nconst langByExt = e => ({\n js: \"javascript\", mjs: \"javascript\", cjs: \"javascript\",\n ts: \"typescript\", py: \"python\", json: \"json\",\n html: \"html\", htm: \"html\", css: \"css\",\n md: \"markdown\", sh: \"bash\", bash: \"bash\", txt: \"text\"\n}[e] || \"text\");\nconst sendOf = o => m => new Promise(r =>\n o.api.sendMessage(m, o.event.threadID, (_, res) => r(res), o.event.messageID)\n);\n\nasync function createNote(filePath) {\n const content = fs.readFileSync(filePath, \"utf8\");\n const title = path.basename(filePath);\n const language = langByExt(path.extname(filePath).slice(1).toLowerCase());\n const { data } = await axios.post(`${BASE}/api/code`, { title, content, language }, { timeout: 20_000 });\n const id = data?.id; if (!id) throw new Error(\"API trả về không có id\");\n return { id, raw: `${BASE}/code/${id}/raw`, page: `${BASE}/code/${id}` };\n}\n\nthis.config = {\n name: \"note\",\n version: \"2.0.0\",\n hasPermssion: 0,\n credits: \"twan\",\n description: \"note\",\n commandCategory: \"Tiện ích\",\n usages: \"..\",\n cooldowns: 5\n};\n\nthis.run = async function (o) {\n const s = sendOf(o), name = this.config.name;\n const url = o.event?.messageReply?.args?.[0] || o.args[1];\n const file = path.join(__dirname, o.args[0] || \"\");\n try {\n if (isUrl(url)) {\n const res = await s(`🔗 URL: ${url}\\n📄 File đích: ${file}\\n\\nThả cảm xúc để **xác nhận** ghi đè từ URL.`);\n return global.client.handleReaction.push({ ...res, name, path: file, o, url, action: \"confirm_from_url\" });\n }\n if (!fs.existsSync(file)) return s(`❎ Không tìm thấy file: ${file}`);\n\n const { id, raw, page } = await createNote(file);\n const res = await s(\n `📝 Đã tạo note\n• ID: ${id}\n• Raw: ${raw}\n• Page: ${page}\n────────────────\n📄 Nguồn: ${file}\n\n📌 Thả cảm xúc để **tải Raw và ghi đè** file.`\n );\n global.client.handleReaction.push({ ...res, name, path: file, o, url: raw, action: \"confirm_from_url\" });\n } catch (e) { console.error(e); s(String(e)); }\n};\n\nthis.handleReaction = async function (o) {\n const _ = o.handleReaction, s = sendOf(o);\n try {\n if (o.event.userID !== _.o.event.senderID) return;\n if (_.action === \"confirm_from_url\") {\n const { data } = await axios.get(_.url, { responseType: \"text\", timeout: 20_000 });\n fs.writeFileSync(_.path, data);\n s(`✅ Đã ghi đè file\\n🔗 ${_.path}`);\n }\n } catch (e) { console.error(e); s(String(e)); }\n};",
5
  "language": "javascript",
6
  "createdAt": 1755548538791,
7
- "updatedAt": 1755548538791
8
  }
 
4
  "content": "const axios = require(\"axios\");\nconst fs = require(\"fs\");\nconst path = require(\"path\");\n\nconst BASE = \"https://twannote.vercel.app\";\nconst isUrl = s => /^https?:\\/\\//i.test(s);\nconst langByExt = e => ({\n js: \"javascript\", mjs: \"javascript\", cjs: \"javascript\",\n ts: \"typescript\", py: \"python\", json: \"json\",\n html: \"html\", htm: \"html\", css: \"css\",\n md: \"markdown\", sh: \"bash\", bash: \"bash\", txt: \"text\"\n}[e] || \"text\");\nconst sendOf = o => m => new Promise(r =>\n o.api.sendMessage(m, o.event.threadID, (_, res) => r(res), o.event.messageID)\n);\n\nasync function createNote(filePath) {\n const content = fs.readFileSync(filePath, \"utf8\");\n const title = path.basename(filePath);\n const language = langByExt(path.extname(filePath).slice(1).toLowerCase());\n const { data } = await axios.post(`${BASE}/api/code`, { title, content, language }, { timeout: 20_000 });\n const id = data?.id; if (!id) throw new Error(\"API trả về không có id\");\n return { id, raw: `${BASE}/code/${id}/raw`, page: `${BASE}/code/${id}` };\n}\n\nthis.config = {\n name: \"note\",\n version: \"2.0.0\",\n hasPermssion: 0,\n credits: \"twan\",\n description: \"note\",\n commandCategory: \"Tiện ích\",\n usages: \"..\",\n cooldowns: 5\n};\n\nthis.run = async function (o) {\n const s = sendOf(o), name = this.config.name;\n const url = o.event?.messageReply?.args?.[0] || o.args[1];\n const file = path.join(__dirname, o.args[0] || \"\");\n try {\n if (isUrl(url)) {\n const res = await s(`🔗 URL: ${url}\\n📄 File đích: ${file}\\n\\nThả cảm xúc để **xác nhận** ghi đè từ URL.`);\n return global.client.handleReaction.push({ ...res, name, path: file, o, url, action: \"confirm_from_url\" });\n }\n if (!fs.existsSync(file)) return s(`❎ Không tìm thấy file: ${file}`);\n\n const { id, raw, page } = await createNote(file);\n const res = await s(\n `📝 Đã tạo note\n• ID: ${id}\n• Raw: ${raw}\n• Page: ${page}\n────────────────\n📄 Nguồn: ${file}\n\n📌 Thả cảm xúc để **tải Raw và ghi đè** file.`\n );\n global.client.handleReaction.push({ ...res, name, path: file, o, url: raw, action: \"confirm_from_url\" });\n } catch (e) { console.error(e); s(String(e)); }\n};\n\nthis.handleReaction = async function (o) {\n const _ = o.handleReaction, s = sendOf(o);\n try {\n if (o.event.userID !== _.o.event.senderID) return;\n if (_.action === \"confirm_from_url\") {\n const { data } = await axios.get(_.url, { responseType: \"text\", timeout: 20_000 });\n fs.writeFileSync(_.path, data);\n s(`✅ Đã ghi đè file\\n🔗 ${_.path}`);\n }\n } catch (e) { console.error(e); s(String(e)); }\n};",
5
  "language": "javascript",
6
  "createdAt": 1755548538791,
7
+ "updatedAt": 1755581917573
8
  }