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
+
1
3
using log4net ;
2
4
3
5
using Microsoft . AspNetCore . Authorization ;
4
6
using Microsoft . AspNetCore . Mvc ;
5
7
8
+ using Newtonsoft . Json ;
9
+
10
+ using Nullinside . Api . TwitchBot . Model ;
11
+
6
12
namespace Nullinside . Api . TwitchBot . Controllers ;
7
13
8
14
/// <summary>
@@ -24,10 +30,18 @@ public class TwitchWebHookController : ControllerBase {
24
30
/// <returns></returns>
25
31
[ HttpPost ]
26
32
[ Route ( "chat" ) ]
27
- public async Task < IActionResult > TwitchChatMessageCallback ( CancellationToken token ) {
33
+ public async Task < HttpResponseMessage > TwitchChatMessageCallback ( CancellationToken token ) {
28
34
using StreamReader stream = new StreamReader ( this . HttpContext . Request . Body ) ;
29
35
string stuff = await stream . ReadToEndAsync ( token ) ;
30
36
_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 ) ;
32
46
}
33
47
}
You can’t perform that action at this time.
0 commit comments