Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into anti-flashy-emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisa committed Jun 14, 2021
2 parents e6d6e53 + 3c0d89e commit 0932a1a
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 60 deletions.
9 changes: 6 additions & 3 deletions Cliptok.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RestoreAdditionalProjectSources>
https://nuget.emzi0767.com/api/v3/index.json
</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abyssal.HumanDateParser" Version="2.0.0-20191113.1" />
<PackageReference Include="DSharpPlus" Version="4.0.1" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.1" />
<PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="1.2.4" />
<PackageReference Include="DSharpPlus" Version="4.1.0-nightly-00879" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.1.0-nightly-00879" />
<PackageReference Include="IDoEverything.DSharpPlus.SlashCommands" Version="1.4.0" />
<PackageReference Include="StackExchange.Redis" Version="2.2.4" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="System.Linq" Version="4.3.0" />
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM --platform=${BUILDPLATFORM} \
mcr.microsoft.com/dotnet/sdk:5.0.300 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:5.0.301 AS build-env
WORKDIR /app

# We need Git for Cliptok builds now.
Expand All @@ -14,7 +13,7 @@ COPY . ./
RUN dotnet build -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:5.0.6-alpine3.13
FROM mcr.microsoft.com/dotnet/runtime:5.0.7-alpine3.13
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Cliptok.dll"]
14 changes: 14 additions & 0 deletions Lists/scams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
hi friend, today i am leaving this
fucking game with a bunch of cheaters and an aggressive community
strearmcommunity.ru
steamcomunitty.ru
streancommunuty.ru
.ru/tradoffer/new/?partner
giving away my skins to people who send trade offers
don't be greedy and take few skins
give away my 3 knifes
hi i'm back and now i'm leaving all games
if you need my skins or steam items
steancomunnity.ru
csgocyber.ru
found a simple referral and you can loot skins there
4 changes: 2 additions & 2 deletions Modules/ConfigJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public struct ConfigJson
public List<string> RestrictedHeartosoftPhrases { get; private set; }

[JsonProperty("autoDehoistCharacters")]
public List<char> AutoDehoistCharacters { get; private set; }
public string AutoDehoistCharacters { get; private set; }

[JsonProperty("investigationsChannel")]
public ulong InvestigationsChannelId { get; private set; }
Expand Down Expand Up @@ -174,7 +174,7 @@ public class SeizureDetectionConfig
public int MassMentionBanThreshold { get; private set; }

[JsonProperty("secondaryAutoDehoistCharacters")]
public List<char> SecondaryAutoDehoistCharacters { get; private set; }
public string SecondaryAutoDehoistCharacters { get; private set; }

