mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-11 02:46:17 +00:00
1.0.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "microsoft-rewards-script",
|
"name": "microsoft-rewards-script",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "Automatically do tasks for Microsoft Rewards but in TS",
|
"description": "Automatically do tasks for Microsoft Rewards but in TS",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -6,5 +6,9 @@
|
|||||||
"searches": {
|
"searches": {
|
||||||
"doMobile": true,
|
"doMobile": true,
|
||||||
"doDesktop": 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') {
|
export function log(title: string, message: string, type?: 'log' | 'warn' | 'error') {
|
||||||
const currentTime = new Date().toISOString()
|
const currentTime = new Date().toISOString()
|
||||||
|
|
||||||
|
let str = ''
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'warn':
|
case 'warn':
|
||||||
console.warn(`[${currentTime}] [WARN] [${title}] ${message}`)
|
str = `[${currentTime}] [WARN] [${title}] ${message}`
|
||||||
|
console.warn(str)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'error':
|
case 'error':
|
||||||
console.error(`[${currentTime}] [ERROR] [${title}] ${message}`)
|
str = `[${currentTime}] [ERROR] [${title}] ${message}`
|
||||||
|
console.error(str)
|
||||||
break
|
break
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log(`[${currentTime}] [LOG] [${title}] ${message}`)
|
str = `[${currentTime}] [LOG] [${title}] ${message}`
|
||||||
|
console.log(str)
|
||||||
break
|
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