feat: add qq push
This commit is contained in:
parent
6c44e37ffe
commit
2a0115ea17
@ -15,3 +15,8 @@ MINIO_USE_SSL=false
|
||||
MINIO_ACCESS_KEY=your_access_key
|
||||
MINIO_SECRET_KEY=your_secret_key
|
||||
MINIO_BUCKET_NAME=winupdate
|
||||
|
||||
# QQ Bot URL
|
||||
QQ_BOT_URL=http://localhost:30000/send_private_msg
|
||||
# QQ Bot Target ID
|
||||
QQ_BOT_TARGET_ID=1234567890
|
||||
12
lib/push.ts
12
lib/push.ts
@ -1,8 +1,12 @@
|
||||
// Simple notification/logging function
|
||||
// In production, you might want to integrate with actual push notification service
|
||||
import { sendMsg } from "./push/qq";
|
||||
|
||||
export function push(message: string) {
|
||||
console.log(`[NOTIFICATION] ${new Date().toISOString()}: ${message}`)
|
||||
|
||||
// Here you could add actual push notification logic
|
||||
// For example, sending to webhook, email, or push notification service
|
||||
const msg = `[WinUpdate] ${new Date().toLocaleString()}\n${message}`;
|
||||
|
||||
if (process.env.QQ_BOT_URL && process.env.QQ_BOT_TARGET_ID) {
|
||||
sendMsg(msg, process.env.QQ_BOT_TARGET_ID, process.env.QQ_BOT_URL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
21
lib/push/qq.ts
Normal file
21
lib/push/qq.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export function sendMsg(msg: string, target_id: string, bot_url: string): Promise<Response> {
|
||||
const replyMessage = {
|
||||
user_id: String(target_id),
|
||||
message: [
|
||||
{
|
||||
type: "text",
|
||||
data: {
|
||||
text: msg
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return fetch(bot_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(replyMessage)
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user