Spaces:
Paused
Paused
File size: 2,725 Bytes
290c0c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import moment from 'moment-timezone';
import config from '../../config.cjs';
export default async function GroupParticipants(sock, { id, participants, action }) {
try {
const metadata = await sock.groupMetadata(id)
// participants
for (const jid of participants) {
// get profile picture user
let profile
try {
profile = await sock.profilePictureUrl(jid, "image")
} catch {
profile = "https://lh3.googleusercontent.com/proxy/esjjzRYoXlhgNYXqU8Gf_3lu6V-eONTnymkLzdwQ6F6z0MWAqIwIpqgq_lk4caRIZF_0Uqb5U8NWNrJcaeTuCjp7xZlpL48JDx-qzAXSTh00AVVqBoT7MJ0259pik9mnQ1LldFLfHZUGDGY=w1200-h630-p-k-no-nu"
}
// action
if (action == "add" && config.WELCOME ) {
const userName = jid.split("@")[0];
const joinTime = moment.tz('Asia/Kolkata').format('HH:mm:ss');
const joinDate = moment.tz('Asia/Kolkata').format('DD/MM/YYYY');
const membersCount = metadata.participants.length;
sock.sendMessage(id, {
text: `> Hello @${userName}! Welcome to *${metadata.subject}*.\n> You are the ${membersCount}th member.\n> Joined at: ${joinTime} on ${joinDate}
"`, contextInfo: {
mentionedJid: [jid],
externalAdReply: {
title: `Welcome`,
mediaType: 1,
previewType: 0,
renderLargerThumbnail: true,
thumbnailUrl: metadata.subject,
sourceUrl: 'https://sid-bhai.vercel.app'
}
}
})
} else if (action == "remove" && config.WELCOME ) {
const userName = jid.split('@')[0];
const leaveTime = moment.tz('Asia/Kolkata').format('HH:mm:ss');
const leaveDate = moment.tz('Asia/Kolkata').format('DD/MM/YYYY');
const membersCount = metadata.participants.length;
sock.sendMessage(id, {
text: `> Goodbye @${userName} from ${metadata.subject}.\n> We are now ${membersCount} in the group.\n> Left at: ${leaveTime} on ${leaveDate}"`, contextInfo: {
mentionedJid: [jid],
externalAdReply: {
title: `Leave`,
mediaType: 1,
previewType: 0,
renderLargerThumbnail: true,
thumbnailUrl: profile,
sourceUrl: 'https://sid-bhai.vercel.app'
}
}
})
}
}
} catch (e) {
throw e
}
} |