Skip to content

Commit

Permalink
welkam and leave message
Browse files Browse the repository at this point in the history
  • Loading branch information
LoL-Human committed Mar 29, 2021
1 parent 1aee105 commit d8fab11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apikey": "",
"apikey": "63553daf381978ed68ff4951",
"prefix": "/",
"owner": "62895418200111"
}
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ async function starts() {
await lolhuman.connect({ timeoutMs: 30 * 1000 })
fs.writeFileSync('./lolhuman.json', JSON.stringify(lolhuman.base64EncodedAuthInfo(), null, '\t'))

lolhuman.on('group-participants-update', async(chat) => {
try {
mem = chat.participants[0]
try {
var pp_user = await lolhuman.getProfilePicture(mem)
} catch (e) {
var pp_user = 'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png?q=60'
}
if (chat.action == 'add') {
ini_user = lolhuman.contacts[mem]
ini_img = await getBuffer(`http://api.lolhuman.xyz/api/welcomeimage?apikey=${apikey}&img=${pp_user}&text=${ini_user.notify}`)
group_info = await lolhuman.groupMetadata(chat.jid)
welkam = `${ini_user.notify}, Welkam to ${group_info.subject}`
lolhuman.sendMessage(chat.jid, ini_img, MessageType.image, { caption: welkam })
}
if (chat.action == 'remove') {
ini_user = lolhuman.contacts[mem]
ini_out = `${ini_user.notify}, Sayonara 👋`
lolhuman.sendMessage(chat.jid, ini_out, MessageType.text)
}
} catch (e) {
console.log('Error :', e)
}
})

lolhuman.on('chat-update', async(lol) => {
try {
const time = moment.tz('Asia/Jakarta').format('HH:mm:ss')
Expand Down

0 comments on commit d8fab11

Please sign in to comment.