Skip to content

Commit

Permalink
Update message reply and remove emotes functions
Browse files Browse the repository at this point in the history
The TwitchWorker has been refactored to ensure that the bot only responds to the same message after 5 minutes. This log is updated to reflect the new rule. Also, the RemoveEmotes function's access modifier has been changed to private to restrict its access.
  • Loading branch information
BillChirico committed Dec 11, 2023
1 parent 9026aab commit 62b015d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/GolfClapBot.Runner/TwitchWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ private async Task TwitchClientOnMessageReceived(object? sender, OnMessageReceiv
return;
}

if (_bot.RepliedMessages.Contains(m))
if (_bot.RepliedMessages.Contains(m) && _sentMessages.Find(message => message.Message == m)?.TmiSent >
DateTime.UtcNow.AddMinutes(-5))
{
_logger.LogInformation("Bot has already replied to message: {Message}", m);
_logger.LogInformation("Bot has already replied to the same message within five minutes: {Message}", m);

await DeleteMessage(e.ChatMessage);

Expand Down Expand Up @@ -159,7 +160,7 @@ private Task SendMessage(string message, string username = "")
/// </summary>
/// <param name="message">The chat message containing the emotes.</param>
/// <returns>The chat message with emotes removed.</returns>
public static string RemoveEmotes(ChatMessage message)
private static string RemoveEmotes(ChatMessage message)
{
StringBuilder parsed = new(message.Message);

Expand Down

0 comments on commit 62b015d

Please sign in to comment.