EasyNotice.Weixin
2.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package EasyNotice.Weixin --version 2.1.0
NuGet\Install-Package EasyNotice.Weixin -Version 2.1.0
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="EasyNotice.Weixin" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyNotice.Weixin --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyNotice.Weixin, 2.1.0"
#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.
// Install EasyNotice.Weixin as a Cake Addin #addin nuget:?package=EasyNotice.Weixin&version=2.1.0 // Install EasyNotice.Weixin as a Cake Tool #tool nuget:?package=EasyNotice.Weixin&version=2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyNotice
Nuget包
| Package Name | Version | Downloads |--------------| ------- | ---- | EasyNotice.Core | | | | EasyNotice.Dingtalk | | | | EasyNotice.Email | | | | EasyNotice.Feishu | | | | EasyNotice.Weixin | | |
EasyNotice
这是一个基于.NET开源的消息通知组件,它包含了邮件通知、钉钉、飞书、企业微信通知,可以帮助我们更容易地发送程序异常通知!
功能介绍
- 支持[邮件]、[钉钉]、[飞书]、[企业微信]方式发送
- 支持自定义发送间隔,避免同样的异常频繁通知
- 傻瓜式配置,开箱即用
平台支持
- SMTP邮箱
- 钉钉群机器人
- 飞书群机器人
- 企业微信群机器人
文档资料
项目接入
项目接入提供了以下发送方式的Demo:邮件通知、钉钉通知、飞书、企业微信通知
1. 邮件通知
邮件通知支持同时发送给多个收件人
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Email
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseEmail(option =>
{
option.Host = "smtp.qq.com";//SMTP地址
option.Port = 465;//SMTP端口
option.FromName = "System";//发送人名字(自定义)
option.FromAddress = "12345@qq.com";//发送邮箱
option.Password = "passaword";//秘钥
option.ToAddress = new List<string>()//收件人集合
{
"12345@qq.com"
};
});
});
}
}
Step 3 : IEmailProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IEmailProvider _mailProvider;
public NoticeController(IEmailProvider provider)
{
_mailProvider = provider;
}
[HttpGet]
public async Task SendMail([FromQuery] string str)
{
await _mailProvider.SendAsync(str, new Exception(str));
}
}
2. 钉钉通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Dingtalk
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseDingTalk(option =>
{
option.WebHook = "https://oapi.dingtalk.com/robot/send?access_token=xxxxx";//通知地址
option.Secret = "secret";//签名校验
});
});
}
}
Step 3 : IDingtalkProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IDingtalkProvider _dingtalkProvider;
public NoticeController(IDingtalkProvider dingtalkProvider)
{
_dingtalkProvider = dingtalkProvider;
}
[HttpGet]
public async Task SendDingTalk([FromQuery] string str)
{
await _dingtalkProvider.SendAsync(str, new Exception(str));
}
}
3. 飞书通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Feishu
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseFeishu(option =>
{
option.WebHook = "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx";//通知地址
option.Secret = "secret";//签名校验
});
});
}
}
Step 3 : IFeishuProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IFeishuProvider _feishuProvider;
public NoticeController(IFeishuProvider feishuProvider)
{
_feishuProvider = feishuProvider;
}
[HttpGet]
public async Task SendFeishu([FromQuery] string str)
{
await _feishuProvider.SendAsync(str, new Exception(str));
}
}
4. 企业微信通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Weixin
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseWeixin(option =>
{
option.WebHook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx";//通知地址
});
});
}
}
Step 3 : IWeixinProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IWeixinProvider _weixinProvider;
public NoticeController(IWeixinProvider weixinProvider)
{
_weixinProvider = weixinProvider;
}
[HttpGet]
public async Task SendWexin([FromQuery] string str)
{
await _weixinProvider.SendAsync(str, new Exception(str));
}
}
更多示例
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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 was computed. 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. |
.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 is compatible. |
.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.
-
.NETStandard 2.0
- EasyNotice.Core (>= 2.1.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.17)
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 2.1
- EasyNotice.Core (>= 2.1.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.17)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.