✨Feat: 实现菜单推送

This commit is contained in:
2025-10-26 16:07:38 +08:00
parent 2372b7ebae
commit dbee3a5b12
4 changed files with 34 additions and 2 deletions
@@ -5,7 +5,9 @@ import com.wonderland.stardewvalley.entity.game.Weather;
import com.wonderland.stardewvalley.util.lark.LarkUtil;
import com.wonderland.stardewvalley.util.weather.WeatherUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
@Component
public class WeatherHandle {
@Resource
@@ -4,7 +4,8 @@ import lombok.Getter;
@Getter
public enum CardTemplate {
CARD_TEMPLATE_WEATHER("AAqxas5etOJDx", "1.0.5");
CARD_TEMPLATE_WEATHER("AAqxas5etOJDx", "1.0.5"),
CARD_TEMPLATE_FRAM("AAqxaYo9rbXPa", "1.0.7");
private String cardId;
private String version;
@@ -0,0 +1,25 @@
package com.wonderland.stardewvalley.util.bean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext context;
public static <T> T getBean(Class<T> beanClass) {
return context.getBean(beanClass);
}
public static <T> T getBean(String name, Class<T> beanClass) {
return context.getBean(name, beanClass);
}
public static Object getBean(String name) {
return context.getBean(name);
}
@Override
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
context = appContext;
}
}
@@ -8,6 +8,8 @@ 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.common.constant.LarkConstant;
import com.wonderland.stardewvalley.handle.WeatherHandle;
import com.wonderland.stardewvalley.util.bean.SpringContextUtil;
public class EventListener {
@@ -33,7 +35,9 @@ public class EventListener {
String eventKey = event.getEvent().getEventKey();
if (eventKey.equals("weather")) {
// TODO 完善调用,发送天气卡片
}
WeatherHandle weatherHandle = SpringContextUtil.getBean(WeatherHandle.class);
weatherHandle.sendCard();
}
System.out.printf("[ onP2BotMenuV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
}