~ 如何设置工作目录
override fun onEnable() {
super.onEnable()
logger.info("sayBack onEnable")
val workingDir = File("data/com.greenhandzdl/")
val cacheDir = File("data/com.greenhandzdl/cache/")
init()//初始化配置文件
这样好像不太对
~如何创建目录
val file = File("data/插件名")
file.mkdirs()
提示special,飘红
~TBP函数相关问题
fun TBP(m: String) : String{
val json = JSONObject(File("data/TBP").readText())
//获取数据
val SecretId = json.getString("SecretId")
val SecretKey = json.getString("SecretKey")
val BotId = json.getString("BotId")
val BotEnv = json.getString("BotEnv")
val TerminalId = json.getString("TerminalId")
val requestBody = FormBody.Builder()
.add("SecretId", SecretId)
.add("SecretKey", SecretKey)
.add("BotId", BotId)
.add("BotEnv", BotEnv)
.add("TerminalId", TerminalId)
.add("InputText", m)
.build()
val request = Request.Builder()
.url("https://tbp.tencentcloudapi.com")
.post(requestBody)
.build()
val response = OkHttpClient().newCall(request).execute()
val responseData = response.body?.string()
//解析json
val jsonObject = JSONObject(responseData)
//提取json中的ResponseMessage并转为string
var responseMessage = jsonObject.getString("ResponseMessage")
if (responseMessage == "") {
responseMessage = "由于网络问题,暂时没找到答案!"
}
return responseMessage
}
相关问题项目:https://github.com/greenhandzdl/mirai-plugins-sayBack/blob/master/src/main/kotlin/SayBack.kt