🔄Update: 点击菜单事件监听

This commit is contained in:
2025-10-25 21:09:05 +08:00
parent c50c876a53
commit df4a138159
@@ -1,16 +1,14 @@
package com.wonderland.stardewvalley.lark;
import com.lark.oapi.core.request.EventReq;
import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.event.CustomEventHandler;
import com.lark.oapi.event.EventDispatcher;
import com.lark.oapi.service.application.ApplicationService;
import com.lark.oapi.service.application.v6.model.P2BotMenuV6;
import com.lark.oapi.service.im.ImService;
import com.lark.oapi.service.im.v1.model.P2MessageReceiveV1;
import com.lark.oapi.ws.Client;
import com.wonderland.stardewvalley.constant.LarkConstant;
import java.nio.charset.StandardCharsets;
public class EventListener {
// onP2MessageReceiveV1 为接收消息 v2.0;onCustomizedEvent 内的 message 为接收消息 v1.0。
@@ -21,10 +19,18 @@ public class EventListener {
System.out.printf("[ onP2MessageReceiveV1 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
}
})
.onCustomizedEvent("p2p_chat_create", new CustomEventHandler() {
// 首次使用应用
// .onCustomizedEvent("p2p_chat_create", new CustomEventHandler() {
// @Override
// public void handle(EventReq event) throws Exception {
// System.out.printf("[ onCustomizedEvent access ], type: message, data: %s\n", new String(event.getBody(), StandardCharsets.UTF_8));
// }
// })
// 菜单交互
.onP2BotMenuV6(new ApplicationService.P2BotMenuV6Handler() {
@Override
public void handle(EventReq event) throws Exception {
System.out.printf("[ onCustomizedEvent access ], type: message, data: %s\n", new String(event.getBody(), StandardCharsets.UTF_8));
public void handle(P2BotMenuV6 event) throws Exception {
System.out.printf("[ onP2BotMenuV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
}
})
.build();