Skip to content

Commit

Permalink
Merge pull request #3096 from IcedMango/master
Browse files Browse the repository at this point in the history
企微回调: 移除不正确的通用模板卡片事件; 增加通用模板卡片事件推送; 增加通用模板卡片右上角菜单事件推送
  • Loading branch information
JeffreySu authored Nov 14, 2024
2 parents cab5e53 + a682db6 commit d733760
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 63 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*----------------------------------------------------------------
Copyright (C) 2024 Senparc
文件名:RequestMessageEvent_TemplateCardEvent.cs
文件功能描述:企业微信-模板卡片事件推送
创建标识:IcedMango - 20241114
----------------------------------------------------------------*/

using System.Collections.Generic;
using System.Xml.Serialization;

namespace Senparc.Weixin.Work.Entities
{
/// <summary>
/// 企业微信-模板卡片事件推送
/// </summary>
public class RequestMessageEvent_TemplateCardEvent : RequestMessageEventBase, IRequestMessageEventBase, IRequestMessageEventKey
{
/// <summary>
/// 事件类型(template_card_event,点击模板卡片按钮)
/// </summary>
public override Event Event => Event.TEMPLATE_CARD_EVENT;

/// <summary>
/// 与发送模板卡片消息时指定的按钮btn:key值相同
/// </summary>
public string EventKey { get; set; }

/// <summary>
/// 与发送模板卡片消息时指定的task_id相同
/// </summary>
public string TaskId { get; set; }

/// <summary>
/// 通用模板卡片的类型
/// </summary>
public TemplateCard_CardTypeEnum CardType { get; set; }

/// <summary>
/// 用于调用更新卡片接口的ResponseCode,72小时内有效,且只能使用一次
/// </summary>
public string ResponseCode { get; set; }

/// <summary>
///
/// </summary>
[XmlArray("SelectedItems")]
[XmlArrayItem("SelectedItem")]
public List<TemplateCard_SelectedItem> SelectedItems { get; set; }
}

/// <summary>
/// 通用模板卡片的类型
/// </summary>
public enum TemplateCard_CardTypeEnum
{
text_notice,
news_notice,
button_interaction,
vote_interaction,
multiple_interaction
}

public class TemplateCard_SelectedItem
{
/// <summary>
/// 问题的key值
/// </summary>
[XmlElement("QuestionKey")]
public string QuestionKey { get; set; }

[XmlArray("OptionIds")]
[XmlArrayItem("OptionId")]
public List<string> OptionIds { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*----------------------------------------------------------------
Copyright (C) 2024 Senparc
文件名:RequestMessageEvent_TemplateCardMenuEvent.cs
文件功能描述:通用模板卡片右上角菜单事件推送
创建标识:IcedMango - 20241114
----------------------------------------------------------------*/

using System.Collections.Generic;
using System.Xml.Serialization;

namespace Senparc.Weixin.Work.Entities
{
/// <summary>
/// 企业微信-模板卡片事件推送
/// </summary>
public class RequestMessageEvent_TemplateCardMenuEvent : RequestMessageEventBase, IRequestMessageEventBase, IRequestMessageEventKey
{
/// <summary>
/// 事件类型(template_card_menu_event,通用模板卡片右上角菜单事件推送)
/// </summary>
public override Event Event => Event.TEMPLATE_CARD_MENU_EVENT;

/// <summary>
/// 与发送模板卡片消息时指定的按钮btn:key值相同
/// </summary>
public string EventKey { get; set; }

/// <summary>
/// 与发送模板卡片消息时指定的task_id相同
/// </summary>
public string TaskId { get; set; }

/// <summary>
/// 通用模板卡片的类型
/// </summary>
public TemplateCard_CardTypeEnum CardType { get; set; }

/// <summary>
/// 用于调用更新卡片接口的ResponseCode,72小时内有效,且只能使用一次
/// </summary>
public string ResponseCode { get; set; }
}
}
12 changes: 10 additions & 2 deletions src/Senparc.Weixin.Work/Senparc.Weixin.Work/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ GroupTaskSentStatus 枚举
修改标识:LofyLiu - 20240315
修改描述:添加枚举“模板卡片点击回调事件”
修改标识: IcedMango - 20241114
修改描述: 添加: 通用模板卡片右上角菜单事件推送; 修复不正确的通用模板卡片事件推送类型
----------------------------------------------------------------*/

using static System.Net.WebRequestMethods;
Expand Down Expand Up @@ -218,9 +221,14 @@ public enum Event
MSGAUDIT_NOTIFY,

/// <summary>
/// 模板卡片点击回调事件
/// 模板卡片事件推送
/// </summary>
TEMPLATE_CARD_EVENT,

/// <summary>
/// 通用模板卡片右上角菜单事件
/// </summary>
TEMPLATE_CARD_CLICK,
TEMPLATE_CARD_MENU_EVENT,
}

public enum TencentGender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ public override IWorkRequestMessageBase GetRequestEntityMappingResult(RequestMsg
case "MSGAUDIT_NOTIFY":
requestMessage = new RequestMessageEvent_MsgAuditNotify();
break;
case "TEMPLATE_CARD_EVENT": //模板卡片回调事件
requestMessage = new RequestMessageEvent_TemplateCardClick();
case "TEMPLATE_CARD_EVENT": // 模板卡片事件推送
requestMessage = new RequestMessageEvent_TemplateCardEvent();
break;
case "TEMPLATE_CARD_MENU_EVENT": // 通用模板卡片右上角菜单事件
requestMessage = new RequestMessageEvent_TemplateCardMenuEvent();
break;
default://其他意外类型(也可以选择抛出异常)
requestMessage = new RequestMessageEventBase();
Expand Down
Loading

0 comments on commit d733760

Please sign in to comment.