Fix Sync message issue (#9)

This commit is contained in:
2022-10-03 23:16:31 +08:00
parent 781979f937
commit 3859236f43
2 changed files with 14 additions and 1 deletions

View File

@@ -138,6 +138,19 @@ object OpenCommandApi {
doRequest(host, json.encodeToString(VerifyRequest(token, code)))
}
/**
* 运行命令成功时返回命令执行结果失败时抛出异常异常详情参考doRequest描述
* @param host 服务器地址
* @param token 持久令牌
* @param command 命令行
* @return 命令执行结果
* @see doRequest
*/
suspend fun runCommand(host: String, token: String, command: String): String {
val ret = doRequest(host, json.encodeToString(CommandRequest(token, command)))
return if (ret.isNullOrEmpty()) "OK" else ret
}
/**
* 运行命令成功时返回命令执行结果失败时抛出异常异常详情参考doRequest描述
* 允许单次执行多条命令,用换行(\n)分隔