mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-19 14:33:58 +00:00
feat: Add conclusion webhook support for final summary notifications (#355)
- Updated README.md to include new configuration options for conclusion webhook. - Enhanced BrowserFunc.ts with improved error handling during page reloads. - Implemented conclusionWebhook configuration in config.json. - Refactored Login.ts to use Playwright types and improved passkey handling. - Added safeClick method in SearchOnBing.ts to handle click timeouts and overlays. - Introduced account summary collection in index.ts for reporting. - Created ConclusionWebhook.ts to send structured summaries to a dedicated webhook. - Updated TypeScript definitions for better type safety across the project.
This commit is contained in:
32
src/util/ConclusionWebhook.ts
Normal file
32
src/util/ConclusionWebhook.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import { Config } from '../interface/Config'
|
||||
|
||||
interface ConclusionPayload {
|
||||
content?: string
|
||||
embeds?: any[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a final structured summary to the dedicated conclusion webhook (if enabled),
|
||||
* otherwise do nothing. Does NOT fallback to the normal logging webhook to avoid spam.
|
||||
*/
|
||||
export async function ConclusionWebhook(configData: Config, content: string, embed?: ConclusionPayload) {
|
||||
const webhook = configData.conclusionWebhook
|
||||
|
||||
if (!webhook || !webhook.enabled || webhook.url.length < 10) return
|
||||
|
||||
const body: ConclusionPayload = embed?.embeds ? { embeds: embed.embeds } : { content }
|
||||
if (content && !body.content && !body.embeds) body.content = content
|
||||
|
||||
const request = {
|
||||
method: 'POST',
|
||||
url: webhook.url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: body
|
||||
}
|
||||
|
||||
await axios(request).catch(() => { })
|
||||
}
|
||||
Reference in New Issue
Block a user