Skip to content

Commit 18d62f2

Browse files
wip
1 parent da3b1f2 commit 18d62f2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Nullinside.Api.TwitchBot/Controllers/TwitchWebHookController.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
using System.Net;
2+
13
using log4net;
24

35
using Microsoft.AspNetCore.Authorization;
46
using Microsoft.AspNetCore.Mvc;
57

8+
using Newtonsoft.Json;
9+
10+
using Nullinside.Api.TwitchBot.Model;
11+
612
namespace Nullinside.Api.TwitchBot.Controllers;
713

814
/// <summary>
@@ -24,10 +30,18 @@ public class TwitchWebHookController : ControllerBase {
2430
/// <returns></returns>
2531
[HttpPost]
2632
[Route("chat")]
27-
public async Task<IActionResult> TwitchChatMessageCallback(CancellationToken token) {
33+
public async Task<HttpResponseMessage> TwitchChatMessageCallback(CancellationToken token) {
2834
using StreamReader stream = new StreamReader(this.HttpContext.Request.Body);
2935
string stuff = await stream.ReadToEndAsync(token);
3036
_log.Info($"TwitchChatMessageCallback: {stuff}");
31-
return Ok(true);
37+
38+
var hi =JsonConvert.DeserializeObject<TwitchChallange>(stuff);
39+
if (null != hi) {
40+
var resp = new HttpResponseMessage(HttpStatusCode.OK);
41+
resp.Content = new StringContent(hi.Challenge?.ToString() ?? string.Empty, System.Text.Encoding.UTF8, "text/plain");
42+
return resp;
43+
}
44+
45+
return new HttpResponseMessage(HttpStatusCode.OK);
3246
}
3347
}

0 commit comments

Comments
 (0)