Skip to content

Commit 17af808

Browse files
Merge pull request #34 from nullinside-development-group/feature/DiscordScams
if you want viewer spam
2 parents 682fbbc + bd05cf7 commit 17af808

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/Nullinside.Api.TwitchBot/ChatRules/BestCheapViewers.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ public class BestCheapViewers : AChatRule {
1313
/// <summary>
1414
/// The strings that we expect to receive if this is a bot.
1515
/// </summary>
16-
public readonly string[] EXPECTED = ["best viewers on", "cheap viewers on"];
16+
public readonly string[] EXPECTED = [
17+
"best viewers on",
18+
"cheap viewers on"
19+
];
1720

1821
/// <inheritdoc />
1922
public override bool ShouldRun(TwitchUserConfig config) {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Nullinside.Api.Common.Twitch;
2+
using Nullinside.Api.Model;
3+
using Nullinside.Api.Model.Ddl;
4+
5+
using TwitchLib.Client.Models;
6+
7+
namespace Nullinside.Api.TwitchBot.ChatRules;
8+
9+
/// <summary>
10+
/// "if you want viewers, go to [link]" scam.
11+
/// </summary>
12+
public class IfYouWantViewers : AChatRule {
13+
/// <summary>
14+
/// The strings that we expect to receive if this is a bot.
15+
/// </summary>
16+
public readonly string[] EXPECTED = [
17+
"if you want more viewers for your stream, go to"
18+
];
19+
20+
/// <inheritdoc />
21+
public override bool ShouldRun(TwitchUserConfig config) {
22+
return config is { Enabled: true, BanKnownBots: true };
23+
}
24+
25+
/// <inheritdoc />
26+
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
27+
NullinsideContext db, CancellationToken stoppingToken = new()) {
28+
if (!message.IsFirstMessage) {
29+
return true;
30+
}
31+
32+
// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
33+
string normalized = string.Join(' ', message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
34+
.ToLowerInvariant();
35+
36+
foreach (var expected in EXPECTED) {
37+
if (normalized.Contains(expected, StringComparison.InvariantCultureIgnoreCase)) {
38+
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
39+
"[Bot] Spam (If You Want Viewers)", db, stoppingToken);
40+
return false;
41+
}
42+
}
43+
44+
return true;
45+
}
46+
}

0 commit comments

Comments
 (0)