mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-10 18:36:17 +00:00
1.0.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "microsoft-rewards-script",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Automatically do tasks for Microsoft Rewards but in TS",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -6,5 +6,9 @@
|
||||
"searches": {
|
||||
"doMobile": true,
|
||||
"doDesktop": true
|
||||
},
|
||||
"webhook": {
|
||||
"enabled": true,
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,26 @@
|
||||
import { Webhook } from './Webhook'
|
||||
|
||||
export function log(title: string, message: string, type?: 'log' | 'warn' | 'error') {
|
||||
const currentTime = new Date().toISOString()
|
||||
|
||||
let str = ''
|
||||
|
||||
switch (type) {
|
||||
case 'warn':
|
||||
console.warn(`[${currentTime}] [WARN] [${title}] ${message}`)
|
||||
str = `[${currentTime}] [WARN] [${title}] ${message}`
|
||||
console.warn(str)
|
||||
break
|
||||
|
||||
case 'error':
|
||||
console.error(`[${currentTime}] [ERROR] [${title}] ${message}`)
|
||||
str = `[${currentTime}] [ERROR] [${title}] ${message}`
|
||||
console.error(str)
|
||||
break
|
||||
|
||||
default:
|
||||
console.log(`[${currentTime}] [LOG] [${title}] ${message}`)
|
||||
str = `[${currentTime}] [LOG] [${title}] ${message}`
|
||||
console.log(str)
|
||||
break
|
||||
}
|
||||
|
||||
if (str) Webhook(str)
|
||||
}
|
||||
21
src/util/Webhook.ts
Normal file
21
src/util/Webhook.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import { webhook } from '../config.json'
|
||||
|
||||
export async function Webhook(content: string) {
|
||||
if (!webhook.enabled) return
|
||||
if (webhook.url.length < 10) return
|
||||
|
||||
const request = {
|
||||
method: 'POST',
|
||||
url: webhook.url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
'content': content
|
||||
}
|
||||
}
|
||||
|
||||
await axios(request).catch(() => { })
|
||||
}
|
||||
Reference in New Issue
Block a user