forked from adam/discord-bot-shtik
parent
e9ddcd237c
commit
da7078f535
@ -45,6 +45,7 @@ public class Behaver
|
|||||||
{
|
{
|
||||||
behavior.ActOn(message);
|
behavior.ActOn(message);
|
||||||
message.ActedOn = true;
|
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))
|
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)]);
|
await message.Channel.SendMessage(responses[Shared.r.Next(responses.Count)]);
|
||||||
message.ActedOn = true;
|
message.ActedOn = true;
|
||||||
}
|
}
|
||||||
if (message.ActedOn)
|
|
||||||
{
|
|
||||||
_db.SaveChanges();
|
|
||||||
}
|
|
||||||
return message.ActedOn;
|
return message.ActedOn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
return tiktokLinks.Any();
|
||||||
}
|
}
|
||||||
public override async Task<bool> ActOn(Message message)
|
public override async Task<bool> ActOn(Message message)
|
||||||
{
|
{
|
||||||
foreach(var link in tiktokLinks)
|
foreach(var link in tiktokLinks)
|
||||||
{
|
{
|
||||||
|
tiktokLinks.Remove(link);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"detiktokifying {link}");
|
Console.WriteLine($"detiktokifying {link}");
|
||||||
|
@ -92,30 +92,34 @@ public class TwitchInterface
|
|||||||
private async void Client_OnWhisperReceivedAsync(object sender, OnWhisperReceivedArgs e)
|
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}");
|
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);
|
var m = UpsertMessage(e.WhisperMessage);
|
||||||
m.Channel.IsDM = true;
|
m.Channel.IsDM = true;
|
||||||
|
|
||||||
m.MentionsMe = Regex.IsMatch(e.WhisperMessage.Message?.ToLower(), $"\\b@{e.WhisperMessage.BotUsername.ToLower()}\\b");
|
m.MentionsMe = Regex.IsMatch(e.WhisperMessage.Message?.ToLower(), $"\\b@{e.WhisperMessage.BotUsername.ToLower()}\\b");
|
||||||
|
_db.SaveChanges();
|
||||||
|
|
||||||
if (await Behaver.Instance.ActOn(m))
|
await Behaver.Instance.ActOn(m);
|
||||||
{
|
|
||||||
m.ActedOn = true;
|
|
||||||
}
|
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Client_OnMessageReceivedAsync(object sender, OnMessageReceivedArgs e)
|
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}");
|
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);
|
var m = UpsertMessage(e.ChatMessage);
|
||||||
|
|
||||||
m.MentionsMe = Regex.IsMatch(e.ChatMessage.Message?.ToLower(), $"@{e.ChatMessage.BotUsername.ToLower()}\\b") ||
|
m.MentionsMe = Regex.IsMatch(e.ChatMessage.Message?.ToLower(), $"@{e.ChatMessage.BotUsername.ToLower()}\\b") ||
|
||||||
e.ChatMessage.ChatReply?.ParentUserLogin == e.ChatMessage.BotUsername;
|
e.ChatMessage.ChatReply?.ParentUserLogin == e.ChatMessage.BotUsername;
|
||||||
|
_db.SaveChanges();
|
||||||
|
|
||||||
if (await Behaver.Instance.ActOn(m))
|
await Behaver.Instance.ActOn(m);
|
||||||
{
|
|
||||||
m.ActedOn = true;
|
|
||||||
}
|
|
||||||
_db.SaveChanges();
|
_db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user