feat: add qq push

This commit is contained in:
feie9454 2025-06-28 20:34:33 +08:00
parent 6c44e37ffe
commit 2a0115ea17
3 changed files with 34 additions and 4 deletions

View File

@ -15,3 +15,8 @@ MINIO_USE_SSL=false
MINIO_ACCESS_KEY=your_access_key MINIO_ACCESS_KEY=your_access_key
MINIO_SECRET_KEY=your_secret_key MINIO_SECRET_KEY=your_secret_key
MINIO_BUCKET_NAME=winupdate 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

View File

@ -1,8 +1,12 @@
// Simple notification/logging function import { sendMsg } from "./push/qq";
// In production, you might want to integrate with actual push notification service
export function push(message: string) { export function push(message: string) {
console.log(`[NOTIFICATION] ${new Date().toISOString()}: ${message}`) console.log(`[NOTIFICATION] ${new Date().toISOString()}: ${message}`)
// Here you could add actual push notification logic const msg = `[WinUpdate] ${new Date().toLocaleString()}\n${message}`;
// For example, sending to webhook, email, or push notification service
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
View 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)
});
}