|
@@ -7,6 +7,9 @@ using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Security.Cryptography;
|
|
|
+using System.Net.Http.Json;
|
|
|
+using System.Text.Json;
|
|
|
+using System.IO;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.DI
|
|
@@ -30,19 +33,13 @@ namespace TEAMModelOS.SDK.DI
|
|
|
/// <returns></returns>
|
|
|
public async Task SendBotMsg(string msg, GroupNames groupkey)
|
|
|
{
|
|
|
- JObject jObject = new JObject()
|
|
|
- {
|
|
|
- new JProperty("msgtype","text"),
|
|
|
- new JProperty("text",new JObject(
|
|
|
- new JProperty("content",msg)))
|
|
|
- };
|
|
|
- var content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
|
|
|
+ var content = new { msgtype = "text", text = new { content = msg } };
|
|
|
var keys = groupkey.GetDescriptionText().Split(',');
|
|
|
- if (keys.Length == 1) await _httpClient.PostAsync($"{url}{keys[0]}", content);
|
|
|
+ if (keys.Length == 1) await _httpClient.PostAsJsonAsync($"{url}{keys[0]}", content);
|
|
|
else
|
|
|
{
|
|
|
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- await _httpClient.PostAsync($"{url}{keys[0]}×tamp={timestamp}&sign={BotAddSign(keys[1], timestamp)}", content);
|
|
|
+ await _httpClient.PostAsJsonAsync($"{url}{keys[0]}×tamp={timestamp}&sign={BotAddSign(keys[1], timestamp)}", content);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -55,20 +52,13 @@ namespace TEAMModelOS.SDK.DI
|
|
|
/// <returns></returns>
|
|
|
public async Task SendBotMsg(string msg, string accesstoken, string secret = null)
|
|
|
{
|
|
|
- JObject jObject = new JObject()
|
|
|
- {
|
|
|
- new JProperty("msgtype","text"),
|
|
|
- new JProperty("text",new JObject(
|
|
|
- new JProperty("content",msg)))
|
|
|
- };
|
|
|
-
|
|
|
- var content = new StringContent(jObject.ToString(), Encoding.UTF8, "application/json");
|
|
|
+ var content = new { msgtype = "text", text = new { content = msg } };
|
|
|
if (string.IsNullOrWhiteSpace(secret))
|
|
|
- await _httpClient.PostAsync($"{url}{accesstoken}", content);
|
|
|
+ await _httpClient.PostAsJsonAsync($"{url}{accesstoken}", content);
|
|
|
else
|
|
|
{
|
|
|
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- await _httpClient.PostAsync($"{url}{accesstoken}×tamp={timestamp}&sign={BotAddSign(secret, timestamp)}", content);
|
|
|
+ await _httpClient.PostAsJsonAsync($"{url}{accesstoken}×tamp={timestamp}&sign={BotAddSign(secret, timestamp)}", content);
|
|
|
}
|
|
|
|
|
|
|