File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
src/Nullinside.Api.TwitchBot/Controllers Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1+ using System . Net ;
2+
13using log4net ;
24
35using Microsoft . AspNetCore . Authorization ;
46using Microsoft . AspNetCore . Mvc ;
57
8+ using Newtonsoft . Json ;
9+
10+ using Nullinside . Api . TwitchBot . Model ;
11+
612namespace 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}
You can’t perform that action at this time.
0 commit comments