clear out detiktokable links when done

fixes #18
This commit is contained in:
Adam R Grey 2023-08-22 14:58:44 -04:00
parent e9ddcd237c
commit da7078f535
3 changed files with 33 additions and 28 deletions

View File

@ -45,6 +45,7 @@ public class Behaver
{
behavior.ActOn(message);
message.ActedOn = true;
Console.WriteLine("acted on, moving forward");
}
}
if (message.ActedOn == false && message.MentionsMe && message.Content.Contains('?') && !Behaver.Instance.Selves.Any(acc => acc.Id == message.Author.Id))
@ -57,10 +58,6 @@ public class Behaver
await message.Channel.SendMessage(responses[Shared.r.Next(responses.Count)]);
message.ActedOn = true;
}
if (message.ActedOn)
{
_db.SaveChanges();
}
return message.ActedOn;
}
}

View File

@ -44,12 +44,16 @@ public class Detiktokify : Behavior
}
}
}
if(tiktokLinks.Any()){
Console.WriteLine($"Should Act on message id {message.ExternalId}; with content {message.Content}");
}
return tiktokLinks.Any();
}
public override async Task<bool> ActOn(Message message)
{
foreach(var link in tiktokLinks)
{
tiktokLinks.Remove(link);
try
{
Console.WriteLine($"detiktokifying {link}");

View File

@ -92,30 +92,34 @@ public class TwitchInterface
private async void Client_OnWhisperReceivedAsync(object sender, OnWhisperReceivedArgs e)
{
Console.WriteLine($"whisper#{e.WhisperMessage.Username}[{DateTime.Now}][{e.WhisperMessage.DisplayName} [id={e.WhisperMessage.Username}]][msg id: {e.WhisperMessage.MessageId}] {e.WhisperMessage.Message}");
if (_db.Messages.Select(m => m.ExternalId == e.WhisperMessage.MessageId) != null)
{
Console.WriteLine("already seent it");
return;
}
var m = UpsertMessage(e.WhisperMessage);
m.Channel.IsDM = true;
m.MentionsMe = Regex.IsMatch(e.WhisperMessage.Message?.ToLower(), $"\\b@{e.WhisperMessage.BotUsername.ToLower()}\\b");
_db.SaveChanges();
if (await Behaver.Instance.ActOn(m))
{
m.ActedOn = true;
}
await Behaver.Instance.ActOn(m);
_db.SaveChanges();
}
private async void Client_OnMessageReceivedAsync(object sender, OnMessageReceivedArgs e)
{
Console.WriteLine($"#{e.ChatMessage.Channel}[{DateTime.Now}][{e.ChatMessage.DisplayName} [id={e.ChatMessage.Username}]][msg id: {e.ChatMessage.Id}] {e.ChatMessage.Message}");
if (_db.Messages.Select(m => m.ExternalId == e.ChatMessage.Id) != null)
{
Console.WriteLine("already seent it");
return;
}
var m = UpsertMessage(e.ChatMessage);
m.MentionsMe = Regex.IsMatch(e.ChatMessage.Message?.ToLower(), $"@{e.ChatMessage.BotUsername.ToLower()}\\b") ||
e.ChatMessage.ChatReply?.ParentUserLogin == e.ChatMessage.BotUsername;
_db.SaveChanges();
if (await Behaver.Instance.ActOn(m))
{
m.ActedOn = true;
}
await Behaver.Instance.ActOn(m);
_db.SaveChanges();
}