simbot-component-miyoushe-villa
0.2.0indexedExtends simbot3 with support for a specific API, offering low-level API access, bot creation, event subscription, and simplified API requests for bot-related functionalities.
Extends simbot3 with support for a specific API, offering low-level API access, bot creation, event subscription, and simplified API requests for bot-related functionalities.
Surfaced from shared tags and platforms — no rankings paid for.
此为 Simple Robot v3 (以下简称为 simbot3 )
下基于simbot标准API对 米游社 API 的组件支持。
[!CAUTION] 米游社大别野已经走向生命尽头。
公告原帖: 【公告】大别野聊天室下线说明

了解simbot3: simbot3官网
文档手册:https://simple-robot.github.io/simbot-component-miyoushe-villa/
[!note] 不论是 simbot API 本身还是其衍生项目(比如本项目)都会提供对 Java 的友好兼容。
[!note] API 模块基于 KMP 支持多平台,包括 JVM、JS(nodeJS)和 native。
api模块 尽可能保证对API的定义与使用"原汁原味",全面而不做过多封装,是一种 low-level 库。
以 "获取房间列表信息" 为例
// 准备一个请求API时需要填充到请求头中的信息
val token = MiyousheVillaApiToken(botId, botSecret, villaId)
// 准备一个 Ktor HttpClient
val client = HttpClient()
// 构建API,此API没有参数
val api = GetVillaGroupRoomListApi.create()
// 请求API,得到预期类型的结果。
val data = api.requestData(client, token)
println(data)
[!note] stdlib 模块基于 KMP 支持多平台,包括 JVM、JS(nodeJS)和 native。
标准库模块 基于 api模块,
提供针对 Bot 相关的基本功能实现,主要包括建立连接、事件订阅以及基于 Bot 对 api模块 中请求API的方式的简化等。
// bot 的一些信息,比如id等。
val ticket = Bot.Ticket(botId, botSecret)
// 构建一个 bot,并可选的修改一些配置
bot = BotFactory.create(ticket) {
loginVillaId = villaId
}
bot.registerProcessor { source ->
println()
}
bot.processEvent<SendMessage> { source ->
content = extendData.content
msgContentInfo = bot.apiDecoder.decodeFromString<MsgContentInfo<TextMsgContent>>(content)
println(msgContentInfo)
( msgContentInfo.content.text) {
bot.cancel()
}
}
bot.start()
bot.join()
以 "获取房间列表信息" 为例
// 假设你构建了一个 Bot
val bot = ...
// 准备一个API
val api = GetVillaGroupRoomListApi.create()
// 直接通过 bot 请求API,并给它一个当前的大别野id
val data = api.requestDataBy(bot, villaId)
println(data)
[!warning] TODO 尚未完成。可参考 simbot3 走马观花 中的API风格。
simbot-component-miyoushe 使用 LGPLv3 许可证开源。
This program free software: you can redistribute it / modify it under the terms
the GNU Lesser General License published the Free Software Foundation, either
version the License, (at your ) any later version.
This program distributed the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty MERCHANTABILITY FITNESS A PARTICULAR PURPOSE.
See the GNU Lesser General License more details.
You should have received a copy the GNU Lesser General License along this
program. , see <https://www.gnu.org/licenses/>.