From df4a1381591f897aac9a293e413fc4af1d865384 Mon Sep 17 00:00:00 2001 From: Wonder Date: Sat, 25 Oct 2025 21:09:05 +0800 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=94=84Update:=20=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E4=BA=8B=E4=BB=B6=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stardewvalley/lark/EventListener.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java b/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java index fae678f..2a72787 100644 --- a/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java +++ b/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java @@ -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();