remove mark

This commit is contained in:
2025-12-04 10:31:37 +08:00
parent 46aa293cce
commit 2a55f2d3ef
35 changed files with 1837 additions and 726 deletions

View File

@@ -0,0 +1,38 @@
import { Worker } from "bullmq";
import { redis } from './redis.ts';
import { Wx } from "../../src/wx";
const worker = new Worker('wxmsg', async job => {
const wx = new Wx({
appId: process.env.WX_APPID || '',
appSecret: process.env.WX_APPSECRET || '',
redis: redis
});
if (job.name === 'analyzeUserMsg') {
const { touser, msg } = job.data;
const accessToken = await wx.getAccessToken();
const sendData = {
touser,
msgtype: 'text',
text: {
content: 'Hello World' + new Date().toISOString(),
},
};
await wx.sendUserMessage(sendData);
} else {
throw new Error(`Unknown job name: ${job.name}`);
}
}, {
connection: redis
});
worker.on('completed', (job) => {
console.log(`Job ${job.id} has completed!`);
});
worker.on('failed', (job, err) => {
console.log(`Job ${job?.id} has failed with error ${err.message}`);
});
console.log('Worker is running...');