feat:第一次提交
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user