Advertisement
samiroexpikachu

Mage B2

Jul 1st, 2024
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2. const fontMap = {
  3.   ' ': ' ',
  4.   'a': '𝚊', 'b': 'πš‹', 'c': '𝚌', 'd': '𝚍', 'e': '𝚎', 'f': '𝚏', 'g': '𝚐', 'h': 'πš‘',
  5.   'i': 'πš’', 'j': 'πš“', 'k': 'πš”', 'l': 'πš•', 'm': 'πš–', 'n': 'πš—', 'o': '𝚘', 'p': 'πš™', 'q': '𝚚',
  6.   'r': 'πš›', 's': '𝚜', 't': '𝚝', 'u': '𝚞', 'v': '𝚟', 'w': '𝚠', 'x': '𝚑', 'y': '𝚒', 'z': '𝚣',
  7.   'A': '𝙰', 'B': '𝙱', 'C': '𝙲', 'D': '𝙳', 'E': '𝙴', 'F': '𝙡', 'G': '𝙢', 'H': '𝙷',
  8.   'I': '𝙸', 'J': '𝙹', 'K': '𝙺', 'L': '𝙻', 'M': '𝙼', 'N': '𝙽', 'O': '𝙾', 'P': '𝙿', 'Q': 'πš€',
  9.   'R': '𝚁', 'S': 'πš‚', 'T': 'πšƒ', 'U': 'πš„', 'V': 'πš…', 'W': 'πš†', 'X': 'πš‡', 'Y': '𝚈', 'Z': 'πš‰',
  10. };
  11.  
  12. function convertToFont(text) {
  13.   let convertedText = '';
  14.   for (let char of text) {
  15.     convertedText += fontMap[char] || char;
  16.   }
  17.   return convertedText;
  18. }
  19.  
  20.  
  21. module.exports = {
  22.   config: {
  23.     name: "magev2",
  24.     aliases: ["vexa"],
  25.     version: "1.0",
  26.     author: "Samir Ε’",
  27.     countDown: 5,
  28.     role: 0,
  29.     description: "anime image generator",
  30.     category: "π—”π—œ-π—šπ—˜π—‘π—˜π—₯π—”π—§π—˜π——",
  31.     guide: {
  32.       en: `πš‚πšƒπšˆπ™»π™΄πš‚\n━━━━━━━━━━━━━━━━━━━\nNone
  33. Professional
  34. Anime
  35. Ghibli
  36. Photographic
  37. Digital Art
  38. Comic Book
  39. Fantasy Art
  40. Analog Film
  41. Neonpunk
  42. Isometric
  43. Lowpoly
  44. Origami
  45. Line Art
  46. Craft Clay
  47. Cinematic
  48. 3D Model
  49. Pixel Art
  50. Texture`
  51.      
  52.     }
  53.   },
  54.  
  55.   onStart: async function ({ event, api, args }) {
  56.     let prompt = args.join(" ") || "cute girl ";
  57.     let aspectRatio = "1:1";
  58.     let style = 1;
  59.     let presets = 3;
  60.     const design = convertToFont(prompt)
  61.  
  62. const inputSentence = `${encodeURIComponent(prompt)}`;
  63.  
  64.  
  65.     args.forEach((arg, index) => {
  66.       switch (arg) {
  67.         case '--ar':
  68.           aspectRatio = args[index + 1];
  69.           break;
  70.         case '--style':
  71.           style = parseInt(args[index + 1]);
  72.           break;
  73.         case '--presets':
  74.           presets = parseInt(args[index + 1]);
  75.           break;
  76.       }
  77.     });
  78.  
  79.     const startTime = Date.now();
  80.     const processingMessage = await api.sendMessage("π™Ώπš›πš˜πšŒπšŽπšœπšœπš’πš—πš πšˆπš˜πšžπš› 𝚁𝚎𝚚𝚞𝚎𝚜𝚝... π™Ώπš•πšŽπšŠπšœπšŽ πš πšŠπš’πš...⏳", event.threadID);
  81.     try {
  82.       const apiUrl = `https://samirxpikachu.onrender.com/mageV2?prompt=${encodeURIComponent(inputSentence)}&style=${encodeURIComponent(style)}&aspect_ratio=${encodeURIComponent(aspectRatio)}`;
  83.       const imgurResponse = await axios.get(`${global.api.samirApi}/telegraph?url=${encodeURIComponent(apiUrl)}&senderId=${event.senderID}`);
  84.  
  85.       if (!imgurResponse.data.success) {
  86.         const errorMessage = imgurResponse.data.error;
  87.         if (errorMessage === 'Limit Exceeded') {
  88.           return api.sendMessage('π™»πš’πš–πš’πš 𝚎𝚑𝚌𝚎𝚎𝚍𝚎𝚍, πšπš›πš’ πšŠπšπšŠπš’πš— πšŠπšπšπšŽπš› 2 πš‘πš˜πšžπš›πšœ', event.threadID, event.messageID);
  89.         } else if (errorMessage === 'Access Forbidden') {
  90.           return api.sendMessage('𝚈𝚘𝚞 πšŠπš›πšŽ πš‹πšŠπš—πš—πšŽπš πš‹πš’ πš‚πšŠπš–πš’πš› Ε’', event.threadID, event.messageID);
  91.         }
  92.       }
  93.  
  94.       const imgurLink = imgurResponse.data.result.link;
  95.       const url = await global.utils.uploadImgbb(imgurLink);
  96. const pattern1 = /-\d+/;
  97. const pattern2 = /-\d+?-n-png-stp-dst-png-p\d+x\d+-nc-cat-\d+-ccb-\d+-\d+-nc-sid/;
  98. const filteredUrl = url.image.url.replace(pattern1, "").replace(pattern2, "");
  99.  
  100.     ;
  101.      
  102.       const endTime = Date.now();
  103.       const duration = (endTime - startTime) / 1000;
  104.  
  105.       await api.sendMessage({
  106.         body: `☘ π™Ώπš›πš˜πš–πš™πš: ${design}\n\n✨ π™»πš’πš—πš”: ${filteredUrl}\n\n⏰ π™Έπš–πšŠπšπšŽ πšπšŽπš—πšŽπš›πšŠπšπšŽπš πš’πš— ${duration} πšœπšŽπšŒπš˜πš—πšπšœ ⏳ `,
  107.         attachment: await global.utils.getStreamFromURL(imgurLink)
  108.       }, event.threadID);
  109.     } catch (error) {
  110.       console.error(error);
  111.       await api.sendMessage("π™΅πšŠπš’πš•πšŽπš 𝚝𝚘 πš›πšŽπšπš›πš’πšŽπšŸπšŽ πš’πš–πšŠπšπšŽ.", event.threadID);
  112.     } finally {
  113.       await api.unsendMessage(processingMessage.messageID);
  114.     }
  115.   }
  116. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement