Skip to content

Commit 56783ee

Browse files
Merge pull request #51 from nullinside-development-group/feature/ChatDisconnect
Adding debugging methods for chat
2 parents 8b89ad1 + 2b76267 commit 56783ee

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using log4net;
44

5+
using Microsoft.AspNetCore.Authorization;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.EntityFrameworkCore;
78

@@ -132,6 +133,24 @@ public async Task<IActionResult> GetConfig(CancellationToken token) {
132133
BanKnownBots = config.BanKnownBots
133134
});
134135
}
136+
137+
/// <summary>
138+
/// Gets the timestamp of the last time a chat message was received.
139+
/// </summary>
140+
/// <param name="token">The cancellation token.</param>
141+
/// <returns>The timestamp of the last message received.</returns>
142+
[AllowAnonymous]
143+
[HttpGet]
144+
[Route("chat/timestamp")]
145+
public async Task<IActionResult> GetLastChatTimestamp(CancellationToken token) {
146+
var message =
147+
await _dbContext.TwitchUserChatLogs.OrderByDescending(c => c.Timestamp).FirstOrDefaultAsync(token);
148+
if (null == message) {
149+
return StatusCode(500);
150+
}
151+
152+
return Ok(message.Timestamp);
153+
}
135154

136155
/// <summary>
137156
/// Updates the configuration.

src/nullinside-api

0 commit comments

Comments
 (0)