[JsonProperty("modmailUserId")]
public ulong ModmailUserId { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion Modules/GenericModCmds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static async Task<bool> BanFromServerAsync(ulong targetUserId, string rea
foreach (KeyValuePair<ulong, DiscordChannel> potentialChannelPair in guild.Channels)
{
var potentialChannel = potentialChannelPair.Value;
if (potentialChannel.Type == ChannelType.Text && potentialChannel.Topic.EndsWith($"User ID: {targetUserId}")) {
if (potentialChannel.Type == ChannelType.Text && potentialChannel.Topic != null && potentialChannel.Topic.EndsWith($"User ID: {targetUserId}")) {
await potentialChannel.SendMessageAsync(logOut);
break;
}
Expand Down
8 changes: 6 additions & 2 deletions Modules/SlashCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ public async Task BanSlashCommand(InteractionContext ctx,

[SlashCommand("warnings", "Fetch the warnings for a user.")]
public async Task WarningsSlashCommand(InteractionContext ctx,
[Option("user", "The user to find the warnings for.")] DiscordUser user
[Option("user", "The user to find the warnings for.")] DiscordUser user,
[Option("private", "Whether to show the warnings to you privately.")] bool privateWarnings = false
)
{
var eout = new DiscordInteractionResponseBuilder().AsEphemeral(false).AddEmbed(Warnings.GenerateWarningsEmbed(user));
var eout = new DiscordInteractionResponseBuilder().AddEmbed(Warnings.GenerateWarningsEmbed(user));
if (privateWarnings)
eout.AsEphemeral(true);

await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, eout);
}

Expand Down
35 changes: 28 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Program : BaseCommandModule
readonly static Regex id_rx = new Regex("([0-9]{1,32}>)");
readonly static Regex modmaiL_rx = new Regex("User ID: ([0-9]+)");
public static Dictionary<ulong, DateTime> supportRatelimit = new Dictionary<ulong, DateTime>();
public static List<ulong> autoBannedUsersCache = new List<ulong>();

static bool CheckForNaughtyWords(string input, WordListJson naughtyWordList)
{
Expand Down Expand Up @@ -268,10 +269,12 @@ async Task OnReady(DiscordClient client, ReadyEventArgs e)
$"```\n" +
$"{commitMessage}\n" +
$"```");

}

async Task MessageCreated(DiscordClient client, MessageCreateEventArgs e)
{
{

if (e.Author.Id == cfgjson.ModmailUserId && e.Message.Content == "@here" && e.Message.Embeds[0].Footer.Text.Contains("User ID:"))
{
var idString = modmaiL_rx.Match(e.Channel.Topic).Groups[1].Captures[0].Value;
Expand Down Expand Up @@ -543,10 +546,30 @@ async Task MessageCreated(DiscordClient client, MessageCreateEventArgs e)

async Task UsernameCheckAsync(DiscordMember member)
{
if (badUsernames.Contains(member.Username))
foreach (var username in badUsernames)
{
var guild = await discord.GetGuildAsync(cfgjson.ServerID);
await ModCmds.BanFromServerAsync(member.Id, "Automatic ban for matching patterns of common bot accounts. Please appeal if you are a human.", discord.CurrentUser.Id, guild, 7, null, default, true);
// emergency failsafe, for newlines and other mistaken entries
if (username.Length < 4)
continue;

if (member.Username.ToLower().Contains(username.ToLower()))
{
if (autoBannedUsersCache.Contains(member.Id))
break;
autoBannedUsersCache.Append(member.Id);
var guild = await discord.GetGuildAsync(cfgjson.ServerID);
await ModCmds.BanFromServerAsync(member.Id, "Automatic ban for matching patterns of common bot accounts. Please appeal if you are a human.", discord.CurrentUser.Id, guild, 7, null, default, true);
var embed = new DiscordEmbedBuilder()
.WithTimestamp(DateTime.Now)
.WithFooter($"User ID: {member.Id}", null)
.WithAuthor($"{member.Username}#{member.Discriminator}", null, member.AvatarUrl)
.AddField("Infringing name", member.Username)
.AddField("Matching pattern", username)
.WithColor(new DiscordColor(0xf03916));
var investigations = await discord.GetChannelAsync(cfgjson.InvestigationsChannelId);
await investigations.SendMessageAsync($"{cfgjson.Emoji.Banned} {member.Mention} was banned for matching blocked username patterns.", embed);
break;
}
}
}

Expand Down Expand Up @@ -583,9 +606,7 @@ async Task GuildMemberAdded(DiscordClient client, GuildMemberAddEventArgs e)
DiscordRole mutedRole = e.Guild.GetRole(cfgjson.MutedRole);
await e.Member.GrantRoleAsync(mutedRole, "Reapplying mute: possible mute evasion.");
}
await CheckAndDehoistMemberAsync(e.Member);

await UsernameCheckAsync(e.Member);
CheckAndDehoistMemberAsync(e.Member);;
}

async Task GuildMemberUpdated(DiscordClient client, GuildMemberUpdateEventArgs e)
Expand Down
54 changes: 12 additions & 42 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
"microsoft",
"xbox",
"FjJfTZdtXg",
"cMxFErsEDB"
"cMxFErsEDB",
"apple",
"google",
"iphone",
"directx",
"winadmins"
],
"autoMuteThresholds": {
"2": 6,
Expand Down Expand Up @@ -87,6 +92,10 @@
"autoban.txt": {
"wholeWord": false,
"reason": "[Automatic] Suspected to be following the patterns of known raiders."
},
"scams.txt": {
"wholeWord": false,
"reason": "Attempted scam message"
}
},
"massEmojiThreshold": 6,
Expand Down Expand Up @@ -130,45 +139,6 @@
"413429915187281940",
"544153359712649251"
],
"autoDehoistCharacters": [
"!",
"\"",
"#",
"$",
"%",
"^",
"&",
"'",
"(",
")",
"*",
"+",
",",
"-",
".",
"/",
":",
";",
"<",
">",
"?",
"@",
"[",
"\\",
"^",
"_",
"`"
],
"secondaryAutoDehoistCharacters": [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]
"autoDehoistCharacters": " !\"#$%&'()*+,-./:;<=>?@[\\]^_`'",
"secondaryAutoDehoistCharacters": "0123456789"
}

0 comments on commit 0932a1a

Please sign in to comment.