(sock, chatId, message)
| 2 | const { channelInfo } = require('../lib/messageConfig'); |
| 3 | |
| 4 | async function characterCommand(sock, chatId, message) { |
| 5 | let userToAnalyze; |
| 6 | |
| 7 | // Check for mentioned users |
| 8 | if (message.message?.extendedTextMessage?.contextInfo?.mentionedJid?.length > 0) { |
| 9 | userToAnalyze = message.message.extendedTextMessage.contextInfo.mentionedJid[0]; |
| 10 | } |
| 11 | // Check for replied message |
| 12 | else if (message.message?.extendedTextMessage?.contextInfo?.participant) { |
| 13 | userToAnalyze = message.message.extendedTextMessage.contextInfo.participant; |
| 14 | } |
| 15 | |
| 16 | if (!userToAnalyze) { |
| 17 | await sock.sendMessage(chatId, { |
| 18 | text: 'Please mention someone or reply to their message to analyze their character!', |
| 19 | ...channelInfo |
| 20 | }); |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | try { |
| 25 | // Get user's profile picture |
| 26 | let profilePic; |
| 27 | try { |
| 28 | profilePic = await sock.profilePictureUrl(userToAnalyze, 'image'); |
| 29 | } catch { |
| 30 | profilePic = 'https://i.imgur.com/2wzGhpF.jpeg'; // Default image if no profile pic |
| 31 | } |
| 32 | |
| 33 | const traits = [ |
| 34 | "Intelligent", "Creative", "Determined", "Ambitious", "Caring", |
| 35 | "Charismatic", "Confident", "Empathetic", "Energetic", "Friendly", |
| 36 | "Generous", "Honest", "Humorous", "Imaginative", "Independent", |
| 37 | "Intuitive", "Kind", "Logical", "Loyal", "Optimistic", |
| 38 | "Passionate", "Patient", "Persistent", "Reliable", "Resourceful", |
| 39 | "Sincere", "Thoughtful", "Understanding", "Versatile", "Wise" |
| 40 | ]; |
| 41 | |
| 42 | // Get 3-5 random traits |
| 43 | const numTraits = Math.floor(Math.random() * 3) + 3; // Random number between 3 and 5 |
| 44 | const selectedTraits = []; |
| 45 | for (let i = 0; i < numTraits; i++) { |
| 46 | const randomTrait = traits[Math.floor(Math.random() * traits.length)]; |
| 47 | if (!selectedTraits.includes(randomTrait)) { |
| 48 | selectedTraits.push(randomTrait); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Calculate random percentages for each trait |
| 53 | const traitPercentages = selectedTraits.map(trait => { |
| 54 | const percentage = Math.floor(Math.random() * 41) + 60; // Random number between 60-100 |
| 55 | return `${trait}: ${percentage}%`; |
| 56 | }); |
| 57 | |
| 58 | // Create character analysis message |
| 59 | const analysis = `🔮 *Character Analysis* 🔮\n\n` + |
| 60 | `👤 *User:* ${userToAnalyze.split('@')[0]}\n\n` + |
| 61 | `✨ *Key Traits:*\n${traitPercentages.join('\n')}\n\n` + |
nothing calls this directly
no outgoing calls
no test coverage detected