Last active
November 9, 2023 18:38
-
-
Save icy-r/7b2c6c3c2acee4e2ce48c2e03d4fde94 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const { getFilter, bot, setFilter, deleteFilter } = require('../lib') | |
| const fm = true | |
| bot( | |
| { | |
| pattern: 'gstop ?(.*)', | |
| fromMe: fm, | |
| desc: 'Delete gfilters in all group', | |
| type: 'autoReply', | |
| }, | |
| async (message, match) => { | |
| if (!match) return await message.send(`*Example : gstop hi*\n | |
| * Example : gstop all* \n | |
| * Example : gstop hi hello*`) | |
| const allmatch = match.split(' '); | |
| if (allmatch[0].toLowerCase() === 'all') | |
| { | |
| const filters = await getFilter('gfilter') | |
| if (!filters) | |
| return await message.send( | |
| `can't find any filter to delete \n | |
| _quitting..._` | |
| ) | |
| let all = ''; | |
| let msg = ''; | |
| filters.map(({ pattern }) => { | |
| msg += `${pattern},` | |
| }) | |
| all = msg.split(','); | |
| let deleted = ''; | |
| for(let i = 0; i < filters.length; i++) | |
| { | |
| const isDel = await deleteFilter('gfilter', all[i]) | |
| if (isDel) | |
| deleted += `${all[i]} ` | |
| } | |
| return await message.send(`${deleted} deleted.\n`) | |
| } | |
| else | |
| { | |
| const allmatch = match.split(','); | |
| let deleted = ''; | |
| let notfound = ''; | |
| for(let i = 0; i < allmatch.length; i++) | |
| { | |
| const isDel = await deleteFilter('gfilter', allmatch[i]) | |
| if (!isDel) | |
| notfound += `${allmatch[i]} ` | |
| else | |
| deleted += `${allmatch[i]} ` | |
| } | |
| return await message.send(`${deleted} deleted.\n ` + (notfound ? `${notfound} not found in gfilters.` : '')) | |
| } | |
| } | |
| ); | |
| bot( | |
| { | |
| pattern: 'pstop ?(.*)', | |
| fromMe: fm, | |
| desc: 'Delete pfilters in all chat', | |
| type: 'autoReply', | |
| }, | |
| async (message, match) => { | |
| if (!match) return await message.send(`*Example : pstop hi* \n | |
| * Example : pstop all* \n | |
| * Example : pstop hi hello*`) | |
| const allmatch = match.split(' '); | |
| if (allmatch[0].toLowerCase() === 'all') | |
| { | |
| const filters = await getFilter('pfilter') | |
| if (!filters) | |
| return await message.send( | |
| `can't find any filter to delete \n | |
| _quitting..._` | |
| ) | |
| let all = ''; | |
| let msg = ''; | |
| filters.map(({ pattern }) => { | |
| msg += `${pattern},` | |
| }) | |
| all = msg.split(','); | |
| let deleted = ''; | |
| for(let i = 0; i < filters.length; i++) | |
| { | |
| const isDel = await deleteFilter('pfilter', all[i]) | |
| if (isDel) | |
| deleted += `${all[i]} ` | |
| } | |
| return await message.send(`${deleted} deleted.\n`) | |
| } | |
| else | |
| { | |
| const allmatch = match.split(' '); | |
| let deleted = ''; | |
| let notfound = ''; | |
| for(let i = 0; i < allmatch.length; i++) | |
| { | |
| const isDel = await deleteFilter('pfilter', allmatch[i]) | |
| if (!isDel) | |
| notfound += `${allmatch[i]} ` | |
| else | |
| deleted += `${allmatch[i]} ` | |
| } | |
| return await message.send(`${deleted} deleted.\n ` + (notfound ? `${notfound} not found in pfilters.` : '')) | |
| } | |
| } | |
| ); | |
| bot( | |
| { | |
| pattern: 'pfilter ?(.*)', | |
| fromMe: fm, | |
| desc: 'pfilter in all chat', | |
| type: 'autoReply', | |
| }, | |
| async (message, match) => { | |
| if(!match) | |
| { | |
| const filters = await getFilter('pfilter') | |
| if (!filters) | |
| return await message.send( | |
| `_Not set any filter_\n | |
| *Example pfilter hi^hello* \n | |
| *Example pfilter hi^hello^hey!^hi there!* \n | |
| _note: use ^ to separate words_` | |
| ) | |
| let msg = '' | |
| filters.map(({ pattern }) => { | |
| msg += `=> ${pattern} \n` | |
| }) | |
| return await message.send(msg.trim()) | |
| } | |
| const allwords = match.split('^'); | |
| for(let i = 0; i < allwords.length; i = i + 2) | |
| { | |
| await setFilter( | |
| 'pfilter', | |
| allwords[i].trim(), | |
| allwords[i + 1].trim(), | |
| false | |
| ) | |
| } | |
| await message.send(`${match.split('^')} added to pfilters.`) | |
| } | |
| ); | |
| bot( | |
| { | |
| pattern: 'gfilter ?(.*)', | |
| fromMe: fm, | |
| desc: 'gfilter in all groups', | |
| type: 'autoReply', | |
| }, | |
| async (message, match) => { | |
| if(!match) | |
| { | |
| const filters = await getFilter('gfilter') | |
| if (!filters) | |
| return await message.send( | |
| `_Not set any filter_\n | |
| *Example gfilter hi^hello* \n | |
| *Example gfilter hi^hello^hey!^hi there!* \n | |
| _note: use ^ to separate words_` | |
| ) | |
| let msg = '' | |
| filters.map(({ pattern }) => { | |
| msg += `=> ${pattern} \n` | |
| }) | |
| return await message.send(msg.trim()) | |
| } | |
| const allwords = match.split('^'); | |
| for(let i = 0; i < allwords.length; i = i + 2) | |
| { | |
| await setFilter( | |
| 'gfilter', | |
| allwords[i].trim(), | |
| allwords[i + 1].trim(), | |
| false | |
| ) | |
| } | |
| await message.send(`${match.split('^')} added to gfilters.`) | |
| } | |
| ); | |
| bot( | |
| { | |
| on: 'text', | |
| fromMe: false, | |
| type: 'gfilter', | |
| onlyGroup: true, | |
| }, | |
| async (message, match) => { | |
| const filters = await getFilter('gfilter') | |
| if (filters) | |
| filters.map(async ({ pattern, regex, text }) => { | |
| pattern = new RegExp(`(?:^|\\W)${pattern}(?:$|\\W)`, 'i') | |
| if (pattern.test(message.text)) { | |
| await message.send(text, { | |
| quoted: message.data, | |
| }) | |
| } | |
| }) | |
| } | |
| ) | |
| bot( | |
| { | |
| on: 'text', | |
| fromMe: false, | |
| type: 'pfilter', | |
| }, | |
| async (message, match) => { | |
| if (!message.isGroup) { | |
| const filters = await getFilter('pfilter') | |
| if (filters) | |
| filters.map(async ({ pattern, regex, text }) => { | |
| pattern = new RegExp(`(?:^|\\W)${pattern}(?:$|\\W)`, 'i') | |
| if (pattern.test(message.text)) { | |
| await message.send(text, { | |
| quoted: message.data, | |
| }) | |
| } | |
| }) | |
| } | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment