Mud.Feishu.EventCallback 2.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mud.Feishu.EventCallback --version 2.0.8
                    
NuGet\Install-Package Mud.Feishu.EventCallback -Version 2.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mud.Feishu.EventCallback" Version="2.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mud.Feishu.EventCallback" Version="2.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Mud.Feishu.EventCallback" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mud.Feishu.EventCallback --version 2.0.8
                    
#r "nuget: Mud.Feishu.EventCallback, 2.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mud.Feishu.EventCallback@2.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mud.Feishu.EventCallback&version=2.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Mud.Feishu.EventCallback&version=2.0.8
                    
Install as a Cake Tool

Mud.Feishu.EventCallback

飞书服务端 SDK 的 .NET 适配版,提供事件与回调功能强数据模型封装。

项目简介

Mud.Feishu.EventCallback 是 MudFeishu SDK 的核心组件之一,专门用于处理飞书平台的事件回调。本项目提供了完整的强类型数据模型,帮助开发者轻松处理飞书各种事件推送。

特性

  • 强类型数据模型 - 所有事件数据均有完整的类型定义和 XML 文档注释
  • 自动生成事件处理器 - 使用源代码生成器自动生成事件处理器基类
  • 多框架支持 - 支持 .NET Standard 2.0、.NET 6.0、.NET 8.0、.NET 10.0
  • 完整的事件覆盖 - 覆盖飞书主要业务场景的事件回调
  • 官方文档链接 - 每个事件模型都包含官方文档链接

支持的事件类型

📋 审批事件(Approval)

事件类型 说明 数据模型
leave_approval 请假审批 LeaveApprovalResult
leave_approval_revert 请假撤销 LeaveApprovalRevertResult
leave_approval_v2 请假审批 V2 LeaveApprovalV2Result
work_approval 加班审批 WorkApprovalResult
work_approval_revert 加班撤销 WorkApprovalRevertResult
out_approval 外出审批 OutApprovalResult
shift_approval 换班审批 ShiftApprovalResult
approval_instance 审批实例 ApprovalInstanceResult
approval_task 审批任务 ApprovalResult
approval_cc 审批抄送 ApprovalCcResult
approval_approval_updated 审批定义更新 ApprovalApprovalUpdatedResult
approval_instance_trip_group_update 出差审批更新 ApprovalInstanceTripGroupUpdateResult
approval_instance_remedy_group_update 补卡审批更新 ApprovalInstanceRemedyGroupUpdateResult

👥 组织架构事件(Organization)

事件类型 说明 数据模型
contact.user.created_v3 员工入职 UserCreateResult
contact.user.deleted_v3 员工离职 UserDeleteResult
contact.user.updated_v3 员工信息更新 UserUpdateResult
contact.department.created_v3 部门创建 DepartmentCreatedEventResult
contact.department.deleted_v3 部门删除 DepartmentDeleteResult
contact.department.updated_v3 部门更新 DepartmentDeleteResult
contact.custom_attr.updated_v3 自定义属性更新 CustomAttrUpdateResult
contact.employee_type_enum.created_v3 人员类型创建 EmployeeTypeEnumCreatedResult
contact.employee_type_enum.deleted_v3 人员类型删除 EmployeeTypeEnumDeleteResult
contact.employee_type_enum.updated_v3 人员类型更新 EmployeeTypeEnumUpdateResult
contact.employee_type_enum.activated_v3 人员类型激活 EmployeeTypeEnumActivedResult
contact.employee_type_enum.deactivated_v3 人员类型停用 EmployeeTypeEnumDeActivedResult

💬 即时通讯事件(IM)

