
🦈드림 걸 Gemoy ~ Info AraBotz
June 16, 2025 at 02:36 AM
// plugins/ai-veo.js
import { GoogleGenerativeAI } from "@google/generative-ai";
import path from "path";
import fs from "fs";
import axios from "axios";
import { fileURLToPath } from "url";
import { tmpdir } from "os";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const apikey = 'AIzaSyBSv-dV0JapIEN5_7I540zktZnM5YbHpvs';
const handler = async (m, { text, command, conn }) => {
await conn.sendMessage(m.chat, { react: { text: "🎬", key: m.key } });
const args = text.trim();
if (!args) {
return m.reply("Please provide a video description prompt!\n\nExample: .veo A cat playing with a ball in a sunny garden");
}
const forbiddenWords = [
"ketik", "tulis", "addmoney", "addlimit", "pesan", "chat",
"tambah", "tambahkan", "function", "conn", "=>", "lib", "plugins", "rm -rf",
"$", "settings.js", "start.js", "package.json"
];
if (forbiddenWords.some(word => m.text.toLowerCase().includes(word))) {
return m.reply("gw gak sudi disuruh begitu 😏");
}
try {
// Send generating message
await conn.sendMessage(m.chat, {
text: "🎥 Generating video with Veo 2... This may take 1-2 minutes...",
contextInfo: {
externalAdReply: {
title: "Veo 2.0 AI",
body: "Video Generation in Progress",
thumbnailUrl: "https://files.catbox.moe/n4uvb4.bin",
sourceUrl: "https://google.com",
mediaType: 0,
renderLargerThumbnail: true,
}
}
});
// Use REST API approach for Veo 2 since it's not available through standard SDK
const requestBody = {
contents: [{
parts: [{
text: `Create a video based on this prompt: ${args}`
}]
}],
generationConfig: {
temperature: 0.7,
topK: 40,
topP: 0.95,
maxOutputTokens: 8192,
}
};
// Try different possible endpoints for Veo 2
const endpoints = [
`https://generativelanguage.googleapis.com/v1beta/models/veo-2:generateContent?key=${apikey}`,
`https://generativelanguage.googleapis.com/v1beta/models/veo-2.0-generate-001:generateContent?key=${apikey}`,
`https://generativelanguage.googleapis.com/v1/models/veo-2:generateContent?key=${apikey}`
];
let response = null;
let lastError = null;
for (const endpoint of endpoints) {
try {
const result = await axios.post(endpoint, requestBody, {
headers: {
'Content-Type': 'application/json',
},
timeout: 120000 // 2 minutes timeout
});
response = result.data;
break;
} catch (err) {
lastError = err;
console.log(`Failed endpoint ${endpoint}:`, err.response?.data || err.message);
continue;
}
}
if (!response) {
// If Veo 2 is not available, fall back to generating a placeholder response
throw new Error(`Veo 2 API not accessible: ${lastError?.response?.data?.error?.message || lastError?.message || 'Unknown error'}`);
}
// Process the response (this would contain video data in actual implementation)
if (response.candidates && response.candidates[0]) {
const candidate = response.candidates[0];
// In a real implementation, the response would contain video file data
// For now, we'll create a mock response since Veo might not be fully available
// Create a temporary video file path
const tempVideoFile = path.join(tmpdir(), `veo-video-${Date.now()}.mp4`);
// Since actual video generation might not be available,
// we'll inform the user about the status
await conn.sendMessage(m.chat, {
text: `🎬 *Veo 2 Video Generation Request*\n\n📝 *Prompt:* ${args}\n\n⚠️ *Note:* Veo 2 video generation is currently in limited preview. Your request has been processed but actual video generation may require:\n\n• Vertex AI access\n• Special API permissions\n• Allowlist approval\n\nTo access full Veo 2 capabilities:\n1. Use Google AI Studio directly\n2. Apply for Vertex AI access\n3. Check Google Cloud Console for video generation\n\n🔗 Visit: https://aistudio.google.com`,
contextInfo: {
externalAdReply: {
title: "Veo 2.0 AI",
body: "Video Generation Status",
thumbnailUrl: "https://files.catbox.moe/n4uvb4.bin",
sourceUrl: "https://aistudio.google.com",
mediaType: 0,
renderLargerThumbnail: true,
}
}
});
} else {
throw new Error("Invalid response format from Veo API");
}
} catch (err) {
console.error("Veo generation error:", err);
let errorMessage = "❌ Veo 2 video generation failed.\n\n";
if (err.message.includes("404") || err.message.includes("Not Found")) {
errorMessage += "🔍 *Issue:* Veo 2 model not found\n\n" +
"📋 *Possible Solutions:*\n" +
"• Veo 2 may require Vertex AI access\n" +
"• Model might be in limited preview\n" +
"• Try using Google AI Studio directly\n\n" +
"🔗 *Alternative:* https://aistudio.google.com";
} else if (err.message.includes("quota") || err.message.includes("limit")) {
errorMessage += "📊 API quota exceeded or rate limited";
} else if (err.message.includes("safety") || err.message.includes("policy")) {
errorMessage += "🛡️ Content violates safety policies";
} else if (err.message.includes("timeout")) {
errorMessage += "⏱️ Generation timed out";
} else {
errorMessage += `🔧 Technical error: ${err.message}`;
}
await conn.sendMessage(m.chat, {
text: errorMessage,
contextInfo: {
externalAdReply: {
title: "Veo 2.0 AI",
body: "Video Generation Failed",
thumbnailUrl: "https://files.catbox.moe/n4uvb4.bin",
sourceUrl: "https://google.com",
mediaType: 0,
renderLargerThumbnail: true,
}
}
});
return conn.sendMessage(m.chat, { react: { text: "🚫", key: m.key } });
}
};
handler.command = ["veo"];
handler.tags = ["ai"];
handler.help = ["veo - Generate video using Veo 3.0"];
handler.limit = true;
handler.premium = true; // Video generation should be premium feature
export default handler;