diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 3cb0c3f..c7d8a39 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -6,7 +6,7 @@ labels: bug --- 警告: 在进一步操作之前,请检查下列选项。如果您忽视此模板或者没有提供关键信息,您的 Issue 将直接被关闭 -- 确保您使用的是 [最新开发版本](https://github.com/whitechi73/Shamrock/actions/workflows/build-apk.yml) 的 Shamrock. +- 确保您使用的是 [最新开发版本](https://github.com/whitechi73/OpenShamrock/actions/workflows/build-apk.yml) 的 Shamrock. - 确保您的问题尚未在 Issues 列表中提出. - 确保您的问题不是由于您的代码错误导致的. @@ -22,5 +22,6 @@ labels: bug - Shamrock 版本: - Android 版本: +- LSPosed 框架版本: - 设备的制造商和型号: - 设备的 CPU 架构: diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md index 750ca6a..eb2268d 100644 --- a/.github/ISSUE_TEMPLATE/feature.md +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -7,7 +7,7 @@ labels: enhancement 警告: 在进一步操作之前,请检查下列选项。如果您忽视此模板或者没有提供关键信息,您的 Issue 将直接被关闭 -- 确保您使用的是 [最新开发版本](https://github.com/whitechi73/Shamrock/actions/workflows/build-apk.yml) 的 Shamrock. +- 确保您使用的是 [最新开发版本](https://github.com/whitechi73/OpenShamrock/actions/workflows/build-apk.yml) 的 Shamrock. - 确保您的功能请求尚未在 Issues 列表中提出. - 确保您的功能请求是与 Shamrock 相关的,且可以实现. diff --git a/README.md b/README.md index a86d9b4..f113396 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ![][onebot-12] [![][license]](LICENSE) -[下载][download-link] | [部署][deploy-link] | [接口][api-link] | [文档][docs-link] | [加群][group-link] +[下载][download-link] | [部署][deploy-link] | [接口][api-link] | [文档][docs-link] @@ -29,8 +29,6 @@ - 一键移植:本项目基于 go-cqhttp 的文档进行开发实现。 - 平行部署:可多平台部署,未来将会支持 Docker 部署的教程。 -> 若您追求小而轻便的Bot服务, [Chronocat](https://chronocat.vercel.app/)是您的不二之选。 - ## 权限声明 > 如出现未在此处声明的权限,请警惕 Shamrock 是否被修改/植入恶意代码 @@ -45,7 +43,7 @@ ## 贡献说明 - **我可爱吗?欢迎你的到来,这里是一个很大的地方,有着无限可能,主要是有你啦!** +Shamrock **我可爱吗?欢迎你的到来,这里是一个很大的地方,有着无限可能,主要是有你啦!** ## 开源协议 @@ -96,9 +94,7 @@ along with this program. If not, see . [docs-link]: https://whitechi73.github.io/OpenShamrock/ -[group-link]: https://whitechi73.github.io/OpenShamrock/group.html - -[hook-system]: https://github.com/whitechi73/OpenShamrock/wiki/perm_hook_android +[hook-system]: https://github.com/whitechi73/OpenShamrock/blob/master/xposed/src/main/java/moe/fuqiuluo/shamrock/xposed/loader/FuckAMS.kt [voice-support]: https://whitechi73.github.io/OpenShamrock/advanced/voice.html diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/LogCenter.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/LogCenter.kt index fba61fa..55e8dbc 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/LogCenter.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/LogCenter.kt @@ -13,6 +13,7 @@ import moe.fuqiuluo.shamrock.utils.FileUtils import moe.fuqiuluo.shamrock.xposed.actions.toast import moe.fuqiuluo.shamrock.xposed.helper.internal.DataRequester import mqq.app.MobileQQ +import java.io.File import java.util.Date internal enum class Level( @@ -26,15 +27,28 @@ internal enum class Level( @SuppressLint("SimpleDateFormat") internal object LogCenter { + private val logFileBaseName = MobileQQ.getMobileQQ().qqProcessName.replace(":", ".") + "_${ + // 格式化时间 + SimpleDateFormat("yyyy-MM-dd").format(Date()) + }_" private val LogFile = MobileQQ.getContext().getExternalFilesDir(null)!! .parentFile!!.resolve("Tencent/Shamrock/log").also { if (it.exists()) it.delete() it.mkdirs() + }.let { + var i = 1 + lateinit var result: File + while (true) { + result = it.resolve("$logFileBaseName$i.log") + if (result.exists()) { + i++ + } else { + break + } + } + return@let result } - .resolve(MobileQQ.getMobileQQ().qqProcessName.replace(":", ".") + "_${ - // 格式化时间 - SimpleDateFormat("yyyy-MM-dd").format(Date()) - }_" + ".log") + private val format = SimpleDateFormat("[HH:mm:ss] ") fun log(string: String, level: Level = Level.INFO, toast: Boolean = false) = diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/WebSocketService.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/WebSocketService.kt index f64b147..b0ccdf4 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/WebSocketService.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/WebSocketService.kt @@ -24,8 +24,8 @@ import java.net.URI internal class WebSocketService( host: String, port: Int, - val heartbeatInterval: Long, -): WebSocketTransmitServlet(host, port) { + heartbeatInterval: Long, +): WebSocketTransmitServlet(host, port, heartbeatInterval) { private val eventJobList = mutableSetOf() override fun submitFlowJob(job: Job) { @@ -85,7 +85,6 @@ internal class WebSocketService( } private fun pushMetaLifecycle() { - if (heartbeatInterval <= 0) return GlobalScope.launch { val runtime = AppRuntimeFetcher.appRuntime pushTo(PushMetaEvent( diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/WebSocketTransmitServlet.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/WebSocketTransmitServlet.kt index 9377797..0ede721 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/WebSocketTransmitServlet.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/WebSocketTransmitServlet.kt @@ -35,7 +35,8 @@ import kotlin.concurrent.timer internal abstract class WebSocketTransmitServlet( host:String, - port: Int + port: Int, + protected val heartbeatInterval: Long, ) : BaseTransmitServlet, WebSocketServer(InetSocketAddress(host, port)) { private val sendLock = Mutex() protected val eventReceivers: MutableList = Collections.synchronizedList(mutableListOf()) @@ -56,20 +57,27 @@ internal abstract class WebSocketTransmitServlet( } init { - timer("heartbeat", true, 0, 1000L * 5) { - val runtime = AppRuntimeFetcher.appRuntime - val curUin = runtime.currentAccountUin - broadcastAnyEvent(PushMetaEvent( - time = System.currentTimeMillis() / 1000, - selfId = app.longAccountUin, - postType = PostType.Meta, - type = MetaEventType.Heartbeat, - subType = MetaSubType.Connect, - status = BotStatus( - Self("qq", curUin.toLong()), runtime.isLogin, status = "正常", good = true - ), - interval = 15000 - )) + if (heartbeatInterval > 0) { + timer("heartbeat", true, 0, heartbeatInterval) { + val runtime = AppRuntimeFetcher.appRuntime + val curUin = runtime.currentAccountUin + broadcastAnyEvent( + PushMetaEvent( + time = System.currentTimeMillis() / 1000, + selfId = app.longAccountUin, + postType = PostType.Meta, + type = MetaEventType.Heartbeat, + subType = MetaSubType.Connect, + status = BotStatus( + Self("qq", curUin.toLong()), + runtime.isLogin, + status = "正常", + good = true + ), + interval = heartbeatInterval + ) + ) + } } } @@ -112,7 +120,7 @@ internal abstract class WebSocketTransmitServlet( } override fun onStart() { - LogCenter.log("WSServer start running on ws://0.0.0.0:$port!") + LogCenter.log("WSServer start running on ws://${getAddress()}!") initTransmitter() }