MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handler

Function handler

plugins/sora.ts:11–49  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

9 usage: '.sora <prompt>',
10
11 async handler(sock: any, message: any, args: any, context: BotContext) {
12 const { chatId, channelInfo } = context;
13
14 try {
15 const quoted = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
16 const quotedText = quoted?.conversation || quoted?.extendedTextMessage?.text || '';
17 const input = args.join(' ') || quotedText;
18
19 if (!input) {
20 await sock.sendMessage(chatId, {
21 text: 'Provide a prompt. Example: .sora anime girl with short blue hair',
22 ...channelInfo
23 }, { quoted: message });
24 return;
25 }
26
27 const apiUrl = `https://okatsu-rolezapiiz.vercel.app/ai/txt2video?text=${encodeURIComponent(input)}`;
28 const { data } = await axios.get(apiUrl, { timeout: 60000, headers: { 'user-agent': 'Mozilla/5.0' } });
29
30 const videoUrl = data?.videoUrl || data?.result || data?.data?.videoUrl;
31 if (!videoUrl) {
32 throw new Error('No videoUrl in API response');
33 }
34
35 await sock.sendMessage(chatId, {
36 video: { url: videoUrl },
37 mimetype: 'video/mp4',
38 caption: `Prompt: ${input}`,
39 ...channelInfo
40 }, { quoted: message });
41
42 } catch(error: any) {
43 console.error('[SORA] error:', error?.message || error);
44 await sock.sendMessage(chatId, {
45 text: 'Failed to generate video. Try a different prompt later.',
46 ...channelInfo
47 }, { quoted: message });
48 }
49 }
50};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected