ProtobufBot / pbbot-spring-boot-starter

QQ机器人的spring boot starter,推荐基于这个进行快速开发。本项目使用MIT协议,如果Client选择Mirai请使用AGPLv3协议。
MIT License
65 stars 16 forks source link

求助:如何取出机器人qq #3

Closed f1owkang closed 3 years ago

f1owkang commented 3 years ago

在实现定时任务时,需要主动发送消息如何构建Bot类型(java开发)

lz1998 commented 3 years ago

在实现定时任务时,需要主动发送消息如何构建Bot类型(java开发)

@Component
class A{

    @Autowired
    BotContainer botContainer;

    public void sendMsg(){
        long botId=123456789; // 需要指定使用哪个bot
        Map<Long, Bot> botMap=botContainer().getBots();
        Bot bot=botMap.get(botId);
        if(bot==null){return;} // 如果机器人未连接,可能是null
        bot.xxx()
    }
}
f1owkang commented 3 years ago

非常感谢!