mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 17:56:15 +00:00
fix: Update package version to 2.56.12 and enhance webhook summary with detailed statistics
This commit is contained in:
@@ -19,7 +19,12 @@ export interface AccountResult {
|
||||
email: string
|
||||
pointsEarned: number
|
||||
runDuration: number
|
||||
initialPoints: number // Points avant l'exécution
|
||||
finalPoints: number // Points après l'exécution
|
||||
desktopPoints: number // Points gagnés sur Desktop
|
||||
mobilePoints: number // Points gagnés sur Mobile
|
||||
errors?: string[]
|
||||
banned?: boolean
|
||||
}
|
||||
|
||||
export interface SummaryData {
|
||||
@@ -41,10 +46,10 @@ export class SummaryReporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send comprehensive summary via webhook
|
||||
* Send comprehensive summary via webhook with complete statistics
|
||||
*/
|
||||
async sendWebhookSummary(summary: SummaryData): Promise<void> {
|
||||
if (!this.config.webhook?.enabled) {
|
||||
if (!this.config.webhook?.enabled && !this.config.conclusionWebhook?.enabled) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,40 +65,183 @@ export class SummaryReporter {
|
||||
? `${minutes}m ${seconds}s`
|
||||
: `${seconds}s`
|
||||
|
||||
let description = `╔════════════════════════════════════════╗\n`
|
||||
description += `║ Daily Run Summary ║\n`
|
||||
description += `╚════════════════════════════════════════╝\n\n`
|
||||
description += `⏱️ **Duration:** ${durationText}\n`
|
||||
description += `💰 **Total Points:** ${summary.totalPoints}\n`
|
||||
description += `✅ **Success Rate:** ${summary.successCount}/${summary.accounts.length} accounts\n\n`
|
||||
// Calculate global statistics
|
||||
const totalDesktop = summary.accounts.reduce((sum, acc) => sum + acc.desktopPoints, 0)
|
||||
const totalMobile = summary.accounts.reduce((sum, acc) => sum + acc.mobilePoints, 0)
|
||||
const totalInitial = summary.accounts.reduce((sum, acc) => sum + acc.initialPoints, 0)
|
||||
const totalFinal = summary.accounts.reduce((sum, acc) => sum + acc.finalPoints, 0)
|
||||
const bannedCount = summary.accounts.filter(acc => acc.banned).length
|
||||
|
||||
// Build structured embed description
|
||||
let description = `┌${'─'.repeat(48)}┐\n`
|
||||
description += `│ ${' '.repeat(10)}📊 EXECUTION SUMMARY${' '.repeat(11)}│\n`
|
||||
description += `└${'─'.repeat(48)}┘\n\n`
|
||||
|
||||
// Global Overview
|
||||
description += `**🌐 GLOBAL STATISTICS**\n`
|
||||
description += `┌${'─'.repeat(48)}┐\n`
|
||||
description += `│ ⏱️ Duration: \`${durationText}\`${' '.repeat(48 - 14 - durationText.length)}│\n`
|
||||
description += `│ 💰 Total Earned: **${summary.totalPoints}** points${' '.repeat(48 - 22 - String(summary.totalPoints).length)}│\n`
|
||||
description += `│ 🖥️ Desktop: **${totalDesktop}** pts | 📱 Mobile: **${totalMobile}** pts${' '.repeat(48 - 28 - String(totalDesktop).length - String(totalMobile).length)}│\n`
|
||||
description += `│ ✅ Success: ${summary.successCount}/${summary.accounts.length} accounts${' '.repeat(48 - 18 - String(summary.successCount).length - String(summary.accounts.length).length)}│\n`
|
||||
if (summary.failureCount > 0) {
|
||||
description += `│ ❌ Failed: ${summary.failureCount} accounts${' '.repeat(48 - 14 - String(summary.failureCount).length)}│\n`
|
||||
}
|
||||
if (bannedCount > 0) {
|
||||
description += `│ 🚫 Banned: ${bannedCount} accounts${' '.repeat(48 - 14 - String(bannedCount).length)}│\n`
|
||||
}
|
||||
description += `└${'─'.repeat(48)}┘\n\n`
|
||||
|
||||
// Account Details
|
||||
description += `**📄 ACCOUNT BREAKDOWN**\n\n`
|
||||
|
||||
const accountsWithErrors: AccountResult[] = []
|
||||
|
||||
// Add individual account results with better formatting
|
||||
description += `📊 **Detailed Results:**\n`
|
||||
description += `${'─'.repeat(45)}\n`
|
||||
for (const account of summary.accounts) {
|
||||
const status = account.errors?.length ? '❌' : '✅'
|
||||
const emailShort = account.email.length > 25 ? account.email.substring(0, 22) + '...' : account.email
|
||||
description += `${status} \`${emailShort}\`\n`
|
||||
description += ` 💎 Points: **${account.pointsEarned}** | ⏱️ Time: ${Math.round(account.runDuration / 1000)}s\n`
|
||||
const status = account.banned ? '🚫' : (account.errors?.length ? '❌' : '✅')
|
||||
const emailShort = account.email.length > 30 ? account.email.substring(0, 27) + '...' : account.email
|
||||
const durationSec = Math.round(account.runDuration / 1000)
|
||||
|
||||
if (account.errors?.length) {
|
||||
description += ` ⚠️ Error: *${account.errors[0]}*\n`
|
||||
description += `${status} **${emailShort}**\n`
|
||||
description += `┌${'─'.repeat(46)}┐\n`
|
||||
|
||||
// Points Earned Breakdown
|
||||
description += `│ 📊 Points Earned: **+${account.pointsEarned}** points${' '.repeat(46 - 23 - String(account.pointsEarned).length)}│\n`
|
||||
description += `│ └─ Desktop: **${account.desktopPoints}** pts${' '.repeat(46 - 20 - String(account.desktopPoints).length)}│\n`
|
||||
description += `│ └─ Mobile: **${account.mobilePoints}** pts${' '.repeat(46 - 19 - String(account.mobilePoints).length)}│\n`
|
||||
description += `├${'─'.repeat(46)}┤\n`
|
||||
|
||||
// Account Total Balance (formula)
|
||||
description += `│ 💳 Account Total Balance${' '.repeat(23)}│\n`
|
||||
description += `│ \`${account.initialPoints}\` + \`${account.pointsEarned}\` = **\`${account.finalPoints}\` pts**${' '.repeat(46 - 17 - String(account.initialPoints).length - String(account.pointsEarned).length - String(account.finalPoints).length)}│\n`
|
||||
description += `│ (Initial + Earned = Final)${' '.repeat(18)}│\n`
|
||||
description += `├${'─'.repeat(46)}┤\n`
|
||||
|
||||
// Duration
|
||||
description += `│ ⏱️ Duration: ${durationSec}s${' '.repeat(46 - 13 - String(durationSec).length)}│\n`
|
||||
|
||||
description += `└${'─'.repeat(46)}┘\n\n`
|
||||
|
||||
// Collect accounts with errors for separate webhook
|
||||
if ((account.errors?.length || account.banned) && account.email) {
|
||||
accountsWithErrors.push(account)
|
||||
}
|
||||
description += `\n`
|
||||
}
|
||||
|
||||
// Footer summary
|
||||
description += `┌${'─'.repeat(48)}┐\n`
|
||||
description += `│ 🌐 TOTAL ACROSS ALL ACCOUNTS${' '.repeat(22)}│\n`
|
||||
description += `├${'─'.repeat(48)}┤\n`
|
||||
description += `│ Initial Balance: \`${totalInitial}\` points${' '.repeat(48 - 25 - String(totalInitial).length)}│\n`
|
||||
description += `│ Final Balance: \`${totalFinal}\` points${' '.repeat(48 - 23 - String(totalFinal).length)}│\n`
|
||||
description += `│ Total Earned: **+${summary.totalPoints}** points${' '.repeat(48 - 23 - String(summary.totalPoints).length)}│\n`
|
||||
description += `└${'─'.repeat(48)}┘\n`
|
||||
|
||||
const color = bannedCount > 0 ? 0xFF0000 : summary.failureCount > 0 ? 0xFFAA00 : 0x00FF00
|
||||
|
||||
// Send main summary webhook
|
||||
await ConclusionWebhook(
|
||||
this.config,
|
||||
'📊 Daily Run Complete',
|
||||
'🎉 Daily Rewards Collection Complete',
|
||||
description,
|
||||
undefined,
|
||||
summary.failureCount > 0 ? 0xFF5555 : 0x00FF00
|
||||
color
|
||||
)
|
||||
|
||||
// Send separate error report if there are accounts with issues
|
||||
if (accountsWithErrors.length > 0) {
|
||||
await this.sendErrorReport(accountsWithErrors)
|
||||
}
|
||||
} catch (error) {
|
||||
log('main', 'SUMMARY', `Failed to send webhook: ${error instanceof Error ? error.message : String(error)}`, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send separate webhook for accounts with errors or bans
|
||||
*/
|
||||
private async sendErrorReport(accounts: AccountResult[]): Promise<void> {
|
||||
try {
|
||||
let errorDescription = `┌${'─'.repeat(48)}┐\n`
|
||||
errorDescription += `│ ${' '.repeat(10)}⚠️ ERROR REPORT${' '.repeat(16)}│\n`
|
||||
errorDescription += `└${'─'.repeat(48)}┘\n\n`
|
||||
|
||||
errorDescription += `**${accounts.length} account(s) encountered issues:**\n\n`
|
||||
|
||||
for (const account of accounts) {
|
||||
const status = account.banned ? '🚫 BANNED' : '❌ ERROR'
|
||||
const emailShort = account.email.length > 35 ? account.email.substring(0, 32) + '...' : account.email
|
||||
|
||||
errorDescription += `${status} | **${emailShort}**\n`
|
||||
errorDescription += `┌${'─'.repeat(46)}┐\n`
|
||||
|
||||
// Show what was attempted
|
||||
errorDescription += `│ 📊 Progress${' '.repeat(35)}│\n`
|
||||
errorDescription += `│ Desktop: ${account.desktopPoints} pts earned${' '.repeat(46 - 21 - String(account.desktopPoints).length)}│\n`
|
||||
errorDescription += `│ Mobile: ${account.mobilePoints} pts earned${' '.repeat(46 - 20 - String(account.mobilePoints).length)}│\n`
|
||||
errorDescription += `│ Total: ${account.pointsEarned} pts${' '.repeat(46 - 13 - String(account.pointsEarned).length)}│\n`
|
||||
errorDescription += `├${'─'.repeat(46)}┤\n`
|
||||
|
||||
// Error details
|
||||
if (account.banned) {
|
||||
errorDescription += `│ 🚫 Status: Account Banned/Suspended${' '.repeat(9)}│\n`
|
||||
if (account.errors?.length && account.errors[0]) {
|
||||
errorDescription += `│ 💬 Reason:${' '.repeat(36)}│\n`
|
||||
const lines = this.wrapText(account.errors[0], 42)
|
||||
for (const line of lines) {
|
||||
errorDescription += `│ ${line}${' '.repeat(46 - 3 - line.length)}│\n`
|
||||
}
|
||||
}
|
||||
} else if (account.errors?.length && account.errors[0]) {
|
||||
errorDescription += `│ ❌ Error Details:${' '.repeat(29)}│\n`
|
||||
const lines = this.wrapText(account.errors[0], 42)
|
||||
for (const line of lines) {
|
||||
errorDescription += `│ ${line}${' '.repeat(46 - 3 - line.length)}│\n`
|
||||
}
|
||||
}
|
||||
|
||||
errorDescription += `└${'─'.repeat(46)}┘\n\n`
|
||||
}
|
||||
|
||||
errorDescription += `**📋 Recommended Actions:**\n`
|
||||
errorDescription += `• Check account status manually\n`
|
||||
errorDescription += `• Review error messages above\n`
|
||||
errorDescription += `• Verify credentials if login failed\n`
|
||||
errorDescription += `• Consider proxy rotation if rate-limited\n`
|
||||
|
||||
await ConclusionWebhook(
|
||||
this.config,
|
||||
'⚠️ Execution Errors & Warnings',
|
||||
errorDescription,
|
||||
undefined,
|
||||
0xFF0000 // Red color for errors
|
||||
)
|
||||
} catch (error) {
|
||||
log('main', 'SUMMARY', `Failed to send error report webhook: ${error instanceof Error ? error.message : String(error)}`, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap text to fit within specified width
|
||||
*/
|
||||
private wrapText(text: string, maxWidth: number): string[] {
|
||||
const words = text.split(' ')
|
||||
const lines: string[] = []
|
||||
let currentLine = ''
|
||||
|
||||
for (const word of words) {
|
||||
if ((currentLine + word).length > maxWidth) {
|
||||
if (currentLine) lines.push(currentLine.trim())
|
||||
currentLine = word + ' '
|
||||
} else {
|
||||
currentLine += word + ' '
|
||||
}
|
||||
}
|
||||
|
||||
if (currentLine.trim()) lines.push(currentLine.trim())
|
||||
return lines
|
||||
}
|
||||
|
||||
/**
|
||||
* Send push notification via Ntfy
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user