Skip to content

Commit

Permalink
Update greetings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
afnanplk authored Apr 16, 2022
1 parent 14d4f50 commit a9a28fd
Showing 1 changed file with 0 additions and 161 deletions.
161 changes: 0 additions & 161 deletions plugins/greetings.js
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)
}
}));
}
}

0 comments on commit a9a28fd

Please sign in to comment.