Bitzsoft.Integrations.InstantMessaging 1.0.2

dotnet add package Bitzsoft.Integrations.InstantMessaging --version 1.0.2
                    
NuGet\Install-Package Bitzsoft.Integrations.InstantMessaging -Version 1.0.2
                    
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="Bitzsoft.Integrations.InstantMessaging" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.InstantMessaging" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.InstantMessaging" />
                    
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 Bitzsoft.Integrations.InstantMessaging --version 1.0.2
                    
#r "nuget: Bitzsoft.Integrations.InstantMessaging, 1.0.2"
                    
#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 Bitzsoft.Integrations.InstantMessaging@1.0.2
                    
#: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=Bitzsoft.Integrations.InstantMessaging&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.InstantMessaging&version=1.0.2
                    
Install as a Cake Tool

Bitzsoft.Integrations.InstantMessaging

即时通讯抽象层 — 统一接口定义、基础模型与结果包装。

屏蔽 Slack、WhatsApp、Telegram、Discord 等供应商差异,提供一致的消息发送、更新、删除、频道管理与成员邀请 API。

功能特性

  • 统一供应商接口 IInstantMessagingService:8 个异步方法覆盖文本/卡片消息与频道/成员管理
  • 统一结果包装ImMessageResultImResult 携带成功标志与错误信息
  • 统一异常 InstantMessagingException:封装供应商标识、错误码与请求 ID
  • 不可变模型设计:集合返回 List<T>,属性使用 init 保证只读

安装

dotnet add package Bitzsoft.Integrations.InstantMessaging
<PackageReference Include="Bitzsoft.Integrations.InstantMessaging" Version="1.0.0" />

接口

IInstantMessagingService

统一的即时通讯供应商接口。

方法 返回类型 说明
ProviderName string 供应商标识(如 SlackWhatsApp
SendTextMessageAsync Task<ImMessageResult> 发送文本消息
SendCardMessageAsync Task<ImMessageResult> 发送卡片消息
DeleteMessageAsync Task<ImResult> 删除消息
UpdateMessageAsync Task<ImResult> 更新消息内容
ListChannelsAsync Task<List<ImChannel>> 查询频道列表
CreateChannelAsync Task<ImResult> 创建频道
InviteMemberAsync Task<ImResult> 邀请成员加入频道

核心模型

关键字段 说明
SendTextMessageRequest ChannelIdTextMentionUserIds 发送文本消息请求
SendCardMessageRequest ChannelIdTitleTextButtonsImageUrl 发送卡片消息请求
InviteMemberRequest ChannelIdUserIds 邀请成员请求
ImChannel ChannelIdNameTypeMemberCount 频道信息
ImCardButton TextActionUrlActionType 卡片按钮
ImMessageResult SuccessMessageIdErrorMessage 消息发送结果
ImResult SuccessErrorMessage 操作结果
InstantMessagingException 统一异常(继承 IntegrationException

枚举

枚举 说明
ImChannelType 频道类型:Public / Private / Group / Direct
ImCardActionType 卡片按钮动作类型:Link / Action

使用示例

抽象层本身只定义接口与模型,具体实现由各供应商包提供。以下示例假设已注册某个供应商实现:

public class MessagingService(IInstantMessagingService im)
{
    public async Task<string?> NotifyChannelAsync(string channelId, string text)
    {
        var result = await im.SendTextMessageAsync(new SendTextMessageRequest
        {
            ChannelId = channelId,
            Text = text,
            MentionUserIds = ["U1001"]
        });
        return result.MessageId;
    }

    public Task<List<ImChannel>> GetChannelsAsync()
        => im.ListChannelsAsync();
}

多供应商解析

同一应用注册多个供应商时,通过 IIntegrationProviderResolver<IInstantMessagingService> 按供应商 ID 解析:

var resolver = serviceProvider.GetRequiredService<IIntegrationProviderResolver<IInstantMessagingService>>();
var slack = resolver.GetRequired("slack");
var result = await slack.SendCardMessageAsync(request);

依赖

相关包

供应商 包名
统一抽象 Bitzsoft.Integrations.InstantMessaging
Slack Bitzsoft.Integrations.InstantMessaging.Slack
WhatsApp Bitzsoft.Integrations.InstantMessaging.WhatsApp
Telegram Bitzsoft.Integrations.InstantMessaging.Telegram
Discord Bitzsoft.Integrations.InstantMessaging.Discord
聚合包 Bitzsoft.Integrations.InstantMessaging.All
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Bitzsoft.Integrations.InstantMessaging:

Package Downloads
Bitzsoft.Integrations.InstantMessaging.Slack

Slack 即时通讯服务实现 — Bot User OAuth Token(xoxb-)Bearer 鉴权 + HttpClient,实现 IInstantMessagingService 统一接口,支持消息收发、卡片、频道与成员管理

Bitzsoft.Integrations.InstantMessaging.Telegram

Telegram Bot 即时通讯服务实现 — Bot Token(URL 路径)鉴权 + HttpClient,实现 IInstantMessagingService 统一接口,支持消息收发、卡片、频道与成员管理

Bitzsoft.Integrations.InstantMessaging.WhatsApp

WhatsApp Business Cloud API 即时通讯服务实现 — System User Token Bearer 鉴权 + HttpClient,实现 IInstantMessagingService 统一接口,支持消息收发、卡片、频道与成员管理

Bitzsoft.Integrations.InstantMessaging.Discord

Discord Bot 即时通讯服务实现 — Bot Token Bearer 鉴权 + HttpClient,实现 IInstantMessagingService 统一接口,支持消息收发、卡片、频道与成员管理

Bitzsoft.Integrations.InstantMessaging.All

即时通讯服务聚合包 — 包含全部供应商实现(Slack / WhatsApp / Telegram / Discord)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 219 8/29/2026
1.0.1 263 8/3/2026
1.0.0 256 8/2/2026