update
This commit is contained in:
@@ -4,8 +4,9 @@ import xml2js from 'xml2js';
|
||||
import { useContextKey } from '@kevisual/context';
|
||||
import { Redis } from 'ioredis';
|
||||
import http from 'node:http';
|
||||
import { Wx, parseWxMessage } from './wx/index.ts';
|
||||
import { Wx, WxMsgEvent, parseWxMessage } from './wx/index.ts';
|
||||
import { config } from './modules/config.ts';
|
||||
import { loginByTicket } from './wx/login-by-ticket.ts';
|
||||
export const simpleRouter: SimpleRouter = await useContextKey('router');
|
||||
export const redis: Redis = await useContextKey('redis');
|
||||
|
||||
@@ -74,7 +75,13 @@ simpleRouter.post('/api/wxmsg', async (req: http.IncomingMessage, res: http.Serv
|
||||
const { fromusername, msgtype } = msg;
|
||||
res.end('')
|
||||
if (msgtype === 'event') {
|
||||
console.log('Received event message');
|
||||
const wxMsgEvent = msg as WxMsgEvent;
|
||||
if (wxMsgEvent.eventkey?.includes?.('login')) {
|
||||
await loginByTicket({
|
||||
ticket: wxMsgEvent.ticket!,
|
||||
openid: wxMsgEvent.fromusername,
|
||||
});
|
||||
}
|
||||
return
|
||||
}
|
||||
if (fromusername) {
|
||||
|
||||
Reference in New Issue
Block a user