-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
0 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1 @@ | ||
/* Copyright (C) 2020 Yusuf Usta. | ||
recodded by afnanplk | ||
new work type by afnanplk | ||
PINKY V2 | ||
*/ | ||
|
||
const MyPnky = require('../events'); | ||
const {MessageType} = require('@adiwajshing/baileys'); | ||
const sql = require('./sql/greetings'); | ||
const Config = require('../config'); | ||
|
||
|
||
const Language = require('../language'); | ||
const Lang = Language.getString('greetings'); | ||
if (Config.STANDPLK == 'off' || Config.STANDPLK == 'OFF') { | ||
if (Config.WORKTYPE == 'private') { | ||
|
||
MyPnky.addCommand({pattern: 'welcome$', fromMe: true, desc: Lang.WELCOME_DESC}, (async (message, match) => { | ||
var hg = await sql.getMessage(message.jid); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_WELCOME,MessageType.text); | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.WELCOME_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'welcome (.*)', fromMe: true, dontAddCommandList: true}, (async (message, match) => { | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_WELCOME_TEXT); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.WELCOME_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'welcome'); } | ||
await sql.setMessage(message.jid, 'welcome', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.WELCOME_SETTED,MessageType.text) | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye$', fromMe: true, desc: Lang.GOODBYE_DESC}, (async (message, match) => { | ||
var hg = await sql.getMessage(message.jid, 'goodbye'); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_GOODBYE,MessageType.text) | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.GOODBYE_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye (.*)', fromMe: true, dontAddCommandList: true}, (async (message, match) => { | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_GOODBYE_TEXT,MessageType.text); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.GOODBYE_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'goodbye'); } | ||
await sql.setMessage(message.jid, 'goodbye', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.GOODBYE_SETTED,MessageType.text) | ||
} | ||
})); | ||
} | ||
|
||
else if (Config.WORKTYPE == 'public') { | ||
|
||
|
||
MyPnky.addCommand({pattern: 'welcome$', fromMe: true, desc: Lang.WELCOME_DESC}, (async (message, match) => { | ||
var hg = await sql.getMessage(message.jid); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_WELCOME,MessageType.text); | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.WELCOME_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'welcome (.*)', fromMe: true, dontAddCommandList: true}, (async (message, match) => { | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_WELCOME_TEXT); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.WELCOME_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'welcome'); } | ||
await sql.setMessage(message.jid, 'welcome', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.WELCOME_SETTED,MessageType.text) | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye$', fromMe: true, desc: Lang.GOODBYE_DESC}, (async (message, match) => { | ||
var hg = await sql.getMessage(message.jid, 'goodbye'); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_GOODBYE,MessageType.text) | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.GOODBYE_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye (.*)', fromMe: true, dontAddCommandList: true}, (async (message, match) => { | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_GOODBYE_TEXT,MessageType.text); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.GOODBYE_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'goodbye'); } | ||
await sql.setMessage(message.jid, 'goodbye', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.GOODBYE_SETTED,MessageType.text) | ||
} | ||
})); | ||
} | ||
|
||
if (Config.WORKTYPE == 'admin') { | ||
|
||
async function checkUsAdmin(message, user = message.data.participant) { | ||
var grup = await message.client.groupMetadata(message.jid); | ||
var sonuc = grup['participants'].map((member) => { | ||
if (member.jid.split("@")[0] == user.split("@")[0] && member.isAdmin) return true; else; return false; | ||
}); | ||
return sonuc.includes(true); | ||
} | ||
async function checkImAdmin(message, user = message.client.user.jid) { | ||
var grup = await message.client.groupMetadata(message.jid); | ||
var sonuc = grup['participants'].map((member) => { | ||
if (member.jid.split("@")[0] == user.split("@")[0] && member.isAdmin) return true; else; return false; | ||
}); | ||
return sonuc.includes(true); | ||
} | ||
|
||
MyPnky.addCommand({pattern: 'welcome$', fromMe: false, desc: Lang.WELCOME_DESC}, (async (message, match) => { | ||
var us = await checkUsAdmin(message); | ||
if (!us) return await message.client.sendMessage(message.jid,Lang.PLKADMIN ,MessageType.text ,{quoted: message.data }); | ||
var hg = await sql.getMessage(message.jid); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_WELCOME,MessageType.text); | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.WELCOME_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'welcome (.*)', fromMe: false, dontAddCommandList: true}, (async (message, match) => { | ||
var us = await checkUsAdmin(message); | ||
if (!us) return await message.client.sendMessage(message.jid,Lang.PLKADMIN,MessageType.text ,{quoted: message.data }); | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_WELCOME_TEXT); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.WELCOME_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'welcome'); } | ||
await sql.setMessage(message.jid, 'welcome', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.WELCOME_SETTED,MessageType.text) | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye$', fromMe: false, desc: Lang.GOODBYE_DESC}, (async (message, match) => { | ||
var us = await checkUsAdmin(message); | ||
if (!us) return await message.client.sendMessage(message.jid,Lang.PLKADMIN,MessageType.text ,{quoted: message.data }); | ||
var hg = await sql.getMessage(message.jid, 'goodbye'); | ||
if (hg === false) { | ||
await message.client.sendMessage(message.jid,Lang.NOT_SET_GOODBYE,MessageType.text) | ||
} else { | ||
await message.client.sendMessage(message.jid,Lang.GOODBYE_ALREADY_SETTED + hg.message + '```',MessageType.text); | ||
} | ||
})); | ||
|
||
MyPnky.addCommand({pattern: 'goodbye (.*)', fromMe: false, dontAddCommandList: true}, (async (message, match) => { | ||
var us = await checkUsAdmin(message); | ||
if (!us) return await message.client.sendMessage(message.jid,Lang.PLKADMIN,MessageType.text ,{quoted: message.data }); | ||
if (match[1] === '') { | ||
return await message.client.sendMessage(message.jid,Lang.NEED_GOODBYE_TEXT,MessageType.text); | ||
} else { | ||
if (match[1] === 'delete') { await message.client.sendMessage(message.jid,Lang.GOODBYE_DELETED,MessageType.text); return await sql.deleteMessage(message.jid, 'goodbye'); } | ||
await sql.setMessage(message.jid, 'goodbye', match[1].replace(/#/g, '\n')); | ||
return await message.client.sendMessage(message.jid,Lang.GOODBYE_SETTED,MessageType.text) | ||
} | ||
})); | ||
} | ||
} |