事件类型 说明 数据模型
im.message.receive_v1 接收消息 MessageReceiveResult
im.message.read_v1 消息已读 MessageReadResult
im.message.recalled_v1 消息撤回 MessageRecalledResult
im.message_reaction.created_v1 表情回应创建 MessageReactionCreatedResult
im.message_reaction.deleted_v1 表情回应删除 MessageReactionDeletedResult
im.chat.updated_v1 群聊更新 ChatUpdatedResult
im.chat.disbanded_v1 群聊解散 ChatDisbandedResult
im.chat.member.user.added_v1 用户进群 ChatMemberUserAddedResult
im.chat.member.user.deleted_v1 用户退群 ChatMemberUserAddedResult
im.chat.member.user.withdrawn_v1 用户主动退群 ChatMemberUserAddedResult
im.chat.member.bot.added_v1 机器人进群 ChatMemberBotAddedResult
im.chat.member.bot.deleted_v1 机器人退群 ChatMemberBotDeletedResult

✅ 任务事件(Task)

事件类型 说明 数据模型
task.updated 任务更新 TaskUpdatedResult
task.comment.updated 任务评论更新 TaskCommentUpdatedResult
task.tenant.updated 租户任务更新 TaskUpdateTenantResult

⏰ 考勤事件(Attendance)

事件类型 说明 数据模型
attendance.user_flow.created_v1 考勤流水创建 AttendanceUserFlowCreatedResult
attendance.user_task.updated_v1 考勤任务更新 AttendanceUserTaskUpdatedResult

安装

通过 NuGet 安装

dotnet add package Mud.Feishu.EventCallback

支持的目标框架

  • .NET Standard 2.0
  • .NET 6.0
  • .NET 8.0
  • .NET 10.0

快速开始

1. 定义事件处理器

继承自动生成的事件处理器基类,实现业务逻辑:

using Mud.Feishu.EventCallback.IM;

public class MyMessageHandler : MessageReceiveEventHandler
{
    private readonly ILogger<MyMessageHandler> _logger;

    public MyMessageHandler(ILogger<MyMessageHandler> logger)
    {
        _logger = logger;
    }

    public override async Task HandleAsync(MessageReceiveResult result, CancellationToken cancellationToken = default)
    {
        _logger.LogInformation("收到消息:{MessageId}", result.Message?.MessageId);

        if (result.Message?.Content != null)
        {
            var content = result.Message.Content;
            _logger.LogInformation("消息内容:{Content}", content);
        }

        await Task.CompletedTask;
    }
}

2. 处理审批事件

using Mud.Feishu.EventCallback.Approval;

public class LeaveApprovalHandler : LeaveApprovalEventHandler
{
    private readonly ILogger<LeaveApprovalHandler> _logger;

    public LeaveApprovalHandler(ILogger<LeaveApprovalHandler> logger)
    {
        _logger = logger;
    }

    public override async Task HandleAsync(LeaveApprovalResult result, CancellationToken cancellationToken = default)
    {
        _logger.LogInformation(
            "员工 {EmployeeId} 请假申请:{StartTime} 至 {EndTime},时长 {Duration} 秒",
            result.EmployeeId,
            result.LeaveStartTime,
            result.LeaveEndTime,
            result.LeaveInterval
        );

        await Task.CompletedTask;
    }
}

3. 处理组织架构事件

using Mud.Feishu.EventCallback.Organization;

public class UserCreatedHandler : UserCreateEventHandler
{
    private readonly ILogger<UserCreatedHandler> _logger;

    public UserCreatedHandler(ILogger<UserCreatedHandler> logger)
    {
        _logger = logger;
    }

    public override async Task HandleAsync(UserCreateResult result, CancellationToken cancellationToken = default)
    {
        _logger.LogInformation(
            "新员工入职:{Name} ({UserId})",
            result.Name,
            result.UserId
        );

        await Task.CompletedTask;
    }
}

数据模型结构

每个事件数据模型都实现了 IEventResult 接口,并包含:

  • 完整的属性定义 - 所有字段均有强类型定义
  • JSON 序列化特性 - 使用 [JsonPropertyName] 标注字段映射
  • XML 文档注释 - 详细的中文注释说明
  • 官方文档链接 - 通过 <see href> 链接到官方文档

示例:

