Files
NapCatRobot/NapCatRobotClient/NapCatRobotClient.API/Controllers/EntryController.cs
T

34 lines
1.9 KiB
C#

using Furion.Logging;
using Microsoft.AspNetCore.Mvc;
using NapCatRobotClient.Service.Dispatcher.Service;
namespace NapCatRobotClient.API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class EntryController : ControllerBase
{
private readonly IDispatcherService _dispatcherService;
public EntryController(IDispatcherService dispatcherService)
{
_dispatcherService = dispatcherService;
}
/// <summary>
/// 接收消息入口
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> Post()
{
using StreamReader reader = new(Request.Body);
string body = await reader.ReadToEndAsync();
Log.Information($"接收到群消息:{body} \r\n");
body = "{\"self_id\":3902582794,\"user_id\":3889001741,\"time\":1781882943,\"message_id\":650215683,\"message_seq\":650215683,\"real_id\":650215683,\"real_seq\":\"1698687\",\"message_type\":\"group\",\"sender\":{\"user_id\":3889001741,\"nickname\":\"小小\",\"card\":\"\",\"role\":\"member\"},\"raw_message\":\"[CQ:markdown,content=&#91;&#93;(%7B%22version%22%3A2%7D)\\n道友的灵田还不能收取,下次收取时间为:44.77小时之后]道友的灵田还不能收取,下次收取时间为:44.77小时之后\",\"font\":14,\"sub_type\":\"normal\",\"message\":[{\"type\":\"markdown\",\"data\":{\"content\":\"[](%7B%22version%22%3A2%7D)\\n道友的灵田还不能收取,下次收取时间为:44.77小时之后\"}},{\"type\":\"text\",\"data\":{\"text\":\"道友的灵田还不能收取,下次收取时间为:44.77小时之后\"}}],\"message_format\":\"array\",\"post_type\":\"message\",\"group_id\":285855428,\"group_name\":\"??????颂我名者轮回得永生??????\"}";
bool result = await _dispatcherService.ReceiveMessageAndProcess(body);
return Ok(result);
}
}
}