mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-04-30 03:22:04 -04:00
Because apparently being retards in the chat is lol xD lmao so funny and my patch the other day made some people mad the war has now escalated
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using Homoglyphic;
|
||||
using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
@@ -37,6 +38,7 @@ public class ChatBot
|
||||
private List<ScheduledAutoDeleteModel> _scheduledDeletions = [];
|
||||
private Task _scheduledAutoDeleteTask;
|
||||
private List<UserModel> _currentUsersInChat = [];
|
||||
private HomoglyphSearch? _homoglyphSearch;
|
||||
|
||||
public ChatBot()
|
||||
{
|
||||
@@ -95,6 +97,13 @@ public class ChatBot
|
||||
_logger.Debug("Creating scheduled auto deletion task");
|
||||
_scheduledAutoDeleteTask = ScheduledDeletionTask();
|
||||
|
||||
_logger.Debug("Trying to load homoglyphs");
|
||||
if (File.Exists("homoglyphs.csv"))
|
||||
{
|
||||
var sets = HomoglyphLoader.LoadSets("homoglyphs.csv");
|
||||
_homoglyphSearch = new HomoglyphSearch(sets);
|
||||
}
|
||||
|
||||
_logger.Debug("Blocking the main thread");
|
||||
var exitEvent = new ManualResetEvent(false);
|
||||
exitEvent.WaitOne();
|
||||
@@ -440,16 +449,36 @@ public class ChatBot
|
||||
// Strip weird control characters and just allow basic punctuation + whitespace
|
||||
var kindaSanitized = new string(message.MessageRawHtmlDecoded
|
||||
.Where(c => c == ' ' || char.IsPunctuation(c) || char.IsLetter(c) || char.IsDigit(c)).ToArray());
|
||||
var homoglyphFound = false;
|
||||
if (_homoglyphSearch != null)
|
||||
{
|
||||
var searchStrings =
|
||||
SettingsProvider.GetValueAsync(BuiltIn.Keys.BotDiscordImpersonationSearchStrings).Result
|
||||
.JsonDeserialize<List<string>>();
|
||||
var lowerStrings = searchStrings?.Select(x => x.ToLower()).ToList();
|
||||
var search = _homoglyphSearch.Search(kindaSanitized.ToLower(), lowerStrings);
|
||||
if (search.Count == 0)
|
||||
{
|
||||
search = _homoglyphSearch.Search(kindaSanitized, searchStrings);
|
||||
}
|
||||
homoglyphFound = search.Count > 0;
|
||||
}
|
||||
if ((message.MessageEditDate == null || message.MessageDate > DateTimeOffset.UtcNow.AddSeconds(-15))
|
||||
&& message.Author.Id != settings[BuiltIn.Keys.GambaSeshUserId].ToType<int>() &&
|
||||
message.Author.Username != settings[BuiltIn.Keys.KiwiFarmsUsername].Value &&
|
||||
settings[BuiltIn.Keys.BotRespondToDiscordImpersonation].ToBoolean() &&
|
||||
(kindaSanitized.Contains("discord16.png") ||
|
||||
(kindaSanitized.Contains("mBossmanJack:", StringComparison.CurrentCultureIgnoreCase) &&
|
||||
kindaSanitized.Contains("[img]", StringComparison.CurrentCultureIgnoreCase)) ||
|
||||
kindaSanitized.Contains("by @KenoGPT at", StringComparison.CurrentCultureIgnoreCase)))
|
||||
settings[BuiltIn.Keys.BotRespondToDiscordImpersonation].ToBoolean() && kindaSanitized.Contains("[img]")
|
||||
&& homoglyphFound)
|
||||
{
|
||||
SendChatMessage($"☝️ {message.Author.Username} is a nigger faggot", true);
|
||||
var deleteOrNah = SettingsProvider.GetValueAsync(BuiltIn.Keys.BotDiscordImpersonationDeleteAttempt)
|
||||
.Result.ToBoolean();
|
||||
if (deleteOrNah)
|
||||
{
|
||||
_ = KfClient.DeleteMessageAsync(message.MessageUuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendChatMessage($"☝️ {message.Author.Username} is a nigger faggot", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FlareSolverrSharp" Version="3.0.7" />
|
||||
<PackageReference Include="Homoglyphic" Version="2.0.1" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
|
||||
<PackageReference Include="Humanizer.Core" Version="3.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.3" />
|
||||
|
||||
@@ -566,6 +566,10 @@ public static class BuiltIn
|
||||
public static string ShuffleDotUsBmjUserId = "ShuffleDotUs.BmjUserId";
|
||||
[BuiltInSetting("UUID for the current MOTD message UUID", SettingValueType.Text)]
|
||||
public static string KiwiFarmsMotdUuid = "KiwiFarms.MotdUuid";
|
||||
[BuiltInSetting("Whether to delete the impersonation attempt instead of just calling it out", SettingValueType.Boolean, "false", BooleanRegex)]
|
||||
public static string BotDiscordImpersonationDeleteAttempt = "Bot.DiscordImpersonation.DeleteAttempt";
|
||||
[BuiltInSetting("What search strings the Homoglyphic searcher should look for", SettingValueType.Array, "[\"discord16.png\", \"mBossmanJack:\", \"mBossnanJack:\", \"mBosmanJack:\", \"by @KenoGPT at\"]")]
|
||||
public static string BotDiscordImpersonationSearchStrings = "Bot.DiscordImpersonation.SearchStrings";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user