From 652a9c68d797bbfbb68002b94b0326faf49d8fdd Mon Sep 17 00:00:00 2001 From: pppscn <35696959@qq.com> Date: Tue, 4 Jul 2023 10:53:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E9=92=89=E9=92=89?= =?UTF-8?q?=E7=BE=A4=E6=9C=BA=E5=99=A8=E4=BA=BA=E6=94=AF=E6=8C=81at?= =?UTF-8?q?=E9=92=89=E9=92=89=E5=8F=B7/=E6=B5=B7=E5=A4=96=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=20#312?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/DingtalkGroupRobotSetting.kt | 1 + .../senders/DingtalkGroupRobotFragment.kt | 17 +- .../utils/sender/DingtalkGroupRobotUtils.kt | 28 +- .../fragment_senders_dingtalk_group_robot.xml | 425 ++++++++++-------- app/src/main/res/values-en/strings.xml | 16 +- app/src/main/res/values/strings.xml | 8 +- 6 files changed, 267 insertions(+), 228 deletions(-) diff --git a/app/src/main/java/com/idormy/sms/forwarder/entity/setting/DingtalkGroupRobotSetting.kt b/app/src/main/java/com/idormy/sms/forwarder/entity/setting/DingtalkGroupRobotSetting.kt index eada67be..860a6183 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/entity/setting/DingtalkGroupRobotSetting.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/entity/setting/DingtalkGroupRobotSetting.kt @@ -7,4 +7,5 @@ data class DingtalkGroupRobotSetting( var secret: String? = "", var atAll: Boolean? = false, var atMobiles: String? = "", + var atDingtalkIds: String? = "", ) : Serializable \ No newline at end of file diff --git a/app/src/main/java/com/idormy/sms/forwarder/fragment/senders/DingtalkGroupRobotFragment.kt b/app/src/main/java/com/idormy/sms/forwarder/fragment/senders/DingtalkGroupRobotFragment.kt index 105dfc38..db0485be 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/fragment/senders/DingtalkGroupRobotFragment.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/fragment/senders/DingtalkGroupRobotFragment.kt @@ -123,15 +123,9 @@ class DingtalkGroupRobotFragment : BaseFragment = mutableMapOf() msgMap["msgtype"] = "text" - val textText: MutableMap = mutableMapOf() - textText["content"] = content - msgMap["text"] = textText - val atMap: MutableMap = mutableMapOf() msgMap["at"] = atMap if (setting.atAll == true) { @@ -69,19 +65,31 @@ class DingtalkGroupRobotUtils private constructor() { if (!TextUtils.isEmpty(setting.atMobiles)) { val atMobilesArray: Array = setting.atMobiles.toString().replace("[,,;;]".toRegex(), ",").trim(',').split(',').toTypedArray() if (atMobilesArray.isNotEmpty()) { - val atMobilesList: MutableList = ArrayList() + atMap["atMobiles"] = atMobilesArray for (atMobile in atMobilesArray) { - if (TextUtils.isDigitsOnly(atMobile)) { - atMobilesList.add(atMobile) + if (!content.contains("@${atMobile}")) { + content += " @${atMobile}" } } - if (atMobilesList.isNotEmpty()) { - atMap["atMobiles"] = atMobilesList + } + } + if (!TextUtils.isEmpty(setting.atDingtalkIds)) { + val atDingtalkIdsArray: Array = setting.atDingtalkIds.toString().replace("[,,;;]".toRegex(), ",").trim(',').split(',').toTypedArray() + if (atDingtalkIdsArray.isNotEmpty()) { + atMap["atDingtalkIds"] = atDingtalkIdsArray + for (atDingtalkId in atDingtalkIdsArray) { + if (!content.contains("@${atDingtalkId}")) { + content += " @${atDingtalkId}" + } } } } } + val textText: MutableMap = mutableMapOf() + textText["content"] = content + msgMap["text"] = textText + val requestMsg: String = Gson().toJson(msgMap) Log.i(TAG, "requestMsg:$requestMsg") diff --git a/app/src/main/res/layout/fragment_senders_dingtalk_group_robot.xml b/app/src/main/res/layout/fragment_senders_dingtalk_group_robot.xml index 69df1055..404024b4 100644 --- a/app/src/main/res/layout/fragment_senders_dingtalk_group_robot.xml +++ b/app/src/main/res/layout/fragment_senders_dingtalk_group_robot.xml @@ -1,198 +1,229 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index d9c93259..7311bb97 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -324,7 +324,7 @@ SendKey Message Channel Tip: Dynamically specified, supports up to two channels, separated by a vertical bar | - Optional, for example: to send service number and enterprise WeChat application, then fill in 9|66 + Optional, e.g. to send service number and enterprise WeChat application, then fill in 9|66 CC OpenID Tip: Only test accounts and Wework application message channels are supported Optional, multiple openids are separated by commas @@ -704,23 +704,25 @@ Robot Settings→webhook→access_token Secret Robot Settings→Security Settings→Sign Up - \@someone when retweeting - Tips: Separate multiple phone numbers with commas, for example: 18888888888,19999999999 + At Mobiles + Tips: Separate multiple mobiles with commas, e.g. 18888888888,19999999999 + At DingtalkIds + Tips:Separate multiple DingtalkIds with commas, e.g. user1,user2 Bark-Server Example: https://api.day.app/XXXXXXXX/ ^https?://[^/]+/[^/]+/$ - The Url format is wrong, for example: https://api.day.app/XXXXXXXX/ + The Url format is wrong, e.g. https://api.day.app/XXXXXXXX/ Group Name Optional, eg: SmsForwarder Message Icon Optional, fill in Url, the picture should not be too big Message Sound - Optional, for example: minuet.caf + Optional, e.g. minuet.caf Message Badge Optional, eg: 888 Message Link - Optional, for example: https://github.com/pppscn/SmsForwarder + Optional, e.g. https://github.com/pppscn/SmsForwarder Notification Level Immediately display notifications Time-sensitive notifications that can be displayed in a focused state @@ -766,7 +768,7 @@ For example: https://a.b.com/msg?token=xyz Params Msg Template - For example: payload=%7B%22text%22%3A%22[msg]%22%7D [msg] will be replaced with SMS content.\nJson format is supported, for example: {\"text\":\"[msg]\"}.\nNote: msg is automatically URLEncoder except in JSON format + For example: payload=%7B%22text%22%3A%22[msg]%22%7D [msg] will be replaced with SMS content.\nJson format is supported, e.g. {\"text\":\"[msg]\"}.\nNote: msg is automatically URLEncoder except in JSON format Secret: If it is empty, the sign will not be calculated Headers Key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index af90aa9a..40de710c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -311,7 +311,7 @@ 企业ID AgentId Secret - 是否@all + 是否@所有人 指定成员 \@all Tip:接收消息的成员ID列表(多个接收者用‘|’分隔,最多支持1000个) @@ -705,8 +705,10 @@ 机器人设置→webhook→access_token 加签 Secret 机器人设置→安全设置→加签 - 转发时@某人 - Tips:多个手机号用逗号分开,例如:18888888888,19999999999 + 被@人的手机号 + Tips:多个手机号用逗号分开,例如:18888888888,19999999999 + 被@人的钉钉号 + Tips:多个钉钉号用逗号分开,例如:user1,user2 Bark-Server 例:https://api.day.app/XXXXXXXX/