Skip to content

Commit

Permalink
优化随机字符串逻辑,避免重复发送同一条消息
Browse files Browse the repository at this point in the history
  • Loading branch information
teble committed May 23, 2024
1 parent 8ba146b commit 8b4babb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.teble.xposed.autodaily.task.model

data class RandomEnv(
val values: List<String>
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import me.teble.xposed.autodaily.hook.function.proxy.FunctionPool.ticketManager
import me.teble.xposed.autodaily.hook.utils.QApplicationUtil.currentUin
import me.teble.xposed.autodaily.hook.utils.VersionUtil
import me.teble.xposed.autodaily.task.model.MiniProfile
import me.teble.xposed.autodaily.task.model.RandomEnv
import me.teble.xposed.autodaily.task.model.Task
import me.teble.xposed.autodaily.ui.enable
import me.teble.xposed.autodaily.utils.LogUtil
Expand Down Expand Up @@ -188,21 +189,21 @@ object EnvFormatUtil {
"skey" -> ticketManager.getSkey() ?: ""
"bkn" -> {
val skey = ticketManager.getSkey()
?: throw RuntimeException("获取skey失败")
?: error("获取skey失败")
CalculationUtil.getBkn(skey).toString()
}

"ps_tk" -> {
val pskey = ticketManager.getPskey(qDomain ?: "")
?: throw RuntimeException("获取pskey失败")
?: error("获取pskey失败")
CalculationUtil.getPsToken(pskey).toString()
}

"client_key" -> ticketManager.getStweb() ?: ""
"mini_nick" -> {
val miniProfile = (env["mini_profile"] ?: let {
val profile = miniProfileManager.syncGetProfile(env["mini_app_id"] as String)
?: throw RuntimeException("获取mini_profile失败")
?: error("获取mini_profile失败")
env["mini_profile"] = profile
profile
}) as MiniProfile
Expand All @@ -212,19 +213,23 @@ object EnvFormatUtil {
"mini_avatar" -> {
val miniProfile = (env["mini_profile"] ?: let {
val profile = miniProfileManager.syncGetProfile(env["mini_app_id"] as String)
?: throw RuntimeException("获取mini_profile失败")
?: error("获取mini_profile失败")
env["mini_profile"] = profile
profile
}) as MiniProfile
miniProfile.avatar
}

"mini_login_code" -> miniLoginManager.syncGetLoginCode(env["mini_app_id"] as String)
?: throw RuntimeException("获取mini_login_code失败")

else -> env[argName] ?: let {
LogUtil.w("没有找到对应的参数: $argName")
""
?: error("获取mini_login_code失败")

else -> {
val argValue = env[argName] ?: error("没有找到对应的参数: $argName")
if (argValue is RandomEnv) {
argValue.values.random()
} else {
argValue
}
}
}
return if (res is String && defaultValue != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import me.teble.xposed.autodaily.ksonpath.read
import me.teble.xposed.autodaily.task.cron.pattent.CronPattern
import me.teble.xposed.autodaily.task.cron.pattent.CronPatternUtil
import me.teble.xposed.autodaily.task.model.MsgExtract
import me.teble.xposed.autodaily.task.model.RandomEnv
import me.teble.xposed.autodaily.task.model.Task
import me.teble.xposed.autodaily.task.model.test
import me.teble.xposed.autodaily.task.request.ReqFactory
Expand Down Expand Up @@ -281,7 +282,7 @@ object TaskUtil {
}

"randString" -> {
env[it.name] = (confValue ?: it.default).split("|").random()
env[it.name] = RandomEnv((confValue ?: it.default).split("|"))
}

"list", "friend", "group" -> {
Expand Down

0 comments on commit 8b4babb

Please sign in to comment.