mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix #149 again
This commit is contained in:
parent
dcb2b0a26f
commit
919c4a7d80
@ -279,9 +279,9 @@ object ShamrockConfig {
|
|||||||
return preferences.getBoolean("enable_self_msg", false)
|
return preferences.getBoolean("enable_self_msg", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableSyncMsg(ctx: Context): Boolean {
|
fun enableSyncMsgAsSentMsg(ctx: Context): Boolean {
|
||||||
val preferences = ctx.getSharedPreferences("config", 0)
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
return preferences.getBoolean("enable_sync_msg", false)
|
return preferences.getBoolean("enable_sync_msg_as_sent_msg", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setEnableSelfMsg(ctx: Context, v: Boolean) {
|
fun setEnableSelfMsg(ctx: Context, v: Boolean) {
|
||||||
@ -289,9 +289,9 @@ object ShamrockConfig {
|
|||||||
preferences.edit().putBoolean("enable_self_msg", v).apply()
|
preferences.edit().putBoolean("enable_self_msg", v).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setEnableSyncMsg(ctx: Context, v: Boolean) {
|
fun setEnableSyncMsgAsSentMsg(ctx: Context, v: Boolean) {
|
||||||
val preferences = ctx.getSharedPreferences("config", 0)
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
preferences.edit().putBoolean("enable_sync_msg", v).apply()
|
preferences.edit().putBoolean("enable_sync_msg_as_sent_msg", v).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getConfigMap(ctx: Context): Map<String, Any?> {
|
fun getConfigMap(ctx: Context): Map<String, Any?> {
|
||||||
@ -321,7 +321,7 @@ object ShamrockConfig {
|
|||||||
"echo_number" to preferences.getBoolean("echo_number", false),
|
"echo_number" to preferences.getBoolean("echo_number", false),
|
||||||
"shell" to preferences.getBoolean("shell", false),
|
"shell" to preferences.getBoolean("shell", false),
|
||||||
"alive_reply" to preferences.getBoolean("alive_reply", false),
|
"alive_reply" to preferences.getBoolean("alive_reply", false),
|
||||||
"enable_sync_msg" to preferences.getBoolean("enable_sync_msg", false),
|
"enable_sync_msg_as_sent_msg" to preferences.getBoolean("enable_sync_msg_as_sent_msg", false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,17 +264,6 @@ fun LabFragment() {
|
|||||||
thickness = 0.2.dp
|
thickness = 0.2.dp
|
||||||
)
|
)
|
||||||
|
|
||||||
Function(
|
|
||||||
title = "同步消息推送",
|
|
||||||
desc = "推送来自同号异设备消息,未做特殊处理请勿打开。",
|
|
||||||
descColor = it,
|
|
||||||
isSwitch = ShamrockConfig.enableSyncMsg(ctx)
|
|
||||||
) {
|
|
||||||
ShamrockConfig.setEnableSyncMsg(ctx, it)
|
|
||||||
ShamrockConfig.pushUpdate(ctx)
|
|
||||||
return@Function true
|
|
||||||
}
|
|
||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = "自发消息推送",
|
title = "自发消息推送",
|
||||||
desc = "推送Bot发送的消息,未做特殊处理请勿打开。",
|
desc = "推送Bot发送的消息,未做特殊处理请勿打开。",
|
||||||
@ -286,6 +275,17 @@ fun LabFragment() {
|
|||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function(
|
||||||
|
title = "同步消息推送类型异换",
|
||||||
|
desc = "推送来自同号异设备消息,将同步消息作为自发消息推送。",
|
||||||
|
descColor = it,
|
||||||
|
isSwitch = ShamrockConfig.enableSyncMsgAsSentMsg(ctx)
|
||||||
|
) {
|
||||||
|
ShamrockConfig.setEnableSyncMsgAsSentMsg(ctx, it)
|
||||||
|
ShamrockConfig.pushUpdate(ctx)
|
||||||
|
return@Function true
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function(
|
Function(
|
||||||
title = "使用纯数字ECHO",
|
title = "使用纯数字ECHO",
|
||||||
|
@ -10,7 +10,7 @@ import kotlin.coroutines.resume
|
|||||||
internal object ContactHelper {
|
internal object ContactHelper {
|
||||||
suspend fun getUinByUidAsync(uid: String): String {
|
suspend fun getUinByUidAsync(uid: String): String {
|
||||||
if (uid.isBlank() || uid == "0") {
|
if (uid.isBlank() || uid == "0") {
|
||||||
return "0"
|
return "-1"
|
||||||
}
|
}
|
||||||
|
|
||||||
val kernelService = NTServiceFetcher.kernelService
|
val kernelService = NTServiceFetcher.kernelService
|
||||||
@ -20,7 +20,7 @@ internal object ContactHelper {
|
|||||||
sessionService.uixConvertService.getUin(hashSetOf(uid)) {
|
sessionService.uixConvertService.getUin(hashSetOf(uid)) {
|
||||||
continuation.resume(it)
|
continuation.resume(it)
|
||||||
}
|
}
|
||||||
}[uid]?.toString() ?: "0"
|
}[uid]?.toString() ?: "-1"
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getUidByUinAsync(peerId: Long): String {
|
suspend fun getUidByUinAsync(peerId: Long): String {
|
||||||
|
@ -59,7 +59,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
|||||||
elements: ArrayList<MsgElement>,
|
elements: ArrayList<MsgElement>,
|
||||||
rawMsg: String,
|
rawMsg: String,
|
||||||
msgHash: Int,
|
msgHash: Int,
|
||||||
postType: PostType = PostType.Msg
|
postType: PostType
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val uin = app.longAccountUin
|
val uin = app.longAccountUin
|
||||||
transMessageEvent(record,
|
transMessageEvent(record,
|
||||||
@ -107,7 +107,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
|||||||
elements: ArrayList<MsgElement>,
|
elements: ArrayList<MsgElement>,
|
||||||
rawMsg: String,
|
rawMsg: String,
|
||||||
msgHash: Int,
|
msgHash: Int,
|
||||||
postType: PostType = PostType.Msg,
|
postType: PostType,
|
||||||
tempSource: MessageTempSource = MessageTempSource.Unknown
|
tempSource: MessageTempSource = MessageTempSource.Unknown
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val botUin = app.longAccountUin
|
val botUin = app.longAccountUin
|
||||||
|
@ -76,7 +76,7 @@ internal object ShamrockConfig {
|
|||||||
|
|
||||||
putBoolean("enable_self_msg", intent.getBooleanExtra("enable_self_msg", false)) // 推送自己发的消息
|
putBoolean("enable_self_msg", intent.getBooleanExtra("enable_self_msg", false)) // 推送自己发的消息
|
||||||
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
||||||
putBoolean("enable_sync_msg", intent.getBooleanExtra("enable_sync_msg", false)) // 推送同步消息
|
putBoolean("enable_sync_msg_as_sent_msg", intent.getBooleanExtra("enable_sync_msg_as_sent_msg", false)) // 推送同步消息
|
||||||
|
|
||||||
putBoolean("isInit", true)
|
putBoolean("isInit", true)
|
||||||
}
|
}
|
||||||
@ -102,8 +102,8 @@ internal object ShamrockConfig {
|
|||||||
return Config.rules?.privateRule
|
return Config.rules?.privateRule
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableSyncMsg(): Boolean {
|
fun enableSyncMsgAsSentMsg(): Boolean {
|
||||||
return mmkv.getBoolean("enable_sync_msg", false)
|
return mmkv.getBoolean("enable_sync_msg_as_sent_msg", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableSelfMsg(): Boolean {
|
fun enableSelfMsg(): Boolean {
|
||||||
|
@ -67,10 +67,10 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
MessageHelper.sendMessageWithoutMsgId(record.chatType, record.peerUin.toString(), "pong", { _, _ -> })
|
MessageHelper.sendMessageWithoutMsgId(record.chatType, record.peerUin.toString(), "pong", { _, _ -> })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.senderUin == TicketSvc.getLongUin() && !ShamrockConfig.enableSyncMsg()) {
|
|
||||||
// 不允许推送同步消息
|
val postType = if (record.senderUin == TicketSvc.getLongUin() && ShamrockConfig.enableSyncMsgAsSentMsg()) {
|
||||||
return
|
PostType.MsgSent
|
||||||
}
|
} else PostType.Msg
|
||||||
|
|
||||||
//if (rawMsg.contains("forward")) {
|
//if (rawMsg.contains("forward")) {
|
||||||
// LogCenter.log(record.extInfoForUI.decodeToString(), Level.WARN)
|
// LogCenter.log(record.extInfoForUI.decodeToString(), Level.WARN)
|
||||||
@ -85,8 +85,8 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!GlobalEventTransmitter.MessageTransmitter.transGroupMessage(
|
if(!GlobalEventTransmitter.MessageTransmitter.transGroupMessage(
|
||||||
record, record.elements, rawMsg, msgHash
|
record, record.elements, rawMsg, msgHash, postType
|
||||||
)) {
|
)) {
|
||||||
LogCenter.log("群消息推送失败 -> 推送目标可能不存在", Level.WARN)
|
LogCenter.log("群消息推送失败 -> 推送目标可能不存在", Level.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,8 +98,8 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
if(!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
||||||
record, record.elements, rawMsg, msgHash
|
record, record.elements, rawMsg, msgHash, postType
|
||||||
)) {
|
)) {
|
||||||
LogCenter.log("私聊消息推送失败 -> MessageTransmitter", Level.WARN)
|
LogCenter.log("私聊消息推送失败 -> MessageTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
if(!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
||||||
record, record.elements, rawMsg, msgHash, tempSource = MessageTempSource.Group
|
record, record.elements, rawMsg, msgHash, tempSource = MessageTempSource.Group, postType = postType
|
||||||
)) {
|
)) {
|
||||||
LogCenter.log("私聊临时消息推送失败 -> MessageTransmitter", Level.WARN)
|
LogCenter.log("私聊临时消息推送失败 -> MessageTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -188,8 +188,7 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
if (!ShamrockConfig.enableSelfMsg()
|
if (!ShamrockConfig.enableSelfMsg()
|
||||||
|| record.senderUin != TicketSvc.getLongUin()
|
|| record.senderUin != TicketSvc.getLongUin()
|
||||||
|| record.peerUin == TicketSvc.getLongUin()
|
|| record.peerUin == TicketSvc.getLongUin()
|
||||||
)
|
) return@launch
|
||||||
return@launch
|
|
||||||
|
|
||||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||||
if (rawMsg.isEmpty()) return@launch
|
if (rawMsg.isEmpty()) return@launch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user