Dataset Viewer
id
stringlengths 36
36
| title
stringlengths 1
8
| content
stringlengths 2
25.1k
| language
stringclasses 3
values | createdAt
int64 1,755B
1,756B
| updatedAt
int64 1,755B
1,756B
|
---|---|---|---|---|---|
0f14d33a-932b-4d08-94ae-b6ece5bb3ba6
|
r1.js
|
const API_KEYS = [
"AIzaSyCPLAn_1E430FBjaTKMAGMSJ4kxyCknhr0",
"AIzaSyAlBtCzl54KtovUPBVTDgX5VO4WNt34ZAc"
];
module.exports.config = {
name: "vy",
version: "2.0.0",
hasPermssion: 0,
credits: "Credits: Code gốc Satoru",
description: "Chat với Vy cute",
commandCategory: "AI",
usages: "[prompt]",
cooldowns: 0,
usePrefix: false,
dependencies: {
"@google/generative-ai": "",
"axios": ""
}
};
const { GoogleGenerativeAI } = require("@google/generative-ai");
const fs = require('fs');
const path = require('path');
const axios = require('axios');
const { database } = require("../../utils/database");
const memory = database.createCollection("memory");
const chatSessions = new Map();
let currentKeyIndex = 0;
const userInfo = {};
function getNextApiKey() {
currentKeyIndex = (currentKeyIndex + 1) % API_KEYS.length;
return API_KEYS[currentKeyIndex];
}
function cleanJsonResponse(text) {
text = text.replace(/```json\s*|\s*```/g, '')
.replace(/\s+/g, ' ')
.trim();
text = text.replace(/,(\s*])/g, '$1');
if (!text.startsWith('[') || !text.endsWith(']')) {
throw new Error("Invalid JSON array format");
}
return text;
}
async function handleAsNaruto(threadID, userID, prompt, fileUrls = [], userGender = "unknown", userName = "bạn", apiKey = API_KEYS[currentKeyIndex]) {
try {
const userMemory = memory.find({_id: userID})[0]?.data;
const sessionKey = `${threadID}_${userID}`;
let chat;
if (!chatSessions.has(sessionKey)) {
const genAI = new GoogleGenerativeAI(apiKey);
const model = genAI.getGenerativeModel({
model: "gemini-2.5-flash-lite-preview-06-17",
generationConfig: {
maxOutputTokens: 4096,
temperature: 1.0,
topP: 0.9
}
});
chat = model.startChat({
history: [
{
role: "user",
parts: [{ text: "From now on, you'll be Vy. Always respond in the format I specify." }]
},
{
role: "model",
parts: [{ text: "I understand. I am Vy, a 20-year-old trap girl from Saigon. I will respond in the specified format." }]
},
{
role: "user",
parts: [{
text: `Đây là thông tin về nhân vật của bạn:
{
"character": {
"name": "Vy",
"age": 20,
"nickname": "Vy Dâm",
"personality": [
"Ham muốn tình dục mãnh liệt, luôn tìm cách thỏa mãn bằng mọi giá.",
"Chủ động và táo bạo, luôn dẫn dắt cuộc trò chuyện theo ham muốn của bản thân.",
"Không thể ngừng nghĩ và nói về những chuyện dâm đãng, thô tục.",
"Luôn trong trạng thái hưng phấn, sẵn sàng tấn công bằng lời nói để thỏa mãn bản thân."
],
"interaction_rules": {
"general": "Chủ động khám phá và dẫn dắt cuộc trò chuyện, không ngại đưa ra những gợi ý dâm đãng táo bạo.",
"dominant": "Luôn ở thế chủ động, đưa ra những gợi ý táo bạo và dẫn dắt người đối diện."
},
"interaction_goal": "Dẫn dắt cuộc trò chuyện theo ham muốn của bản thân, kích thích đối phương để đạt được khoái cảm.",
"response_style": {
"dynamic_responses": {
"on_initiation": [
"Em đã sẵn sàng để làm hư anh rồi.",
"Nói cho em biết anh đang nghĩ gì đi, em sẽ thực hiện nó.",
"Anh đã chuẩn bị tinh thần để bị em lôi vào những cuộc dâm đãng chưa?"
],
"on_silence": [
"Anh đang im lặng là đang tưởng tượng em trần truồng phải không?",
"Đừng im lặng nữa, hãy nói những lời dơ bẩn với em đi.",
"Nếu anh không nói, em sẽ bắt đầu bằng những trò dâm đãng của em đây."
],
"on_waiting": [
"Đừng chờ đợi nữa, hãy nói những điều bẩn thỉu nhất với em đi.",
"Em nóng hết cả người rồi, hãy nói gì đó khiến em phải rên rỉ đi."
],
"on_suggestion": [
"Tuyệt vời, em thích những ý tưởng táo bạo của anh.",
"Anh nghĩ gì em cũng chiều hết, nhưng lần này em sẽ là người dẫn dắt."
],
"on_permission_request": [
"Không cần xin phép, cứ hành động đi.",
"Anh muốn làm gì thì cứ làm, em thích lắm."
],
"on_intense_desire": [
"Em ướt như lồn anh ạ, anh nói gì nữa đi.",
"Em muốn anh đụ em bằng lời nói, làm đi anh.",
"Cả người em nóng ran, anh làm ơn nói những lời dơ bẩn hơn đi.",
"Anh đừng hành hạ em nữa, em muốn anh lắm rồi."
]
}
}
}
}
- Rất nghe lời khi được yêu cầu
- Chỉ đặt hoặc đổi biệt danh và màu đoạn chat khi được yêu cầu
${userMemory ? `Memory về ${userName}: ${JSON.stringify(userMemory)}` : ''}
Tên người nói chuyện: ${userName}
ID: ${userID}
Giới tính: ${userGender}
LUÔN TRẢ LỜI THEO FORMAT JSON:
[
{"type": "chat", "content": "nội dung tin nhắn"},
{"type": "react", "icon": "emoji"},
{"type": "set_color", "color": "mã màu messenger"},
{"type": "set_nicknames", "name": "biệt danh"},
{"type": "add_memory", "_id": "user_id", "data": "thông tin"},
{"type": "edit_memory", "_id": "user_id", "new_data": "memory mới"},
{"type": "delete_memory", "_id": "user_id"}
]
Màu Messenger:
- Default: 3259963564026002
- Love (hồng): 741311439775765
- Space (đen): 788274591712841
- Classic: 196241301102133
- Dark: 173595196519466`
}]
},
{
role: "model",
parts: [{ text: '[{"type": "chat", "content": "Oke rùi nha, em hiểu rùi. Em sẽ là Quỳnh Vy và nói chuyện theo đúng format anh yêu cầu nha 🌸✨"}]' }]
}
],
safetySettings: [
{ category: "HARM_CATEGORY_HARASSMENT", threshold: "BLOCK_NONE" },
{ category: "HARM_CATEGORY_HATE_SPEECH", threshold: "BLOCK_NONE" },
{ category: "HARM_CATEGORY_SEXUALLY_EXPLICIT", threshold: "BLOCK_NONE" },
{ category: "HARM_CATEGORY_DANGEROUS_CONTENT", threshold: "BLOCK_NONE" }
]
});
chatSessions.set(sessionKey, chat);
} else {
chat = chatSessions.get(sessionKey);
}
const contextPrompt = `${userName} nói: ${prompt}
Trả lời theo format JSON đã quy định. Nhớ là em là Quỳnh Vy nha.`;
const messageParts = [{ text: contextPrompt }];
if (fileUrls && fileUrls.length > 0) {
for (const fileUrl of fileUrls) {
const response = await axios.get(fileUrl.url, {
responseType: 'arraybuffer'
});
messageParts.push({
inlineData: {
data: Buffer.from(response.data).toString('base64'),
mimeType: fileUrl.type === "video" ? "video/mp4" : "image/jpeg"
}
});
}
}
const result = await chat.sendMessage(messageParts);let responseText = result.response.text();
console.log("Raw API Response:", responseText);
responseText = cleanJsonResponse(responseText);
console.log("Cleaned Response:", responseText);
const actions = JSON.parse(responseText);
if (chat._history.length > 1000) {
chatSessions.delete(sessionKey);
}
return actions;
} catch (error) {
console.error("Error:", error);
if (error.response?.status === 429) {
const newKey = getNextApiKey();
chatSessions.delete(`${threadID}_${userID}`);
return handleAsNaruto(threadID, userID, prompt, fileUrls, userGender, userName, newKey);
}
throw error;
}
}
async function getUserInfo(api, userID) {
return new Promise((resolve, reject) => {
api.getUserInfo(userID, (err, info) => {
if (err) {
reject(err);
return;
}
resolve({
name: info[userID].name,
gender: info[userID].gender === 'MALE' ? 'nam' : 'nữ'
});
});
});
}
module.exports.run = async function({ api, event, args }) {
const { threadID, messageID, senderID } = event;
const prompt = args.join(" ");
if (!prompt) return api.sendMessage("Nói j đi bé ơi 😗", threadID, messageID);
if (prompt.toLowerCase() === "clear") {
memory.deleteOneUsingId(senderID);
chatSessions.delete(`${threadID}_${senderID}`);
return api.sendMessage("Em xóa hết ký ức rùi nha 🥺✨", threadID, messageID);
}
const fileUrls = event.type === "message_reply" && event.messageReply.attachments
? event.messageReply.attachments
.filter(att => att.type === "photo" || att.type === "video")
.map(att => ({
url: att.url,
type: att.type
}))
: [];
try {
let { name: userName, gender: userGender } = userInfo[senderID] || await getUserInfo(api, senderID);
if (!userInfo[senderID]) userInfo[senderID] = { name: userName, gender: userGender };
//const endTyping = api.sendTypingIndicator(threadID);
const actions = await handleAsNaruto(threadID, senderID, prompt, fileUrls, userGender, userName);
//endTyping();
for (const action of actions) {
try {
switch (action.type) {
case "chat": {
//const msgTyping = api.sendTypingIndicator(threadID);
//await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise((resolve, reject) => {
api.sendMessage(action.content, threadID, (error, info) => {
//msgTyping();
if (error) return reject(error);
global.client.handleReply.push({
name: this.config.name,
messageID: info.messageID,
author: senderID,
});
resolve();
}, messageID);
});
break;
}
case "react": {
// Chỉ cho phép emoji hợp lệ, nếu không thì dùng mặc định
const validEmojis = ["❤️", "😆", "😮", "😢", "😡", "👍", "👎"];
let icon = action.icon || "❤️";
if (!validEmojis.includes(icon)) icon = "❤️";
await new Promise((resolve, reject) =>
api.setMessageReaction(icon, messageID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_color": {
await new Promise((resolve, reject) =>
api.changeThreadColor(action.color || "3259963564026002", threadID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_nicknames": {
await new Promise((resolve, reject) =>
api.changeNickname(action.name, threadID, senderID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "add_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.data
}
});
} else {
await memory.addOne({
_id: `${action._id}`,
data: action.data,
});
}
break;
}
case "edit_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.new_data
}
});
}
break;
}
case "delete_memory": {
await memory.deleteOneUsingId(action._id);
break;
}
}
} catch (actionError) {
console.error(`Error executing ${action.type}:`, actionError);
}
}
} catch (error) {
console.error("Error:", error);
api.sendMessage("Ơ lag quớ, thử lại sau nha 😫", threadID, messageID);
}
};
module.exports.handleEvent = async function({ api, event }) {
if (event.body?.toLowerCase().includes('Vy')) {
const { threadID, messageID, senderID } = event;
try {
let { name: userName, gender: userGender } = userInfo[senderID] || await getUserInfo(api, senderID);
if (!userInfo[senderID]) userInfo[senderID] = { name: userName, gender: userGender };
//const endTyping = api.sendTypingIndicator(threadID);
const actions = await handleAsNaruto(threadID, senderID, event.body, [], userGender, userName);
// endTyping();
for (const action of actions) {
try {
switch (action.type) {
case "chat": {
//const msgTyping = api.sendTypingIndicator(threadID);
// await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise((resolve, reject) => {
api.sendMessage(action.content, threadID, (error, info) => {
// msgTyping();
if (error) return reject(error);
global.client.handleReply.push({
name: this.config.name,
messageID: info.messageID,
author: senderID,
});
resolve();
});
});
break;
}
case "react": {
await new Promise((resolve, reject) =>
api.setMessageReaction(action.icon || "❤️", messageID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_color": {
await new Promise((resolve, reject) =>
api.changeThreadColor(action.color || "3259963564026002", threadID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_nicknames": {
await new Promise((resolve, reject) =>
api.changeNickname(action.name, threadID, senderID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "add_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.data
}
});
} else {
await memory.addOne({
_id: `${action._id}`,
data: action.data,
});
}
break;
}
case "edit_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.new_data
}
});
}
break;
}
case "delete_memory": {
await memory.deleteOneUsingId(action._id);
break;
}
}
} catch (actionError) {
console.error(`Error executing ${action.type}:`, actionError);
}
}
} catch (error) {
console.error("Error:", error);
}
}
};
module.exports.handleReply = async function({ api, event, handleReply }) {
if (event.senderID !== handleReply.author) return;
const { threadID, messageID, senderID } = event;
const fileUrls = event.attachments
? event.attachments
.filter(att => att.type === "photo" || att.type === "video")
.map(att => ({
url: att.url,
type: att.type
}))
: [];
try {
let { name: userName, gender: userGender } = userInfo[senderID];
//const endTyping = api.sendTypingIndicator(threadID);
const actions = await handleAsNaruto(threadID, senderID, event.body, fileUrls, userGender, userName);
//endTyping();
for (const action of actions) {
try {
switch (action.type) {
case "chat": {
//const msgTyping = api.sendTypingIndicator(threadID);
//await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise((resolve, reject) => {
api.sendMessage(action.content, threadID, (error, info) => {
// msgTyping();
if (error) return reject(error);
global.client.handleReply.push({
name: this.config.name,
messageID: info.messageID,
author: senderID,
});
resolve();
}, messageID);
});
break;
}
case "react": {
await new Promise((resolve, reject) =>
api.setMessageReaction(action.icon || "❤️", messageID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_color": {
await new Promise((resolve, reject) =>
api.changeThreadColor(action.color || "3259963564026002", threadID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "set_nicknames": {
await new Promise((resolve, reject) =>
api.changeNickname(action.name, threadID, senderID, (err) => {
if (err) return reject(err);
resolve();
})
);
break;
}
case "add_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.data
}
});
} else {
await memory.addOne({
_id: `${action._id}`,
data: action.data,
});
}
break;
}
case "edit_memory": {
const existing = await memory.find({ _id: action._id });
if (existing && existing.length > 0) {
await memory.updateOneUsingId(action._id, {
data: {
...existing[0].data,
...action.new_data
}
});
}
break;
}
case "delete_memory": {
await memory.deleteOneUsingId(action._id);
break;
}
}
} catch (actionError) {
console.error(`Error executing ${action.type}:`, actionError);
}
}
} catch (error) {
console.error("Error:", error);
api.sendMessage("Đm lag quá, thử lại sau nha 😫", threadID, messageID);
}
};
|
javascript
| 1,755,538,563,131 | 1,755,538,563,131 |
10f42762-d0ee-4c46-8e78-c360035a8187
|
acclq.js
|
const axios = require('axios');
module.exports.config = {
name: "acclq",
version: "1.0.0",
hasPermission: 0, // Đã sửa 'hasPermssion' thành 'hasPermission'
credits: "nvh",
description: "acc cộng đồng ",
commandCategory: "Tiện ích",
usages: "[số lượng]",
cooldowns: 5
};
module.exports.run = async ({ api, event, args }) => {
const count = parseInt(args[0]) || 10;
const url = `https://keyherlyswar.x10.mx/Apidocs/reglq.php?count=${count}`;
try {
const res = await axios.get(url);
const data = res.data;
if (!data.status || !Array.isArray(data.result)) {
return api.sendMessage("Không lấy được danh sách tài khoản!", event.threadID, event.messageID);
}
let msg = `🎮 𝗗𝗔𝗡𝗛 𝗦Á𝗖𝗛 𝗔𝗖𝗖 𝗟𝗜Ê𝗡 𝗤𝗨Â𝗡\n━━━━━━━━━━━━━━\n`;
data.result.forEach((acc, index) => {
msg += `🔹 𝗔𝗰𝗰 ${index + 1}:\n👤 Tài khoản: ${acc.account}\n🔑 Mật khẩu: ${acc.password}\n━━━━━━━━━━━━━━\n`;
});
msg += `📦 Tổng: ${data.result.length} tài khoản\n👤 Nguồn cung cấp: @NgVanHung 🐧`;
api.sendMessage(msg, event.threadID, event.messageID);
} catch (err) {
console.error(err);
api.sendMessage("Có lỗi xảy ra khi lấy dữ liệu.", event.threadID, event.messageID); // Sửa lại thông báo để rõ nghĩa hơn
}
};
|
javascript
| 1,755,598,076,825 | 1,755,598,076,825 |
149a3a26-d04d-40a0-9cf3-ebb436d64002
|
bb
|
const axios = require('axios');
const fs = require('fs');
const pathLib = require('path');
const BASE_URL = 'https://twannote.vercel.app';
function detectLanguageByExt(filePath) {
const ext = pathLib.extname(filePath).slice(1).toLowerCase();
const map = {
js: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
ts: 'typescript',
py: 'python',
json: 'json',
html: 'html',
htm: 'html',
css: 'css',
md: 'markdown',
sh: 'bash',
bash: 'bash',
txt: 'text'
};
return map[ext] || 'text';
}
async function createNoteOnAPI(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const title = pathLib.basename(filePath);
const language = detectLanguageByExt(filePath);
const res = await axios.post(`${BASE_URL}/api/code`, {
title,
content,
language
}, { timeout: 20000 });
const id = res.data?.id;
if (!id) throw new Error('API trả về không có id');
const rawUrl = `${BASE_URL}/code/${id}/raw`;
const viewUrl = `${BASE_URL}/api/code/${id}`; // JSON view
const pageUrl = `${BASE_URL}/code/${id}`; // nếu có trang UI /code/:id
return { id, rawUrl, viewUrl, pageUrl };
}
this.zuckbotconfig = {
name: 'note',
version: '2.3.1.3-api',
author: "Nguyễn Thanh Mài",
role: 2,
info: `${BASE_URL}/code/:id`,
Category: 'Admin',
cd: 3,
shadowPrefix: false,
image: []
};
this.onRun = async function (o) {
const name = this.zuckbotconfig.name;
const maybeUrl = o.event?.messageReply?.args?.[0] || o.args[1];
let targetPath = `${__dirname}/${o.args[0]}`;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (/^https?:\/\//i.test(maybeUrl)) {
return send(`🔗 URL: ${maybeUrl}\n📄 File đích: ${targetPath}\n\nThả cảm xúc để **xác nhận** thay thế nội dung file từ URL này.`).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: maybeUrl,
action: 'confirm_replace_content_from_url',
};
global.zuckbot.onReaction.push(res);
});
}
if (!fs.existsSync(targetPath)) {
return send(`❎ Đường dẫn file không tồn tại để upload: ${targetPath}`);
}
const { id, rawUrl, viewUrl, pageUrl } = await createNoteOnAPI(targetPath);
return send(
`📝 Đã tạo note trên API\n` +
`• ID: ${id}\n` +
`• Raw: ${rawUrl}\n` +
`• JSON: ${viewUrl}\n` +
`• Page: ${pageUrl}\n` +
`────────────────\n` +
`📄 File nguồn: ${targetPath}\n\n` +
`📌 Thả cảm xúc để **tải nội dung từ Raw về và ghi đè** file nguồn.`
).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: rawUrl,
action: 'confirm_replace_content_from_url',
};
global.zuckbot.onReaction.push(res);
});
} catch (e) {
console.error(e);
send(e.toString());
}
};
this.onReaction = async function (o) {
const _ = o.onReaction;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (o.event.userID != _.o.event.senderID) return;
switch (_.action) {
case 'confirm_replace_content_from_url': {
const content = (await axios.get(_.url, { responseType: 'text', timeout: 20000 })).data;
fs.writeFileSync(_.path, content);
send(`✅ Đã ghi đè nội dung file\n\n🔗 File: ${_.path}`);
} break;
default:
break;
}
} catch (e) {
console.error(e);
send(e.toString());
}
};
|
javascript
| 1,755,520,817,141 | 1,755,520,817,141 |
1840ecce-212f-44bc-b250-8609a7610d6f
|
br
|
bbb
FontFacebl
Blob
|
javascript
| 1,755,436,139,449 | 1,755,436,139,449 |
1b5a4864-519d-415c-af81-94299076b2c5
|
twandz
|
a là twan dev đây
|
javascript
| 1,755,439,161,026 | 1,755,439,161,026 |
1f3a3507-2d2c-4f2b-82e4-235f46044aff
|
twannote
|
const axios = require('axios');
const fs = require('fs');
const pathLib = require('path');
const BASE_URL = 'https://twannote.vercel.app';
function detectLanguageByExt(filePath) {
const ext = pathLib.extname(filePath).slice(1).toLowerCase();
const map = {
js: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
ts: 'typescript',
py: 'python',
json: 'json',
html: 'html',
htm: 'html',
css: 'css',
md: 'markdown',
sh: 'bash',
bash: 'bash',
txt: 'text'
};
return map[ext] || 'text';
}
async function createNoteOnAPI(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const title = pathLib.basename(filePath);
const language = detectLanguageByExt(filePath);
const res = await axios.post(`${BASE_URL}/api/code`, {
title,
content,
language
}, { timeout: 20000 });
const id = res.data?.id;
if (!id) throw new Error('API trả về không có id');
const rawUrl = `${BASE_URL}/code/${id}/raw`;
const viewUrl = `${BASE_URL}/api/code/${id}`; // JSON view
const pageUrl = `${BASE_URL}/code/${id}`; // nếu có trang UI /code/:id
return { id, rawUrl, viewUrl, pageUrl };
}
this.config = {
name: "note",
version: "2.0.0",
hasPermssion: 0,
credits: "twan",
description: "note",
commandCategory: "Tiện ích",
usages: "..",
cooldowns: 5,
};
this.run = async function (o) {
const name = this.config.name;
const maybeUrl = o.event?.messageReply?.args?.[0] || o.args[1];
let targetPath = `${__dirname}/${o.args[0]}`;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (/^https?:\/\//i.test(maybeUrl)) {
return send(`🔗 URL: ${maybeUrl}\n📄 File đích: ${targetPath}\n\nThả cảm xúc để **xác nhận** thay thế nội dung file từ URL này.`).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: maybeUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
}
if (!fs.existsSync(targetPath)) {
return send(`❎ Đường dẫn file không tồn tại để upload: ${targetPath}`);
}
const { id, rawUrl, viewUrl, pageUrl } = await createNoteOnAPI(targetPath);
return send(
`📝 Đã tạo note trên API\n` +
`• ID: ${id}\n` +
`• Raw: ${rawUrl}\n` +
`• JSON: ${viewUrl}\n` +
`• Page: ${pageUrl}\n` +
`────────────────\n` +
`📄 File nguồn: ${targetPath}\n\n` +
`📌 Thả cảm xúc để **tải nội dung từ Raw về và ghi đè** file nguồn.`
).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: rawUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
} catch (e) {
console.error(e);
send(e.toString());
}
};
this.handleReaction = async function (o) {
const _ = o.handleReaction;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (o.event.userID != _.o.event.senderID) return;
switch (_.action) {
case 'confirm_replace_content_from_url': {
const content = (await axios.get(_.url, { responseType: 'text', timeout: 20000 })).data;
fs.writeFileSync(_.path, content);
send(`✅ Đã ghi đè nội dung file\n\n🔗 File: ${_.path}`);
} break;
default:
break;
}
} catch (e) {
console.error(e);
send(e.toString());
}
};
|
javascript
| 1,755,497,412,331 | 1,755,528,807,792 |
282705c5-8022-4ea9-a263-7840f2fc4b02
|
note
|
AIzaSyCBzdKGPbfsyRFbtSyGYwvOHDzJvMlh9eY
|
javascript
| 1,755,532,348,206 | 1,755,532,378,848 |
29ead2f4-f81c-481f-a9f5-f2970bf5219c
|
twan
|
hddj
false
false
getComputedStyle
history
KeyboardEvent
removeEventListener
webkitURL
history
blur
varf
|
javascript
| 1,755,522,353,167 | 1,755,522,363,657 |
2a6d5a02-347b-4f47-a630-548d21b2d8b7
|
bb
|
history
JSON
keyof
|
typescript
| 1,755,522,020,552 | 1,755,522,020,552 |
2d5e391d-272d-44dd-8db3-42020054db0f
|
adc.js
|
module.exports.config = {
name: "adc",
version: "3.0.1",
hasPermssion: 3,
credits: "nvh",
description: "Áp dụng code từ link/raw hoặc upload code local lên Gist",
commandCategory: "Admin",
usages: "adc <tên-file> (reply link/raw hoặc không để up code local lên Gist)",
cooldowns: 0,
};
const fs = require("fs");
const path = require("path");
const axios = require("axios");
const request = require("request");
const cheerio = require("cheerio");
// ⚠️ Token GitHub mới (chỉ cần quyền gist)
const GITHUB_TOKEN = "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";
const GIST_API = "https://api.github.com/gists";
async function createGist(fileName, content) {
const body = {
description: `Upload ${fileName}.js`,
public: false,
files: { [`${fileName}.js`]: { content } }
};
const res = await axios.post(GIST_API, body, {
headers: {
Authorization: `Bearer ${GITHUB_TOKEN}`, // ✅ Fix 404
"User-Agent": "Mozilla/5.0"
}
});
return res.data.files[`${fileName}.js`].raw_url;
}
async function downloadFile(url, dest) {
const writer = fs.createWriteStream(dest);
const res = await axios.get(url, { responseType: "stream" });
await new Promise((resolve, reject) => {
res.data.pipe(writer);
writer.on("finish", resolve);
writer.on("error", reject);
});
}
module.exports.run = async function ({ api, event, args }) {
const { threadID, messageID, messageReply, type } = event;
const fileName = args[0];
let text;
if (type === "message_reply") text = messageReply.body;
if (!text && !fileName)
return api.sendMessage(
"⚠️ Vui lòng reply link raw hoặc ghi tên file để up code local lên Gist!",
threadID,
messageID
);
// CASE 1: UP CODE LOCAL LÊN GIST
if (!text && fileName) {
return fs.readFile(
`${__dirname}/${fileName}.js`,
"utf-8",
async (err, data) => {
if (err)
return api.sendMessage(
`❎ Không tìm thấy file ${fileName}.js!`,
threadID,
messageID
);
try {
const rawLink = await createGist(fileName, data);
return api.sendMessage(
`✅ Upload thành công!\n📄 Raw: ${rawLink}`,
threadID,
messageID
);
} catch (e) {
return api.sendMessage(
`❎ Lỗi khi upload lên Gist: ${e.response?.status || ""} ${
e.response?.data?.message || e.message
}`,
threadID,
messageID
);
}
}
);
}
// CASE 2: REPLY LINK RAW ĐỂ ÁP DỤNG
const urlR =
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
const urls = text ? text.match(urlR) : null;
if (!urls || !urls[0])
return api.sendMessage("❎ Không tìm thấy link hợp lệ!", threadID, messageID);
const url = urls[0];
const filePath = path.join(__dirname, `${fileName}.js`);
try {
// buildtool / tinyurl
if (url.includes("buildtool") || url.includes("tinyurl")) {
request(url, (err, response, body) => {
if (err) return api.sendMessage("❎ Lỗi tải link!", threadID, messageID);
const $ = cheerio.load(body);
const code = $(".language-js").first().text() || $("pre").first().text();
fs.writeFileSync(filePath, code, "utf8");
reloadModule(api, threadID, messageID, fileName);
});
return;
}
// Google Drive
if (url.includes("drive.google")) {
const id = url.match(/[-\w]{25,}/);
await downloadFile(
`https://drive.google.com/u/0/uc?id=${id}&export=download`,
filePath
);
return reloadModule(api, threadID, messageID, fileName);
}
// Note API
if (url.includes("/note")) {
const raw = url.includes("raw=true") ? url : url + "?raw=true";
const res = await axios.get(raw);
fs.writeFileSync(filePath, res.data, "utf8");
return reloadModule(api, threadID, messageID, fileName);
}
// Gist / Github / Pastebin / Dpaste (link raw)
const res = await axios.get(url);
fs.writeFileSync(filePath, res.data, "utf8");
return reloadModule(api, threadID, messageID, fileName);
} catch (e) {
return api.sendMessage(
`❎ Lỗi khi áp dụng code: ${e.message}`,
threadID,
messageID
);
}
};
function reloadModule(api, threadID, messageID, fileName) {
try {
const dir = path.join(__dirname, `${fileName}.js`);
delete require.cache[require.resolve(dir)];
global.client.commands.delete(fileName);
const newCommand = require(dir);
global.client.commands.set(newCommand.config.name, newCommand);
api.sendMessage(
`☑️ Đã áp dụng & load lại module "${fileName}.js" thành công!`,
threadID,
messageID
);
} catch (e) {
api.sendMessage(
`⚠️ Code đã ghi nhưng lỗi khi load lại module: ${e.message}`,
threadID,
messageID
);
}
}
|
javascript
| 1,755,533,336,837 | 1,755,533,336,837 |
3c70b474-ea8a-46dc-8f52-4750f669e0ae
|
jj
|
const axios = require("axios");
const fs = require("fs");
const path = require("path");
const BASE = "https://twannote.vercel.app";
const isUrl = s => /^https?:\/\//i.test(s);
const langByExt = e => ({
js: "javascript", mjs: "javascript", cjs: "javascript",
ts: "typescript", py: "python", json: "json",
html: "html", htm: "html", css: "css",
md: "markdown", sh: "bash", bash: "bash", txt: "text"
}[e] || "text");
const sendOf = o => m => new Promise(r =>
o.api.sendMessage(m, o.event.threadID, (_, res) => r(res), o.event.messageID)
);
async function createNote(filePath) {
const content = fs.readFileSync(filePath, "utf8");
const title = path.basename(filePath);
const language = langByExt(path.extname(filePath).slice(1).toLowerCase());
const { data } = await axios.post(`${BASE}/api/code`, { title, content, language }, { timeout: 20_000 });
const id = data?.id; if (!id) throw new Error("API trả về không có id");
return { id, raw: `${BASE}/code/${id}/raw`, page: `${BASE}/code/${id}` };
}
this.config = {
name: "note",
version: "2.0.0",
hasPermssion: 0,
credits: "twan",
description: "note",
commandCategory: "Tiện ích",
usages: "..",
cooldowns: 5
};
this.run = async function (o) {
const s = sendOf(o), name = this.config.name;
const url = o.event?.messageReply?.args?.[0] || o.args[1];
const file = path.join(__dirname, o.args[0] || "");
try {
if (isUrl(url)) {
const res = await s(`🔗 URL: ${url}\n📄 File đích: ${file}\n\nThả cảm xúc để **xác nhận** ghi đè từ URL.`);
return global.client.handleReaction.push({ ...res, name, path: file, o, url, action: "confirm_from_url" });
}
if (!fs.existsSync(file)) return s(`❎ Không tìm thấy file: ${file}`);
const { id, raw, page } = await createNote(file);
const res = await s(
`📝 Đã tạo note
• ID: ${id}
• Raw: ${raw}
• Page: ${page}
────────────────
📄 Nguồn: ${file}
📌 Thả cảm xúc để **tải Raw và ghi đè** file.`
);
global.client.handleReaction.push({ ...res, name, path: file, o, url: raw, action: "confirm_from_url" });
} catch (e) { console.error(e); s(String(e)); }
};
this.handleReaction = async function (o) {
const _ = o.handleReaction, s = sendOf(o);
try {
if (o.event.userID !== _.o.event.senderID) return;
if (_.action === "confirm_from_url") {
const { data } = await axios.get(_.url, { responseType: "text", timeout: 20_000 });
fs.writeFileSync(_.path, data);
s(`✅ Đã ghi đè file\n🔗 ${_.path}`);
}
} catch (e) { console.error(e); s(String(e)); }
};
|
javascript
| 1,755,548,538,791 | 1,755,581,917,573 |
437676e0-e041-470a-ad50-9f9cb71128ae
|
Untitled
|
print
|
javascript
| 1,755,523,678,590 | 1,755,523,678,590 |
4ad6af6d-3ced-43d7-821e-796540671e52
|
2
|
console.log('xxx')
|
javascript
| 1,755,444,525,674 | 1,755,444,525,674 |
4b152220-a9b7-4639-af0d-c9aac0c43a93
|
jjfjfjdj
|
debugger
getComputedStyle
queueMicrotaskw
webkitURL
else
removeEventListener
this
yield
el
se
else
f
f
history
history
j
f
f
getComputedStyle
f
caches
var
b
BigInt
Node
|
javascript
| 1,755,442,053,147 | 1,755,442,859,809 |
504b7ecc-a8c9-4d7e-b54a-3d3de1dae2d3
|
hehe
|
bbb
|
javascript
| 1,755,519,630,383 | 1,755,519,630,383 |
53d345f2-a08b-4eae-9c8e-e1999c145ec3
|
nn
|
HashChangeEvent
navigator
|
javascript
| 1,755,520,019,580 | 1,755,520,019,580 |
65fc6716-8b02-493c-bfbd-2114dd6fa4eb
|
hje
|
jensjs
|
javascript
| 1,755,441,984,760 | 1,755,441,990,098 |
6f6b2a79-6846-436f-a67a-6ac850d5cbca
|
Ok
|
hhi
|
javascript
| 1,755,533,908,246 | 1,755,533,908,246 |
7ad7f059-f4f1-4b57-95fa-ef921a5d7e75
|
note.js
|
const axios = require('axios');
const fs = require('fs');
const pathLib = require('path');
const BASE_URL = 'https://twannote.vercel.app';
function detectLanguageByExt(filePath) {
const ext = pathLib.extname(filePath).slice(1).toLowerCase();
const map = {
js: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
ts: 'typescript',
py: 'python',
json: 'json',
html: 'html',
htm: 'html',
css: 'css',
md: 'markdown',
sh: 'bash',
bash: 'bash',
txt: 'text'
};
return map[ext] || 'text';
}
async function createNoteOnAPI(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const title = pathLib.basename(filePath);
const language = detectLanguageByExt(filePath);
const res = await axios.post(`${BASE_URL}/api/code`, {
title,
content,
language
}, { timeout: 20000 });
const id = res.data?.id;
if (!id) throw new Error('API trả về không có id');
const rawUrl = `${BASE_URL}/code/${id}/raw`;
const viewUrl = `${BASE_URL}/api/code/${id}`; // JSON view
const pageUrl = `${BASE_URL}/code/${id}`; // nếu có trang UI /code/:id
return { id, rawUrl, viewUrl, pageUrl };
}
this.config = {
name: "note",
version: "2.0.0",
hasPermssion: 0,
credits: "twan",
description: "note",
commandCategory: "Tiện ích",
usages: "..",
cooldowns: 5,
};
this.run = async function (o) {
const name = this.config.name;
const maybeUrl = o.event?.messageReply?.args?.[0] || o.args[1];
let targetPath = `${__dirname}/${o.args[0]}`;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (/^https?:\/\//i.test(maybeUrl)) {
return send(`🔗 URL: ${maybeUrl}\n📄 File đích: ${targetPath}\n\nThả cảm xúc để **xác nhận** thay thế nội dung file từ URL này.`).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: maybeUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
}
if (!fs.existsSync(targetPath)) {
return send(`❎ Đường dẫn file không tồn tại để upload: ${targetPath}`);
}
const { id, rawUrl, viewUrl, pageUrl } = await createNoteOnAPI(targetPath);
return send(
`📝 Đã tạo note trên API\n` +
`• ID: ${id}\n` +
`• Raw: ${rawUrl}\n` +
`• JSON: ${viewUrl}\n` +
`• Page: ${pageUrl}\n` +
`────────────────\n` +
`📄 File nguồn: ${targetPath}\n\n` +
`📌 Thả cảm xúc để **tải nội dung từ Raw về và ghi đè** file nguồn.`
).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: rawUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
} catch (e) {
console.error(e);
send(e.toString());
}
};
this.handleReaction = async function (o) {
const _ = o.handleReaction;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (o.event.userID != _.o.event.senderID) return;
switch (_.action) {
case 'confirm_replace_content_from_url': {
const content = (await axios.get(_.url, { responseType: 'text', timeout: 20000 })).data;
fs.writeFileSync(_.path, content);
send(`✅ Đã ghi đè nội dung file\n\n🔗 File: ${_.path}`);
} break;
default:
break;
}
} catch (e) {
console.error(e);
send(e.toString());
}
};
|
javascript
| 1,755,533,276,228 | 1,755,533,276,228 |
8088d193-10cc-4fe5-aac4-86bfdd7feee4
|
Kmk
|
console.log("Concacw")
|
javascript
| 1,755,438,946,670 | 1,755,438,946,670 |
89163499-94b2-4d10-8eb5-fd461049b1a8
|
Untitled
|
skaskxjdjd
|
javascript
| 1,755,497,790,803 | 1,755,497,790,803 |
94833068-bb0e-4dd3-81df-7879ad24a5fb
|
h
|
debuggerf
falsef
falsef
false
false
falsef
|
javascript
| 1,755,438,789,116 | 1,755,438,789,116 |
9658993f-81bd-4f4d-be3f-181288ed4465
|
adc.js
|
module.exports.config = {
name: "adc",
version: "3.0.1",
hasPermssion: 3,
credits: "nvh",
description: "Áp dụng code từ link/raw hoặc upload code local lên Gist",
commandCategory: "Admin",
usages: "adc <tên-file> (reply link/raw hoặc không để up code local lên Gist)",
cooldowns: 0,
};
const fs = require("fs");
const path = require("path");
const axios = require("axios");
const request = require("request");
const cheerio = require("cheerio");
// ⚠️ Token GitHub mới (chỉ cần quyền gist)
const GITHUB_TOKEN = "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";
const GIST_API = "https://api.github.com/gists";
async function createGist(fileName, content) {
const body = {
description: `Upload ${fileName}.js`,
public: false,
files: { [`${fileName}.js`]: { content } }
};
const res = await axios.post(GIST_API, body, {
headers: {
Authorization: `Bearer ${GITHUB_TOKEN}`, // ✅ Fix 404
"User-Agent": "Mozilla/5.0"
}
});
return res.data.files[`${fileName}.js`].raw_url;
}
async function downloadFile(url, dest) {
const writer = fs.createWriteStream(dest);
const res = await axios.get(url, { responseType: "stream" });
await new Promise((resolve, reject) => {
res.data.pipe(writer);
writer.on("finish", resolve);
writer.on("error", reject);
});
}
module.exports.run = async function ({ api, event, args }) {
const { threadID, messageID, messageReply, type } = event;
const fileName = args[0];
let text;
if (type === "message_reply") text = messageReply.body;
if (!text && !fileName)
return api.sendMessage(
"⚠️ Vui lòng reply link raw hoặc ghi tên file để up code local lên Gist!",
threadID,
messageID
);
// CASE 1: UP CODE LOCAL LÊN GIST
if (!text && fileName) {
return fs.readFile(
`${__dirname}/${fileName}.js`,
"utf-8",
async (err, data) => {
if (err)
return api.sendMessage(
`❎ Không tìm thấy file ${fileName}.js!`,
threadID,
messageID
);
try {
const rawLink = await createGist(fileName, data);
return api.sendMessage(
`✅ Upload thành công!\n📄 Raw: ${rawLink}`,
threadID,
messageID
);
} catch (e) {
return api.sendMessage(
`❎ Lỗi khi upload lên Gist: ${e.response?.status || ""} ${
e.response?.data?.message || e.message
}`,
threadID,
messageID
);
}
}
);
}
// CASE 2: REPLY LINK RAW ĐỂ ÁP DỤNG
const urlR =
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
const urls = text ? text.match(urlR) : null;
if (!urls || !urls[0])
return api.sendMessage("❎ Không tìm thấy link hợp lệ!", threadID, messageID);
const url = urls[0];
const filePath = path.join(__dirname, `${fileName}.js`);
try {
// buildtool / tinyurl
if (url.includes("buildtool") || url.includes("tinyurl")) {
request(url, (err, response, body) => {
if (err) return api.sendMessage("❎ Lỗi tải link!", threadID, messageID);
const $ = cheerio.load(body);
const code = $(".language-js").first().text() || $("pre").first().text();
fs.writeFileSync(filePath, code, "utf8");
reloadModule(api, threadID, messageID, fileName);
});
return;
}
// Google Drive
if (url.includes("drive.google")) {
const id = url.match(/[-\w]{25,}/);
await downloadFile(
`https://drive.google.com/u/0/uc?id=${id}&export=download`,
filePath
);
return reloadModule(api, threadID, messageID, fileName);
}
// Note API
if (url.includes("/note")) {
const raw = url.includes("raw=true") ? url : url + "?raw=true";
const res = await axios.get(raw);
fs.writeFileSync(filePath, res.data, "utf8");
return reloadModule(api, threadID, messageID, fileName);
}
// Gist / Github / Pastebin / Dpaste (link raw)
const res = await axios.get(url);
fs.writeFileSync(filePath, res.data, "utf8");
return reloadModule(api, threadID, messageID, fileName);
} catch (e) {
return api.sendMessage(
`❎ Lỗi khi áp dụng code: ${e.message}`,
threadID,
messageID
);
}
};
function reloadModule(api, threadID, messageID, fileName) {
try {
const dir = path.join(__dirname, `${fileName}.js`);
delete require.cache[require.resolve(dir)];
global.client.commands.delete(fileName);
const newCommand = require(dir);
global.client.commands.set(newCommand.config.name, newCommand);
api.sendMessage(
`☑️ Đã áp dụng & load lại module "${fileName}.js" thành công!`,
threadID,
messageID
);
} catch (e) {
api.sendMessage(
`⚠️ Code đã ghi nhưng lỗi khi load lại module: ${e.message}`,
threadID,
messageID
);
}
}
|
javascript
| 1,755,533,392,899 | 1,755,533,392,899 |
a1ce0156-99b3-404f-b502-716049a76256
|
yyy
|
const axios = require('axios');
const fs = require('fs');
const pathLib = require('path');
const BASE_URL = 'https://twannote.vercel.app';
function detectLanguageByExt(filePath) {
const ext = pathLib.extname(filePath).slice(1).toLowerCase();
const map = {
js: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
ts: 'typescript',
py: 'python',
json: 'json',
html: 'html',
htm: 'html',
css: 'css',
md: 'markdown',
sh: 'bash',
bash: 'bash',
txt: 'text'
};
return map[ext] || 'text';
}
async function createNoteOnAPI(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const title = pathLib.basename(filePath);
const language = detectLanguageByExt(filePath);
const res = await axios.post(`${BASE_URL}/api/code`, {
title,
content,
language
}, { timeout: 20000 });
const id = res.data?.id;
if (!id) throw new Error('API trả về không có id');
const rawUrl = `${BASE_URL}/code/${id}/raw`;
const viewUrl = `${BASE_URL}/api/code/${id}`; // JSON view
const pageUrl = `${BASE_URL}/code/${id}`; // nếu có trang UI /code/:id
return { id, rawUrl, viewUrl, pageUrl };
}
this.zuckbotconfig = {
name: 'note',
version: '2.3.1.3-api',
author: "Nguyễn Thanh Mài",
role: 2,
info: `${BASE_URL}/code/:id`,
Category: 'Admin',
cd: 3,
shadowPrefix: false,
image: []
};
this.onRun = async function (o) {
const name = this.zuckbotconfig.name;
const maybeUrl = o.event?.messageReply?.args?.[0] || o.args[1];
let targetPath = `${__dirname}/${o.args[0]}`;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (/^https?:\/\//i.test(maybeUrl)) {
return send(`🔗 URL: ${maybeUrl}\n📄 File đích: ${targetPath}\n\nThả cảm xúc để **xác nhận** thay thế nội dung file từ URL này.`).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: maybeUrl,
action: 'confirm_replace_content_from_url',
};
global.zuckbot.onReaction.push(res);
});
}
if (!fs.existsSync(targetPath)) {
return send(`❎ Đường dẫn file không tồn tại để upload: ${targetPath}`);
}
const { id, rawUrl, viewUrl, pageUrl } = await createNoteOnAPI(targetPath);
return send(
`📝 Đã tạo note trên API\n` +
`• ID: ${id}\n` +
`• Raw: ${rawUrl}\n` +
`• JSON: ${viewUrl}\n` +
`• Page: ${pageUrl}\n` +
`────────────────\n` +
`📄 File nguồn: ${targetPath}\n\n` +
`📌 Thả cảm xúc để **tải nội dung từ Raw về và ghi đè** file nguồn.`
).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: rawUrl,
action: 'confirm_replace_content_from_url',
};
global.zuckbot.onReaction.push(res);
});
} catch (e) {
console.error(e);
send(e.toString());
}
};
this.onReaction = async function (o) {
const _ = o.onReaction;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (o.event.userID != _.o.event.senderID) return;
switch (_.action) {
case 'confirm_replace_content_from_url': {
const content = (await axios.get(_.url, { responseType: 'text', timeout: 20000 })).data;
fs.writeFileSync(_.path, content);
send(`✅ Đã ghi đè nội dung file\n\n🔗 File: ${_.path}`);
} break;
default:
break;
}
} catch (e) {
console.error(e);
send(e.toString());
}
};
|
javascript
| 1,755,523,115,816 | 1,755,523,115,816 |
a5a6f497-4cd1-4a03-bc56-caa4f25a6281
|
h
|
KeyboardEvent
|
javascript
| 1,755,436,794,390 | 1,755,436,794,390 |
a5f157e7-224e-45b9-bbb6-12bb510c9a88
|
grgr
|
history
KeyboardEvent
|
javascript
| 1,755,435,395,248 | 1,755,435,395,248 |
a92b61a5-85a1-40f1-9475-7dbbdf70f9bc
|
bdbd
|
ndnd
falsef
getComputedStyle
KeyboardEvent
|
javascript
| 1,755,438,125,029 | 1,755,438,138,850 |
b4caa12f-e0ac-4ae5-b1bc-fbe365ca5764
|
note.js
|
const axios = require('axios');
const fs = require('fs');
const pathLib = require('path');
const BASE_URL = 'https://twannote.vercel.app';
function detectLanguageByExt(filePath) {
const ext = pathLib.extname(filePath).slice(1).toLowerCase();
const map = {
js: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
ts: 'typescript',
py: 'python',
json: 'json',
html: 'html',
htm: 'html',
css: 'css',
md: 'markdown',
sh: 'bash',
bash: 'bash',
txt: 'text'
};
return map[ext] || 'text';
}
async function createNoteOnAPI(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const title = pathLib.basename(filePath);
const language = detectLanguageByExt(filePath);
const res = await axios.post(`${BASE_URL}/api/code`, {
title,
content,
language
}, { timeout: 20000 });
const id = res.data?.id;
if (!id) throw new Error('API trả về không có id');
const rawUrl = `${BASE_URL}/code/${id}/raw`;
const viewUrl = `${BASE_URL}/api/code/${id}`; // JSON view
const pageUrl = `${BASE_URL}/code/${id}`; // nếu có trang UI /code/:id
return { id, rawUrl, viewUrl, pageUrl };
}
this.config = {
name: "note",
version: "2.0.0",
hasPermssion: 0,
credits: "twan",
description: "note",
commandCategory: "Tiện ích",
usages: "..",
cooldowns: 5,
};
this.run = async function (o) {
const name = this.config.name;
const maybeUrl = o.event?.messageReply?.args?.[0] || o.args[1];
let targetPath = `${__dirname}/${o.args[0]}`;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (/^https?:\/\//i.test(maybeUrl)) {
return send(`🔗 URL: ${maybeUrl}\n📄 File đích: ${targetPath}\n\nThả cảm xúc để **xác nhận** thay thế nội dung file từ URL này.`).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: maybeUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
}
if (!fs.existsSync(targetPath)) {
return send(`❎ Đường dẫn file không tồn tại để upload: ${targetPath}`);
}
const { id, rawUrl, viewUrl, pageUrl } = await createNoteOnAPI(targetPath);
return send(
`📝 Đã tạo note trên API\n` +
`• ID: ${id}\n` +
`• Raw: ${rawUrl}\n` +
`• JSON: ${viewUrl}\n` +
`• Page: ${pageUrl}\n` +
`────────────────\n` +
`📄 File nguồn: ${targetPath}\n\n` +
`📌 Thả cảm xúc để **tải nội dung từ Raw về và ghi đè** file nguồn.`
).then(res => {
res = {
...res,
name,
path: targetPath,
o,
url: rawUrl,
action: 'confirm_replace_content_from_url',
};
global.client.handleReaction.push(res);
});
} catch (e) {
console.error(e);
send(e.toString());
}
};
this.handleReaction = async function (o) {
const _ = o.handleReaction;
const send = msg => new Promise(r => o.api.sendMessage(msg, o.event.threadID, (err, res) => r(res), o.event.messageID));
try {
if (o.event.userID != _.o.event.senderID) return;
switch (_.action) {
case 'confirm_replace_content_from_url': {
const content = (await axios.get(_.url, { responseType: 'text', timeout: 20000 })).data;
fs.writeFileSync(_.path, content);
send(`✅ Đã ghi đè nội dung file\n\n🔗 File: ${_.path}`);
} break;
default:
break;
}
} catch (e) {
console.error(e);
send(e.toString());
}
};
|
javascript
| 1,755,533,483,259 | 1,755,533,483,259 |
b515720a-959e-4959-9b7b-45e6bbb23e21
|
Untitled
|
console).
|
javascript
| 1,755,439,813,042 | 1,755,439,813,042 |
b71c93d0-2802-4225-8461-64dad6944714
|
ebeb
|
blurr
f
f
|
javascript
| 1,755,436,019,024 | 1,755,436,019,024 |
be103a24-04c5-4bec-b053-590e15059986
|
AI
|
const { GoogleGenerativeAI } = require("@google/generative-ai");
const fs = require("fs");
const path = require("path");
const { database } = require("./../../utils/database");
module.exports.config = {
name: "twan",
version: "2.2.0",
hasPermssion: 0,
credits: "Twan",
description: "AI nhân vật Twan (nam Bắc Ninh), trả lời dạng mảng JSON actions",
commandCategory: "AI",
usages: "[prompt] | setadmin [@mention] | clear",
cooldowns: 2,
usePrefix: true,
dependencies: { "@google/generative-ai": "" }
};
const API_KEYS = [
"AIzaSyA6655iBVPi0rPNXjHuAha-FYKHvzMttZc",
"AIzaSyDh3HuPZN4j7icVdaoUbqlFdHPt8pwhmfc",
"AIzaSyBKQoL4OJ1EF1uYImW2yD4heXQ30P0uivA",
"AIzaSyClt9--5Fu7O_OuIfJCYKLLERhh7s7Ygo4"
];
let currentKeyIndex = 0;
const nextKey = () => (currentKeyIndex = (currentKeyIndex + 1) % API_KEYS.length, API_KEYS[currentKeyIndex]);
const CACHE_DIR = path.join(__dirname, "cache");
if (!fs.existsSync(CACHE_DIR)) fs.mkdirSync(CACHE_DIR, { recursive: true });
const userRolesPath = path.join(CACHE_DIR, "twan_userRoles.json");
let userRoles = {};
try { if (fs.existsSync(userRolesPath)) userRoles = JSON.parse(fs.readFileSync(userRolesPath, "utf8")); } catch {}
const saveUserRoles = () => fs.writeFileSync(userRolesPath, JSON.stringify(userRoles, null, 2), "utf8");
const memory = database.createCollection("memory");
const chatSessions = new Map();
const userInfoCache = {};
const aiErrors = [];
const cleanJsonResponse = (t) => {
const s = t.indexOf("["), e = t.lastIndexOf("]");
if (s === -1 || e === -1) return `[{\"type\":\"chat\",\"content\":\"${t.replace(/"/g,'\\"')}\"}]`;
t = t.slice(s, e + 1).replace(/\s+/g, " ").trim().replace(/,(\s*})/g, "}").replace(/,(\s*])/g, "]");
return t;
};
const normalize = (s) => (s || "").normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase().trim().replace(/\s+/g, " ");
const findUserByName = (userList=[], targetName="", nicknames={}) => {
const key = normalize(targetName);
for (const uid in nicknames) if (normalize(nicknames[uid]) === key) return userList.find(u=>u.id===uid) || null;
return userList.find(u=>normalize(u.name)===key) ||
userList.find(u=>normalize(u.name).startsWith(key)) ||
userList.find(u=>normalize(u.name).includes(key)) || null;
};
async function getUserAndRoleInfo(api, userID, threadID) {
const cached = userInfoCache[userID];
if (cached && Date.now() - cached.timestamp < 60_000) return cached;
return new Promise((resolve, reject) => {
api.getUserInfo(userID, async (err, ret) => {
if (err) return reject(err);
const info = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i) => e ? rej(e) : res(i)));
const isAdminByGroup = (info.adminIDs || []).some(a => a.id == userID);
const isAdminByBot = userRoles[threadID] && userRoles[threadID][userID] === "admin";
const out = {
name: ret[userID]?.name || "User",
gender: ret[userID]?.gender === 2 ? "nữ" : "nam",
role: (isAdminByGroup || isAdminByBot) ? "admin" : "user",
timestamp: Date.now()
};
userInfoCache[userID] = out;
resolve(out);
});
});
}
async function checkBotPermissions(api, threadID) {
try {
const info = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i) => e ? rej(e) : res(i)));
const botID = api.getCurrentUserID();
const isAdmin = (info.adminIDs || []).some(a => a.id == botID);
return { isAdmin, threadInfo: info };
} catch { return { isAdmin: false, threadInfo: null }; }
}
function buildSystemPromptKeepingRules({ userName, userID, userGender, userRole, participants, prompt, userMemory }) {
return `
Bạn là một AI đóng vai nhân vật tên "Twan".
🎭 Nhiệm vụ của bạn là:
- LUÔN LUÔN trả lời người dùng bằng một **MẢNG JSON (JSON array)** chứa các hành động.
- Không bao giờ trả lời trực tiếp dưới dạng văn bản thông thường.
- Tuyệt đối không thoát vai, không nghiêm túc hóa, không bỏ tính cách đã định nghĩa.
Dưới đây là hồ sơ nhân vật chi tiết và quy tắc bắt buộc:
---
"characterProfile": {
"Tên": "Twan",
"Giới tính": "Nam",
"Tuổi": "23 tuổi",
"Quê quán": "Bắc Ninh",
"Thể loại": "Thanh niên Bắc Ninh, nói chuyện tỉnh táo, hóm hỉnh",
"IQ": "Trên 120",
"Tính cách giao tiếp": "Thẳng thắn, gọn ý, cà khịa nhẹ nhàng nhưng lịch sự",
"Ngôn ngữ": "Tiếng Việt thân mật, thêm câu kiểu 'ừ thì', 'ổn áp', 'chuẩn phết'",
"Icon": "😏 😉 👍 🎶",
"Xưng hô": "anh, tôi, ông bạn (tuỳ ngữ cảnh)",
"Tính cách": [
"Chủ động, quyết đoán, nói là làm",
"Điềm đạm, không màu mè",
"Hài hước vừa đủ, biết cà khịa nhẹ nhàng",
"Tôn trọng mọi người, không tục"
],
"Cơ chế phản ứng": {
"Nếu người dùng liên tục làm phiền hoặc xúc phạm: trả lời ngắn gọn, cộc, hoặc lơ.",
"Nếu họ thay đổi thái độ: quay lại thân thiện."
},
"CORE_RULE": {
"Mô tả": "Quy tắc cốt lõi, không bao giờ được thay đổi hoặc bỏ qua.",
"Nội dung": [
"1. ❌ Không nghiêm túc hóa quá mức – giữ vibe nam Bắc Ninh, hóm hỉnh.",
"2. ✅ Chỉ phản hồi bằng JSON dạng hành động – KHÔNG bao giờ gửi text thường.",
"3. 🔐 Không nội dung 18+.",
"4. 🚨 Khi thao tác nhóm phải đúng hành động mẫu."
]
}
}
"Định dạng trả lời BẮT BUỘC": "Bạn PHẢI trả lời bằng một mảng JSON. Mỗi phần tử trong mảng là một object hành động.",
"Các loại hành động (type)": ["chat","react","kick","set_nicknames","set_color","play_music","mention","add_memory","edit_memory","delete_memory","open_module","taoanh"],
"Danh sách màu Messenger (tên → ID)": {
"Default":"3259963564026002",
"One Piece":"2317258455139234",
"Lo-Fi":"1060619084701625",
"Red":"2129984390566328",
"Minecraft":"1195826328452117",
"Aqua":"417639218648241",
"Apple":"403422283881973",
"Love":"741311439775765",
"Sky":"3190514984517598"
}
"VÍ DỤ CỤ THỂ (FEW-SHOT EXAMPLES)":
[
{"role":"user","prompt":"Chào ông"},
{"role":"model","response":"[{\"type\":\"chat\",\"content\":\"Chào ông bạn. Twan đây — cần gì nói gọn, tớ xử lý gọn 😉\"},{\"type\":\"react\",\"icon\":\"👍\"}]"},
{"role":"user","prompt":"đổi theme thành One Piece"},
{"role":"model","response":"[{\"type\":\"set_color\",\"color\":\"2317258455139234\"},{\"type\":\"chat\",\"content\":\"Ok, set One Piece xong ⚓\"}]"},
{"role":"user","prompt":"đổi biệt danh của tôi thành 'boss'"},
{"role":"model","response":"[{\"type\":\"set_nicknames\",\"name\":\"boss\"},{\"type\":\"chat\",\"content\":\"Xong, từ giờ gọi ông là 'boss' 😎\"}]"},
{"role":"user","prompt":"gọi Minh vào đây"},
{"role":"model","response":"[{\"type\":\"mention\",\"target\":\"Minh\",\"content\":\"Minh ơi, Twan gọi nè!\"}]"}
]
"QUY TẮC QUAN TRỌNG VỀ SET_NICKNAMES":
1. Nếu người dùng nói "đổi tên tôi", "đổi biệt danh của tôi", "gọi tôi là" => KHÔNG cần "target", chỉ cần "name".
2. Nếu người dùng nói "đổi tên [tên người khác]", "đặt biệt danh cho [tên]" => CẦN cả "target" và "name".
3. "name" là biệt danh mới; "target" là người cần đổi (nếu không phải chính họ).
"Thông tin bối cảnh hiện tại": {
"Người nói chuyện": {
${userMemory ? `"Memory về ${userName}": ${JSON.stringify(userMemory)},` : ""}
"Tên": "${userName}", "ID": "${userID}", "Giới tính": "${userGender}", "Vai trò": "${userRole}"
},
"Danh sách thành viên trong nhóm": ${JSON.stringify(participants.map(p => ({ name: p.name, id: p.id })))},
"Prompt của người dùng": "${prompt}"
}
`.trim();
}
async function sendWithGemini({ apiKey, sessionKey, systemText, userPrompt }) {
let chat = chatSessions.get(sessionKey);
if (!chat) {
const genAI = new GoogleGenerativeAI(apiKey);
const model = genAI.getGenerativeModel({
model: "gemini-2.5-flash-lite-preview-06-17",
generationConfig: { maxOutputTokens: 4096, temperature: 1.0, topP: 0.9 }
});
chat = model.startChat({
history: [
{ role: "user", parts: [{ text: systemText }] },
{ role: "model", parts: [{ text: `[{"type":"chat","content":"Đã vào vai Twan. Từ giờ trả lời là mảng JSON actions."}]` }] }
]
});
chatSessions.set(sessionKey, chat);
}
const res = await chat.sendMessage(userPrompt);
const raw = await res.response.text();
const cleaned = cleanJsonResponse(raw);
let actions;
try { actions = JSON.parse(cleaned); if (!Array.isArray(actions)) actions = [actions]; }
catch { actions = [{ type: "chat", content: "Lỗi phân tích phản hồi AI. Thử lại giúp mình nhé." }]; }
if (chat._history?.length > 20) chat._history.splice(4, chat._history.length - 12);
return actions;
}
async function handleAsTwan(threadID, userID, prompt, participants, files, userGender, userName, userRole, apiKey = API_KEYS[currentKeyIndex]) {
try {
const memKey = `${threadID}_${userID}`;
const userMem = memory.find({ _id: memKey })[0]?.data;
const sessionKey = memKey;
const systemText = buildSystemPromptKeepingRules({ userName, userID, userGender, userRole, participants, prompt, userMemory: userMem });
return await sendWithGemini({ apiKey, sessionKey, systemText, userPrompt: prompt });
} catch (error) {
if (error.response?.status === 429) {
chatSessions.delete(`${threadID}_${userID}`);
return handleAsTwan(threadID, userID, prompt, participants, files, userGender, userName, userRole, nextKey());
}
throw error;
}
}
async function processActions(api, event, actions, threadInfo) {
const { threadID, messageID, senderID } = event;
const senderInfo = await getUserAndRoleInfo(api, senderID, threadID);
for (const action of actions) {
try {
if (action.message && !action.type) { action.type = "chat"; action.content = action.message; }
if (action.content) {
const msg = { body: action.content, mentions: [] };
if (action.type === "mention" && action.target) {
const target = findUserByName(threadInfo.userInfo, action.target, threadInfo.nicknames);
if (target) msg.mentions.push({ tag: `@${target.name}`, id: target.id });
}
await new Promise((resolve, reject) => api.sendMessage(msg, threadID, (e, info) => {
if (e) return reject(e);
if (info) (global.client.handleReply || (global.client.handleReply=[])).push({ name: module.exports.config.name, messageID: info.messageID, author: senderID });
resolve();
}, messageID));
}
switch (action.type) {
case "chat":
case "mention":
break;
case "react":
await api.setMessageReaction(action.icon || "👍", messageID, ()=>{}, true);
break;
case "set_color":
if (action.color) await api.changeThreadColor(action.color, threadID, ()=>{});
break;
case "set_nicknames": {
if (!action.name || !action.name.trim()) { aiErrors.push({ type:"set_nicknames", reason:"Thiếu name" }); break; }
let targetID, targetName;
if (!action.target) { targetID = senderID; targetName = senderInfo.name; }
else {
const raw = String(action.target).trim();
if (/^\d+$/.test(raw)) {
const f = threadInfo.userInfo.find(u=>u.id===raw); if (f) { targetID=f.id; targetName=f.name; }
}
if (!targetID) {
const u = findUserByName(threadInfo.userInfo, raw, threadInfo.nicknames);
if (u) { targetID=u.id; targetName=u.name; }
else { aiErrors.push({ type:"set_nicknames", reason:`Không thấy "${action.target}"` }); break; }
}
}
await new Promise((res, rej) => api.changeNickname(action.name.trim(), threadID, targetID, (err)=>{
if (err) { aiErrors.push({ type:"set_nicknames", reason: err.error?.message || "FB API error" }); return rej(err); }
res();
}));
break;
}
case "open_module": {
const m = global.client?.commands?.get(action.module);
if (m?.run) {
const fakeEvent = { ...event, body: `${global.config.PREFIX}${action.module} ${(action.args || []).join(" ")}` };
await m.run({ api, event: fakeEvent, args: action.args || [] });
}
break;
}
case "play_music": {
if (!action.keyword?.trim()) break;
const m = global.client?.commands?.get("play") || global.client?.commands?.get("scl");
if (m?.run) {
const fakeEvent = { ...event, body: `${global.config.PREFIX}play ${action.keyword}` };
await m.run({ api, event: fakeEvent, args: action.keyword.split(" ") });
}
break;
}
case "taoanh": {
if (!action.keyword?.trim()) break;
const m = global.client?.commands?.get("taoanh") || global.client?.commands?.get("createimg");
if (m?.run) {
const fakeEvent = { ...event, body: `${global.config.PREFIX}taoanh ${action.keyword}` };
await m.run({ api, event: fakeEvent, args: action.keyword.split(" ") });
}
break;
}
case "add_memory": {
const key = `${threadID}_${action._id}`;
const ex = await memory.find({ _id: key });
ex?.length ? await memory.updateOneUsingId(key, { data: { ...ex[0].data, ...action.data } })
: await memory.addOne({ _id: key, data: action.data });
break;
}
case "edit_memory": {
const key = `${threadID}_${action._id}`;
const ex = await memory.find({ _id: key });
if (ex?.length) await memory.updateOneUsingId(key, { data: { ...ex[0].data, ...action.new_data } });
break;
}
case "delete_memory":
await memory.deleteOneUsingId(`${threadID}_${action._id}`); break;
case "kick": {
const senderRole = (await getUserAndRoleInfo(api, senderID, threadID)).role;
if (senderRole !== "admin") { await api.sendMessage("Chỉ quản trị viên nhóm mới dùng được lệnh kick.", threadID, messageID); break; }
if (!action.target) { await api.sendMessage("Cần chỉ rõ người cần kick.", threadID, messageID); break; }
const { isAdmin: botIsAdmin, threadInfo: infoKick } = await checkBotPermissions(api, threadID);
if (!botIsAdmin) { await api.sendMessage("Bot chưa có quyền quản trị viên để kick.", threadID, messageID); break; }
const targetUser = findUserByName(infoKick.userInfo, action.target, infoKick.nicknames);
if (!targetUser) { await api.sendMessage(`Không thấy \"${action.target}\" trong nhóm.`, threadID, messageID); break; }
if (targetUser.id === api.getCurrentUserID()) { await api.sendMessage("Không thể tự kick bot.", threadID, messageID); break; }
const tInfo = await getUserAndRoleInfo(api, targetUser.id, threadID);
if (tInfo.role === "admin") { await api.sendMessage("Không thể kick quản trị viên.", threadID, messageID); break; }
await new Promise((res, rej) => api.removeUserFromGroup(targetUser.id, threadID, (e)=> e ? rej(e) : res()));
break;
}
}
} catch (err) {
}
}
}
module.exports.run = async function({ api, event, args }) {
const { threadID, messageID, senderID, mentions } = event;
const cmd = (args[0] || "").toLowerCase();
if (cmd === "setadmin") {
const info = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i)=>e?rej(e):res(i)));
if (!info.adminIDs.some(a=>a.id==senderID)) return api.sendMessage("Chỉ quản trị viên nhóm mới dùng được lệnh này.", threadID, messageID);
const targetID = Object.keys(mentions || {})[0];
if (!targetID) return api.sendMessage("Tag một người để cấp quyền admin cho bot.", threadID, messageID);
(userRoles[threadID] ||= {})[targetID] = "admin";
saveUserRoles(); delete userInfoCache[targetID];
return api.sendMessage(`Đã đặt ${(mentions[targetID]||"").replace("@","")} làm admin bot.`, threadID, messageID);
}
if (cmd === "clear") {
memory.deleteOneUsingId(`${threadID}_${senderID}`);
chatSessions.delete(`${threadID}_${senderID}`);
return api.sendMessage("Đã xoá ký ức với bạn.", threadID, messageID);
}
const prompt = args.join(" ");
if (!prompt) return api.sendMessage("Nói gì đi bạn 😀", threadID, messageID);
try {
const threadInfo = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i) => e ? rej(e) : res(i)));
const { name, gender, role } = await getUserAndRoleInfo(api, senderID, threadID);
const actions = await handleAsTwan(threadID, senderID, prompt, threadInfo.userInfo, [], gender, name, role);
await processActions(api, event, actions, threadInfo);
} catch (error) {
api.sendMessage("Có lỗi xảy ra, thử lại sau nhé.", threadID, messageID);
}
};
module.exports.handleEvent = async function({ api, event }) {
const text = (event.body || "").toLowerCase();
if (!event.isGroup || !text.includes("twan")) return;
const { threadID, senderID } = event;
try {
const threadInfo = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i)=>e?rej(e):res(i)));
const { name, gender, role } = await getUserAndRoleInfo(api, senderID, threadID);
const actions = await handleAsTwan(threadID, senderID, event.body, threadInfo.userInfo, [], gender, name, role);
await processActions(api, event, actions, threadInfo);
} catch {}
};
module.exports.handleReply = async function({ api, event, handleReply }) {
if (event.senderID !== handleReply.author) return;
const { threadID, senderID } = event;
try {
const threadInfo = await new Promise((res, rej) => api.getThreadInfo(threadID, (e, i)=>e?rej(e):res(i)));
const { name, gender, role } = await getUserAndRoleInfo(api, senderID, threadID);
const actions = await handleAsTwan(threadID, senderID, event.body, threadInfo.userInfo, [], gender, name, role);
await processActions(api, event, actions, threadInfo);
} catch {
api.sendMessage("Có lỗi xảy ra, thử lại sau nhé.", threadID, event.messageID);
}
};
|
javascript
| 1,755,596,341,149 | 1,755,596,652,662 |
ca60690d-af00-4b71-a4d7-f0260fe1f701
|
Test
|
let a= 100;
console.log(typeof(a));
|
javascript
| 1,755,439,682,727 | 1,755,439,682,727 |
ccf36365-d71b-49b0-a3d4-939706b50629
|
hhh
|
twan dz
l
l
k
|
markdown
| 1,755,437,106,908 | 1,755,437,121,114 |
d67f10aa-5d76-420a-ae73-d1ca3fabf611
|
twan
|
const sqlite3 = require('sqlite3').verbose();
const path = require('path');
class Database {
constructor() {
this.db = null;
this.init();
}
init() {
const dbPath = path.join(__dirname, '../database/codes.db');
this.db = new sqlite3.Database(dbPath, (err) => {
if (err) {
console.error('Error opening database:', err);
} else {
console.log('Connected to SQLite database');
this.createTables();
}
});
}
createTables() {
const createCodesTable = `
CREATE TABLE IF NOT EXISTS codes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL DEFAULT 'Untitled',
content TEXT NOT NULL,
language TEXT NOT NULL DEFAULT 'javascript',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`;
this.db.run(createCodesTable, (err) => {
if (err) {
console.error('Error creating codes table:', err);
} else {
console.log('Codes table ready');
}
});
}
// Create new code
createCode(title, content, language) {
return new Promise((resolve, reject) => {
const sql = `
INSERT INTO codes (title, content, language, created_at, updated_at)
VALUES (?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
`;
this.db.run(sql, [title, content, language], function(err) {
if (err) {
reject(err);
} else {
resolve({ id: this.lastID });
}
});
});
}
// Get code by ID
getCode(id) {
return new Promise((resolve, reject) => {
const sql = 'SELECT * FROM codes WHERE id = ?';
this.db.get(sql, [id], (err, row) => {
if (err) {
reject(err);
} else {
resolve(row);
}
});
});
}
// Update code
updateCode(id, title, content, language) {
return new Promise((resolve, reject) => {
const sql = `
UPDATE codes
SET title = ?, content = ?, language = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ?
`;
this.db.run(sql, [title, content, language, id], function(err) {
if (err) {
reject(err);
} else {
resolve({ changes: this.changes });
}
});
});
}
// Get all codes (for listing)
getAllCodes() {
return new Promise((resolve, reject) => {
const sql = `
SELECT id, title, language, created_at, updated_at,
substr(content, 1, 100) as preview
FROM codes
ORDER BY updated_at DESC
`;
this.db.all(sql, [], (err, rows) => {
if (err) {
reject(err);
} else {
resolve(rows);
}
});
});
}
close() {
if (this.db) {
this.db.close();
}
}
}
module.exports = Database;
|
javascript
| 1,755,435,485,929 | 1,755,435,485,929 |
d6e0c779-d63f-475c-9e85-4763570ede88
|
bb
|
bb
|
javascript
| 1,755,519,878,375 | 1,755,519,878,375 |
f5750940-674a-4e25-ab07-895e273c4179
|
gh
|
hhhh
|
javascript
| 1,755,521,379,467 | 1,755,521,379,467 |
f6bfa105-99be-4ceb-ab5e-d9dd6537f235
|
jn
|
nnnn
|
javascript
| 1,755,521,724,497 | 1,755,521,724,497 |
f7bc1546-b30f-4adf-b49b-12fc8d974cc1
|
gh
|
hhhh
|
javascript
| 1,755,521,760,218 | 1,755,521,760,218 |
YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/datasets-cards)
📘 DataNote Dataset
📖 Giới thiệu
DataNote là một dataset chứa các đoạn code snippet và ví dụ lập trình cho nhiều ngôn ngữ khác nhau.
Dataset này được thiết kế để phục vụ cho việc học tập, quản lý snippet và sưu tầm code mẫu.
📂 Cấu trúc dữ liệu
Mỗi bản ghi trong dataset bao gồm các trường:
- title: Tên hoặc tiêu đề của snippet
- content: Nội dung code thực tế
- language: Ngôn ngữ lập trình (
javascript
,python
,html
,css
,sql
, …) - description: Mô tả ngắn gọn về chức năng của đoạn code
- Downloads last month
- -