Skip to content

Commit

Permalink
Fix mirai config.
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Mar 25, 2021
1 parent cc54e2c commit fda3267
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,30 @@ public class MiraiConfiguration {
val devInfo = simbotMiraiDeviceInfo(it.id, deviceInfoSeed)

if (deviceInfoOutput) {
kotlin.runCatching {
runCatching {
val devInfoJson = Json {
isLenient = true
ignoreUnknownKeys = true
prettyPrint = true
}.encodeToString(devInfo)
val outFile = File("simbot-devInfo.json")
if (!outFile.exists()) {
outFile.let { f ->
f.parentFile.mkdirs()
f.createNewFile()
outFile.apply {
parentFile?.mkdirs()
createNewFile()
}
}
FileWriter(outFile).use {
w -> w.write(devInfoJson)
logger.info("DevInfo write to ${outFile.canonicalPath}")
}
}.getOrElse { e -> logger.error("Write devInfo failed.", e) }
}.getOrElse { e ->
logger.error("Write devInfo failed: {}", e.localizedMessage)
if (!logger.isDebugEnabled) {
logger.error("Enable debug log for more information.")
}
logger.debug("Write devInfo failed.", e)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public fun Neko.toMiraiMessageContent(message: MessageChain?, cache: MiraiMessag
// 头像抖动
"nudge" -> {
val target = this["target"]
MiraiNudgedMessageContent(target?.toLong())
val from = this["from"]
MiraiNudgedMessageContent(from?.toLong(), target?.toLong())
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
package love.forte.test.listener

import love.forte.common.ioc.annotation.Beans
import love.forte.simbot.annotation.Filter
import love.forte.simbot.annotation.Filters
import love.forte.simbot.annotation.OnGroup
import love.forte.simbot.annotation.OnPrivate
import love.forte.simbot.api.sender.Sender
import love.forte.simbot.api.message.events.MessageGet

/**
* @author ForteScarlet
Expand All @@ -27,19 +26,24 @@ import love.forte.simbot.api.sender.Sender
class TestListener {


// @OnPrivate
// @Filters(Filter("share"))
// fun share(sender: Sender){
// val share1 = "[CAT:share,image=http://nhy-file-upload.test.upcdn.net/robot/img/%E6%AC%A2%E8%BF%8E.jpg,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
// val share2 = "[CAT:share,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
// val share3 = "[CAT:share,image=http://forte.love:15520/img/r,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
// sender.sendPrivateMsg(1149159218, share1)
// sender.sendPrivateMsg(1149159218, share2)
// sender.sendPrivateMsg(1149159218, share3)
// }

@OnGroup
@OnPrivate
@Filters(Filter("share"))
fun share(sender: Sender){
val share1 = "[CAT:share,image=http://nhy-file-upload.test.upcdn.net/robot/img/%E6%AC%A2%E8%BF%8E.jpg,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
val share2 = "[CAT:share,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
val share3 = "[CAT:share,image=http://forte.love:15520/img/r,title=抢红包啦,content=土豪来抢红包?,url=https://baidu.com]"
sender.sendPrivateMsg(1149159218, share1)
sender.sendPrivateMsg(1149159218, share2)
sender.sendPrivateMsg(1149159218, share3)
fun MessageGet.listen() {
println(msg)
}




}

0 comments on commit fda3267

Please sign in to comment.