From 0f0d9b3134f8db4777531077963ba14b2e71e43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=88=E6=A3=AE=E5=90=B4?= <8402134@qq.com> Date: Sat, 31 Dec 2022 22:28:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E4=BC=81=E4=B8=9A=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enterprise/Wechat_Xiaoxie_QY_Override.cs | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/PCRobot/PCWechat/Enterprise/Wechat_Xiaoxie_QY_Override.cs b/PCRobot/PCWechat/Enterprise/Wechat_Xiaoxie_QY_Override.cs index a895c2d..14bc426 100644 --- a/PCRobot/PCWechat/Enterprise/Wechat_Xiaoxie_QY_Override.cs +++ b/PCRobot/PCWechat/Enterprise/Wechat_Xiaoxie_QY_Override.cs @@ -110,7 +110,15 @@ namespace PCRobot.PCWechat.Enterprise weapppagethumbrawurl = regKey.Groups["weapppagethumbrawurl"].Value; //小程序 - SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title, image_url, desc, pagepath); + if (!string.IsNullOrWhiteSpace(image_url)) + { + SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title, + image_url, desc, pagepath); + } + else + { + SendProgramMessage(conversation_id, ghid.XMLReplace(false), ghid.XMLReplace(false), title, image_url, desc, pagepath, image_key1, image_key2, image_key3, image_size); + } return; } else @@ -706,10 +714,10 @@ namespace PCRobot.PCWechat.Enterprise #endregion FileC2cCdnInfo cdn = GetCdnByUpLoadFile(appicon, 1).Result; - if (cdn == null) - throw new Exception("小程序图片获取Cdn失败"); + //if (cdn == null) + // throw new Exception("小程序图片获取Cdn失败"); - var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = cdn.file_id, aes_key = cdn.file_aes_key, md5 = cdn.file_md5, size = cdn.file_size } }); + var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = cdn?.file_id ?? string.Empty, aes_key = cdn?.file_aes_key ?? string.Empty, md5 = cdn?.file_md5 ?? string.Empty, size = cdn?.file_size ?? 0 } }); SendWxWorkData(User.DwClientId, _json); } @@ -719,6 +727,22 @@ namespace PCRobot.PCWechat.Enterprise } } + + private void SendProgramMessage(string username, string appUsername, string appId, string appName, string appicon, string title, + string page_path, string file_id, string file_aes_key, string file_md5, int file_size) + { + try + { + var _json = JsonConvert.SerializeObject(new { type = Wechat_Xiaoxie_QY.MsgType.MT_SEND_MINI_PROGRAM_MSG, data = new { conversation_id = GetConversationId(username), username = appUsername, appid = appId, appName = appName, appicon = appicon, title = title, page_path = page_path, file_id = file_id, aes_key = file_aes_key, md5 = file_md5, size = file_size } }); + + SendWxWorkData(User.DwClientId, _json); + } + catch (Exception ex) + { + LogHelper.GetSingleObj().Error(new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name, $"发送小程序Cdn:{ex.Message}"); + } + } + public override void SendVideoHao(string username, string avatar, string cover_url, string desc, int feed_type, string nickname, string thumb_url, string url, string extras) {