Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OssTJiaUploaderService
|
||||
{
|
||||
public class DingTalkNotifier
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public DingTalkNotifier(HttpClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task SendTextAsync(string url, string content)
|
||||
{
|
||||
if (!content.Contains("备份"))
|
||||
content = "备份:" + content;
|
||||
|
||||
var payload = new
|
||||
{
|
||||
msgtype = "text",
|
||||
text = new { content }
|
||||
};
|
||||
|
||||
var json = JsonSerializer.Serialize(payload);
|
||||
var resp = await _client.PostAsync(url, new StringContent(json, Encoding.UTF8, "application/json"));
|
||||
resp.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user