Skip to content

Commit

Permalink
CQCode: support sending custom xml and json message
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Aug 5, 2020
1 parent 14723a6 commit 2630a93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
- 发送抖一抖 `[CQ:shake]`
- 发送各类戳一戳 `[CQ:poke,id=xxx,type=xxx]`,ID和Type见 `mirai``HummerMessage.kt`,必须在该文件中定义的id和type才能发送
- 接收`VipFace` `[CQ:vipface,id=xxx,name=xxx,count=xxx]`
- 发送 `Xml` 消息 `[CQ:xml,data=xxxx]`
- 发送 `Json` 消息 `[CQ:json,data=xxxx]`

## 酷Q API

Expand Down
10 changes: 4 additions & 6 deletions src/main/kotlin/org/itxtech/mirainative/MiraiNative.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object MiraiNative : PluginBase() {
var botOnline = false
val bot: Bot by lazy { Bot.botInstances.first() }

fun ByteArray.checksum() = BigInteger(1, MessageDigest.getInstance("MD5").digest(this))
private fun ByteArray.checksum() = BigInteger(1, MessageDigest.getInstance("MD5").digest(this))

private fun checkNativeLibs() {
logger.info("正在加载 ${dll.absolutePath}")
Expand All @@ -79,11 +79,9 @@ object MiraiNative : PluginBase() {
val cqp = FileOutputStream(dll)
getResources("CQP.dll")?.copyTo(cqp)
cqp.close()
} else {
if (getResources("CQP.dll")!!.readBytes().checksum() != dll.readBytes().checksum()) {
logger.warning("${dll.absolutePath} 与 Mirai Native 内置的 CQP.dll 的校验和不同。")
logger.warning("如运行时出现问题,请尝试删除 ${dll.absolutePath} 并重启 Mirai。")
}
} else if (getResources("CQP.dll")!!.readBytes().checksum() != dll.readBytes().checksum()) {
logger.warning("${dll.absolutePath} 与 Mirai Native 内置的 CQP.dll 的校验和不同。")
logger.warning("如运行时出现问题,请尝试删除 ${dll.absolutePath} 并重启 Mirai。")
}

initDataDir()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ object ChainCodeConverter {
}
return MSG_EMPTY
}
"xml" -> {
return XmlMessage(args["data"]!!)
}
"json" -> {
return JsonMessage(args["data"]!!)
}
else -> {
MiraiNative.logger.debug("不支持的 CQ码:${parts[0]}")
}
Expand Down

0 comments on commit 2630a93

Please sign in to comment.