Skip to content

在哪儿配置机器人在线设备 #81

Answered by ForteScarlet
fhh-coder asked this question in Q&A
Discussion options

You must be logged in to vote

怎么修改simbot的登录显示?

bot使用的登录协议参考 mirai组件bot配置 中的 config.protocol

怎么动态注册BOT

动态登录可以获取到组件对应的BotManager 后使用特定的 register 注册。在mirai组件中,其类型为 MiraiBotManager,可以在 Application.botManagers 中迭代并寻找。

var managers = application.getBotManagers();

for(var manager : managers) {
   if(manager instanceof MiraiBotManager miraiBotManager) {
     MiraiBot bot = manager.register(...);
     bot.startBlocking(); // or startAsync
      // 或其他操作 ......
   }
}

其中,在SpringBoot环境中 Application 实例可以自动注入。

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@zhihui-Yu
Comment options

@ForteScarlet
Comment options

Answer selected by ForteScarlet
Comment options

You must be logged in to vote
1 reply
@ForteScarlet
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
组件:mirai 与mirai组件有关的内容
3 participants