/// <summary>
/// 接收消息事件处理器
/// <para>机器人接收到用户发送的消息后触发此事件。</para>
/// <para>事件类型:im.message.receive_v1</para>
/// <para>使用时请继承:<see cref="MessageReceiveEventHandler"/></para>
/// <para>文档地址:<see href="https://open.feishu.cn/document/server-docs/im-v1/message/events/receive"/></para>
/// </summary>
[GenerateEventHandler(EventType = FeishuEventTypes.ReceiveMessage,
                      HandlerNamespace = Consts.HandlerNamespace,
                      InheritedFrom = Consts.InheritedFrom)]
public class MessageReceiveResult : IEventResult
{
    [JsonPropertyName("sender")]
    public MessageSender? Sender { get; set; }

    [JsonPropertyName("message")]
    public MessageContent? Message { get; set; }
}

项目结构

Mud.Feishu.EventCallback/
├── Approval/                          # 审批事件
│   ├── LeaveApprovalEvent/           # 请假审批
│   ├── WorkApprovalEvent/            # 加班审批
│   ├── OutApprovalEvent/             # 外出审批
│   ├── ShiftApprovalEvent/           # 换班审批
│   ├── ApprovalInstanceEvent/        # 审批实例
│   ├── ApprovalTaskEvent/            # 审批任务
│   ├── ApprovalCcEvent/              # 审批抄送
│   └── ...
├── Organization/                      # 组织架构事件
│   ├── UserCreateEvent/              # 用户创建
│   ├── UserDeleteEvent/              # 用户删除
│   ├── UserUpdateEvent/              # 用户更新
│   ├── DepartmentCreatedEvent/       # 部门创建
│   ├── DepartmentDeletedEvent/       # 部门删除
│   ├── DepartmentUpdateEvent/        # 部门更新
│   └── ...
├── IM/                               # 即时通讯事件
│   ├── MessageReceiveEvent/          # 消息接收
│   ├── MessageReadEvent/             # 消息已读
│   ├── MessageRecalledEvent/         # 消息撤回
│   ├── MessageReactionCreatedEvent/  # 表情回应创建
│   ├── MessageReactionDeletedEvent/  # 表情回应删除
│   ├── ChatUpdatedEvent/             # 群聊更新
│   ├── ChatDisbandedEvent/           # 群聊解散
│   └── ...
├── Task/                             # 任务事件
│   ├── TaskUpdatedResult.cs          # 任务更新
│   ├── TaskCommentUpdatedResult.cs   # 任务评论更新
│   └── TaskUpdateTenantResult.cs     # 租户任务更新
├── Attendance/                       # 考勤事件
│   ├── AttendanceUserFlowCreatedResult.cs   # 考勤流水创建
│   └── AttendanceUserTaskUpdatedResult.cs   # 考勤任务更新
└── GlobalUsings.cs                   # 全局引用

依赖项

  • Mud.Feishu.Abstractions - 核心抽象和基础类型
  • Mud.HttpUtils.Generator - 源代码生成器(用于自动生成事件处理器)

相关项目

  • Mud.Feishu - 核心 HTTP API 客户端
  • Mud.Feishu.Abstractions - 事件处理抽象
  • Mud.Feishu.Webhook - Webhook 事件处理
  • Mud.Feishu.WebSocket - WebSocket 实时事件
  • Mud.Feishu.Redis - Redis 分布式去重

文档与资源

许可证

本项目采用 MIT 许可证。详见 LICENSE-MIT 文件。

版权声明

版权所有 © Mud Studio 2026。保留所有权利。

Mud.Feishu 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。

本项目主要遵循 MIT 许可证进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 文件。

不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目开发而产生的一切法律纠纷和责任,我们不承担任何责任!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-preview3 98 5/22/2026
3.0.0-preview2 121 5/11/2026
3.0.0-preview1 148 5/1/2026
2.1.3 164 5/22/2026
2.1.2 142 5/12/2026
2.1.1 108 5/11/2026
2.1.0 122 5/1/2026
2.0.9 175 4/24/2026
2.0.8 145 4/12/2026