herramientas-dallE.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import fetch from 'node-fetch';
  2. import axios from 'axios';
  3. import * as cheerio from "cheerio"
  4. const handler = async (m, {conn, text, usedPrefix, command}) => {
  5. if (!text) throw `*⚠️ 𝐈𝐧𝐠𝐫𝐞𝐬𝐞 𝐮𝐧 𝐭𝐞𝐱𝐭𝐨 𝐩𝐚𝐫𝐚 𝐜𝐫𝐞𝐚𝐫 𝐮𝐧𝐚 𝐢𝐦𝐚𝐠𝐞𝐧 𝐲 𝐚𝐬𝐢 𝐮𝐬𝐚𝐫 𝐥𝐚 𝐟𝐮𝐧𝐜𝐢𝐨𝐧 𝐝𝐞 𝐝𝐚𝐥𝐥-𝐞*\n\n*• 𝐄𝐣𝐞𝐦𝐩𝐥𝐨:*\n*${usedPrefix + command} gatitos llorando*`;
  6. m.react('⌛')
  7. try {
  8. let response = await fetch(`https://api.dorratz.com/v3/ai-image?prompt=${text}`)
  9. let res = await response.json()
  10. if (res.data.status === "success") {
  11. const imageUrl = res.data.image_link;
  12. await conn.sendFile(m.chat, imageUrl, 'error.jpg', `_💫 Resutados: ${text}_\n\n> *✨ Imagen generada por IA ✨*`, m, null, fake);
  13. m.react('✅');
  14. }
  15. } catch {
  16. try {
  17. let answer = await flux(text)
  18. await conn.sendFile(m.chat, answer, 'error.jpg', `_💫 Resutados: ${text}_\n\n> *✨ Imagen generada por IA ✨*`, m, null, fake);
  19. //conn.sendMessage(m.chat, { image: { url: answer }, caption: `_💫 Resutados: ${text}_\n\n> *✨ Imagen generada por IA ✨*`, mentions: [m.sender],}, { quoted: m })
  20. m.react('✅');
  21. } catch {
  22. try {
  23. const url = `https://api.unsplash.com/search/photos?query=${encodeURIComponent(text)}&client_id=YuKJ2TeTdI2x92PLBA3a11kCEqxjrwVsGhrVRyLBEfU`;
  24. const response = await axios.get(url);
  25. if (response.data.results.length === 0) return m.react("❌")
  26. const imageUrl = response.data.results[0].urls.regular;
  27. await conn.sendFile(m.chat, imageUrl, 'error.jpg', `_*Resultado de:* ${text}_`, m, null, fake);
  28. m.react('✅');
  29. } catch {
  30. try {
  31. const url = `https://api.betabotz.eu.org/api/search/bing-img?text=${encodeURIComponent(text)}&apikey=7gBNbes8`;
  32. const response = await axios.get(url);
  33. if (!response.data.result || response.data.result.length === 0) return m.react("❌")
  34. const imageUrl = response.data.result[0];
  35. await conn.sendFile(m.chat, imageUrl, 'error.jpg', `_*Resultado de:* ${text}_`, m, null, fake);
  36. m.react('✅');
  37. } catch {
  38. try {
  39. const tiores1 = await fetch(`https://vihangayt.me/tools/imagine?q=${text}`);
  40. const json1 = await tiores1.json();
  41. await conn.sendFile(m.chat, json1.data, 'error.jpg', `_*Resultado de:* ${text}_`, m, null, fake);
  42. } catch {
  43. try {
  44. const tiores4 = await conn.getFile(`https://api.lolhuman.xyz/api/dall-e?apikey=${lolkeysapi}&text=${text}`);
  45. await conn.sendFile(m.chat, tiores4.data, 'error.jpg', `_*Resultado de:* ${text}_`, m, null, fake);
  46. m.react('✅')
  47. } catch (error) {
  48. console.log('[❗] Error, ninguna api funcional.\n' + error);
  49. m.reply(`error ${error}`)
  50. m.react('❌')
  51. }}}}}}}
  52. handler.help = ["dalle"]
  53. handler.tags = ["buscadores"]
  54. handler.command = ['dall-e', 'dalle', 'ia2', 'cimg', 'openai3', 'a-img', 'aimg', 'imagine'];
  55. handler.register = true
  56. handler.limit = 1
  57. export default handler;
  58. const flux = async (prompt) => {
  59. const url = `https://lusion.regem.in/access/flux.php?prompt=${encodeURIComponent(prompt)}`
  60. const headers = {
  61. Accept: "*/*",
  62. "User-Agent":
  63. "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, seperti Gecko) Chrome/129.0.0.0 Mobile Safari/537.36",
  64. Referer: "https://lusion.regem.in/?ref=taaft&utm_source=taaft&utm_medium=referral",
  65. }
  66. const response = await fetch(url, { headers })
  67. const html = await response.text()
  68. const $ = cheerio.load(html)
  69. return $("a.btn-navy.btn-sm.mt-2").attr("href") || null
  70. }
  71. const writer = async (input) => {
  72. const url = `https://ai-server.regem.in/api/index.php`
  73. const headers = {
  74. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  75. Accept: "*/*",
  76. "User-Agent":
  77. "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, seperti Gecko) Chrome/129.0.0.0 Mobile Safari/537.36",
  78. Referer: "https://regem.in/ai-writer/",
  79. }
  80. const formData = new URLSearchParams()
  81. formData.append("input", input)
  82. const response = await fetch(url, { method: "POST", headers, body: formData })
  83. return response.text()
  84. }
  85. const rephrase = async (input) => {
  86. const url = `https://ai-server.regem.in/api/rephrase.php`
  87. const headers = {
  88. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  89. Accept: "*/*",
  90. "User-Agent":
  91. "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, seperti Gecko) Chrome/129.0.0.0 Mobile Safari/537.36",
  92. Referer: "https://regem.in/ai-rephrase-tool/",
  93. }
  94. const formData = new URLSearchParams()
  95. formData.append("input", input)
  96. const response = await fetch(url, { method: "POST", headers, body: formData })
  97. return response.text()
  98. }