Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Nullinside.Api.TwitchBot/Controllers/BotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using log4net;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -132,6 +133,24 @@ public async Task<IActionResult> GetConfig(CancellationToken token) {
BanKnownBots = config.BanKnownBots
});
}

/// <summary>
/// Gets the timestamp of the last time a chat message was received.
/// </summary>
/// <param name="token">The cancellation token.</param>
/// <returns>The timestamp of the last message received.</returns>
[AllowAnonymous]
[HttpGet]
[Route("chat/timestamp")]
public async Task<IActionResult> GetLastChatTimestamp(CancellationToken token) {
var message =
await _dbContext.TwitchUserChatLogs.OrderByDescending(c => c.Timestamp).FirstOrDefaultAsync(token);
if (null == message) {
return StatusCode(500);
}

return Ok(message.Timestamp);
}

/// <summary>
/// Updates the configuration.
Expand Down
2 changes: 1 addition & 1 deletion src/nullinside-api
Loading