Created
March 24, 2025 14:05
-
-
Save KOULIKS94/ed8b826b9b78dae7088d8d801f807697 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 { bot, isAdmin } = require('../lib'); | |
| let autoReviveGroups = {}; // Stores groups with auto-revive enabled | |
| let lastMessageTime = {}; // Tracks last message time | |
| const reviveMessages = [ | |
| "π₯ *Wake up everyone! This group needs some energy!*", | |
| "β‘ *Where is everyone? Drop a message now!*", | |
| "π *This group was silent for too long. Letβs chat!*", | |
| "π *Silent readers, it's time to talk!*", | |
| "π£ *Reviving the chat! Who's online?*" | |
| ]; | |
| // Enable or disable auto-revive | |
| bot( | |
| { | |
| pattern: 'autorevive', | |
| desc: 'Enable or disable auto-revive feature', | |
| type: 'group', | |
| }, | |
| async (message, match) => { | |
| if (!(await isAdmin(message))) { | |
| return await message.send('*You must be an admin to use this command!*'); | |
| } | |
| if (match.toLowerCase() === 'on') { | |
| autoReviveGroups[message.jid] = true; | |
| lastMessageTime[message.jid] = Date.now(); // Set initial time | |
| await message.send('β *Auto-Revive is now enabled!*'); | |
| } else if (match.toLowerCase() === 'off') { | |
| autoReviveGroups[message.jid] = false; | |
| await message.send('π« *Auto-Revive is now disabled!*'); | |
| } else { | |
| await message.send('*Usage: !autorevive on/off*'); | |
| } | |
| } | |
| ); | |
| // Track last message time | |
| bot( | |
| { | |
| on: 'message', | |
| }, | |
| async (message) => { | |
| if (message.jid && !message.fromMe) { | |
| lastMessageTime[message.jid] = Date.now(); | |
| } | |
| } | |
| ); | |
| // Auto-Revive Mechanism (Runs Every 6 Hours) | |
| setInterval(async () => { | |
| const currentTime = Date.now(); | |
| for (let groupJid in autoReviveGroups) { | |
| if (autoReviveGroups[groupJid]) { | |
| const lastActive = lastMessageTime[groupJid] || 0; | |
| const timeDiff = currentTime - lastActive; | |
| if (timeDiff > 6 * 60 * 60 * 1000) { // 6 hours | |
| const groupMetadata = await bot.client.groupMetadata(groupJid); | |
| const mentions = groupMetadata.participants.map((user) => user.id); | |
| const reviveMessage = reviveMessages[Math.floor(Math.random() * reviveMessages.length)]; | |
| await bot.client.sendMessage(groupJid, { text: `β‘ ${reviveMessage}`, mentions }); | |
| lastMessageTime[groupJid] = currentTime; // Reset timer | |
| } | |
| } | |
| } | |
| }, 10 * 60 * 1000); // Check every 10 minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment