求助 求助0.0 #137
Answered
by
ForteScarlet
jiangdengke
asked this question in
Q&A
求助 求助0.0
#137
-
涉及的编程语言Java 涉及的组件库mirai (QQ) 疑问描述我这样写为啥收不到消息 package love.forte.demo.task;
import lombok.extern.slf4j.Slf4j;
import love.forte.di.annotation.Beans;
import love.forte.simbot.ID;
import love.forte.simbot.application.Application;
import love.forte.simbot.bot.Bot;
import love.forte.simbot.definition.Group;
import love.forte.simbot.message.MessagesBuilder;
import love.forte.simbot.timer.Cron;
import love.forte.simbot.timer.EnableTimeTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@EnableTimeTask
@Beans
@Component
public class MessageSendTask {
@Autowired
private Application application;
public static ID Id(String id) {
return ID.$(id.trim());
}
/**
* 每一分钟小时向群组发送信息
*/
@Cron(value = "0 0/1 * * * ?")
public void sendGroupInfo() {
Bot bot = application.getBotManagers().get(0).all().get(0);
ID groupId = Id("805646552");
Group group = bot.getGroup(groupId);
var message = new MessagesBuilder();
var text = message.text("加油").build();
group.sendBlocking(text);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ForteScarlet
Jun 4, 2023
Replies: 1 comment 1 reply
-
请直接使用 Spring Boot 所提供的 定时任务 能力。 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ForteScarlet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请直接使用 Spring Boot 所提供的 定时任务 能力。