You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using Flurl.Http;
|
|
using NapCatRobotClient.Core.RobotAPI.Dto.Request;
|
|
|
|
namespace NapCatRobotClient.Core.RobotAPI
|
|
{
|
|
public class RobotAPI
|
|
{
|
|
/// <summary>
|
|
/// 发送群文本消息
|
|
/// </summary>
|
|
/// <param name="groupId"></param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public static async Task<string> SendGroupText(GroupSendMessageRequest request)
|
|
{
|
|
return await Post(JsonConvert.SerializeObject(request), "/send_group_msg");
|
|
}
|
|
|
|
private static async Task<string> Post(string parameters, string action)
|
|
{
|
|
string url = App.Configuration["QQConfig:SendApiUrl"] + action;
|
|
string response = await url.WithHeader("Authorization", "Bearer " + App.Configuration["QQConfig:AccessToken"])
|
|
.WithHeader("Content-Type", "application/json;charset=utf-8")
|
|
.PostStringAsync(parameters)
|
|
.ReceiveString();
|
|
Console.WriteLine($"{DateTime.Now} 请求地址:{url} 请求结果:{response}");
|
|
return response;
|
|
}
|
|
}
|
|
}
|