Commit 6c757017 authored by nanahira's avatar nanahira

fix

parent 7b59cf4c
...@@ -50,14 +50,14 @@ app.plugin(WeComBot, { ...@@ -50,14 +50,14 @@ app.plugin(WeComBot, {
encodingAESKey: 'encodingAESKey', // 加密密钥,在应用消息接收设置中设置并填入 encodingAESKey: 'encodingAESKey', // 加密密钥,在应用消息接收设置中设置并填入
}); });
app.on('wecom/location', (session) => { app.on('wecom/LOCATION', (session) => {
console.log( console.log(
`Got location for ${session.userId}: ${session.wecom.Longitude} ${session.wecom.Latitude}`, `Got location for ${session.userId}: ${session.wecom.Longitude} ${session.wecom.Latitude}`,
); );
}); });
app.on('wecom/enter-agent', (session) => { app.on('wecom/enter_agent', (session) => {
console.log(`Got enter-agent for ${session.userId}`); console.log(`Got enter_agent for ${session.userId}`);
}); });
app.on('wecom/click', (session) => { app.on('wecom/click', (session) => {
......
...@@ -51,15 +51,15 @@ declare global { ...@@ -51,15 +51,15 @@ declare global {
wecom?: WecomEventBody; wecom?: WecomEventBody;
} }
interface Events { interface Events {
'wecom/enter-agent': WecomEventFunction; 'wecom/enter_agent': WecomEventFunction;
'wecom/subscribe': WecomEventFunction; 'wecom/subscribe': WecomEventFunction;
'wecom/unsubscribe': WecomEventFunction; 'wecom/unsubscribe': WecomEventFunction;
'wecom/location': WecomEventFunction<{ 'wecom/LOCATION': WecomEventFunction<{
Latitude: number; Latitude: number;
Longitude: number; Longitude: number;
Precision: number; Precision: number;
}>; }>;
'wecom/batch-job-result': WecomEventFunction<{ 'wecom/batch_job_result': WecomEventFunction<{
BatchJob: { BatchJob: {
JobId: string; JobId: string;
JobType: string; JobType: string;
...@@ -69,12 +69,12 @@ declare global { ...@@ -69,12 +69,12 @@ declare global {
}>; }>;
'wecom/click': WecomEventFunction<EventKeyBody>; 'wecom/click': WecomEventFunction<EventKeyBody>;
'wecom/view': WecomEventFunction<EventKeyBody>; 'wecom/view': WecomEventFunction<EventKeyBody>;
'wecom/scancode-push': WecomEventFunction<ScanCodeEventBody>; 'wecom/scancode_push': WecomEventFunction<ScanCodeEventBody>;
'wecom/scancode-waitmsg': WecomEventFunction<ScanCodeEventBody>; 'wecom/scancode_waitmsg': WecomEventFunction<ScanCodeEventBody>;
'wecom/pic-sysphoto': WecomEventFunction<PhotoEventBody>; 'wecom/pic_sysphoto': WecomEventFunction<PhotoEventBody>;
'wecom/pic-photo-or-album': WecomEventFunction<PhotoEventBody>; 'wecom/pic_photo_or_album': WecomEventFunction<PhotoEventBody>;
'wecom/pic-weixin': WecomEventFunction<PhotoEventBody>; 'wecom/pic_weixin': WecomEventFunction<PhotoEventBody>;
'wecom/location-select': WecomEventFunction< 'wecom/location_select': WecomEventFunction<
EventKeyBody & { EventKeyBody & {
SendLocationInfo: { SendLocationInfo: {
Location_X: number; Location_X: number;
...@@ -85,18 +85,18 @@ declare global { ...@@ -85,18 +85,18 @@ declare global {
}; };
} }
>; >;
'wecom/share-agent-change': WecomEventFunction; 'wecom/share_agent_change': WecomEventFunction;
'wecom/share-chain-change': WecomEventFunction; 'wecom/share_chain_change': WecomEventFunction;
'wecom/template-card-event': WecomEventFunction< 'wecom/template_card_event': WecomEventFunction<
CardEvent & { CardEvent & {
SelectedItems: CardEventSelectedItems; SelectedItems: CardEventSelectedItems;
} }
>; >;
'wecom/template-card-menu-event': WecomEventFunction<CardEvent>; 'wecom/template_card_menu_event': WecomEventFunction<CardEvent>;
'wecom/open-approval-change': WecomEventFunction<{ 'wecom/open_approval_change': WecomEventFunction<{
ApprovalInfo: ApprovalInfo; ApprovalInfo: ApprovalInfo;
}>; }>;
'wecom/change-contact': WecomEventFunction<ChangeContact>; 'wecom/change_contact': WecomEventFunction<ChangeContact>;
} }
} }
} }
......
...@@ -39,6 +39,7 @@ export function adaptSession(bot: WeComBot, input: WecomEventResponse) { ...@@ -39,6 +39,7 @@ export function adaptSession(bot: WeComBot, input: WecomEventResponse) {
}; };
if (body.MsgType === 'event' && !body.Event.startsWith('template_card_')) { if (body.MsgType === 'event' && !body.Event.startsWith('template_card_')) {
session.type = `wecom/${body.Event.replace('LOCATION', 'location')}`; session.type = `wecom/${body.Event.replace('LOCATION', 'location')}`;
console.log(`Got event ${session.type}`);
} else { } else {
switch (body.MsgType) { switch (body.MsgType) {
case 'text': case 'text':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment