this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add startup notification for owner and auto-update restart flag handling

+41
+32
index.js
··· 35 35 console.log('Discord webhook integration enabled'); 36 36 } 37 37 38 + // Send startup notification to owner (unless this is an auto-update restart) 39 + const sendStartupNotification = async () => { 40 + const fs = require('fs-extra'); 41 + const path = require('path'); 42 + const config = require('./config'); 43 + const flagFile = path.join(__dirname, '.auto-update-restart'); 44 + 45 + try { 46 + // Check if auto-update flag exists 47 + const flagExists = await fs.pathExists(flagFile); 48 + 49 + if (flagExists) { 50 + // Delete the flag and skip notification 51 + await fs.remove(flagFile); 52 + console.log('Auto-update restart detected, skipping startup notification'); 53 + return; 54 + } 55 + 56 + // Send startup notification to owner 57 + if (config.ownerId) { 58 + const startupMessage = '✅ Bot has started successfully!'; 59 + await telegramBot.bot.sendMessage(config.ownerId, startupMessage); 60 + console.log('Startup notification sent to owner'); 61 + } 62 + } catch (error) { 63 + console.error('Error handling startup notification:', error); 64 + } 65 + }; 66 + 67 + // Delay startup notification to ensure bot is fully initialized 68 + setTimeout(sendStartupNotification, 2000); 69 + 38 70 // Start the scheduler with both posting services 39 71 const postFunctions = { 40 72 telegram: telegramBot.postMedia.bind(telegramBot),
+9
utils/updater.js
··· 5 5 const { exec } = require('child_process'); 6 6 const { promisify } = require('util'); 7 7 const execAsync = promisify(exec); 8 + const fs = require('fs-extra'); 9 + const path = require('path'); 8 10 9 11 class Updater { 10 12 constructor() { ··· 95 97 const queueManager = require('../queue/queueManager'); 96 98 await queueManager.saveQueueToDisk(); 97 99 console.log('Queue saved before restart'); 100 + 101 + // Create flag file to indicate this is an auto-update restart 102 + const fs = require('fs-extra'); 103 + const path = require('path'); 104 + const flagFile = path.join(__dirname, '..', '.auto-update-restart'); 105 + await fs.writeFile(flagFile, Date.now().toString()); 106 + console.log('Auto-update flag set'); 98 107 99 108 await execAsync('pm2 restart --update-env stagehand'); 100 109 console.log('Bot restarted successfully');