Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers> {
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("B\u0366est vie\u031fwers on streamboo .com ( remove the space ) @IBjZQcD1")]
[TestCase("Cheap \u0314Viewers on streamboo .com ( remove the space ) @kX9lOgg1")]
[TestCase("B͐est vi̯ewers o͎n on streamboo .com ( remove the space ) @9F3Wnft0")]
[TestCase("Ch̚eͅap viewers on *** @STGPMoLg")]
[TestCase("C̭heap viewe͌rs on̆ *** @R1QXrXPM")]
Expand Down
28 changes: 28 additions & 0 deletions src/Nullinside.Api.TwitchBot.Tests/ChatRules/BotsisterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Moq;

using Nullinside.Api.Common.Twitch;
using Nullinside.Api.TwitchBot.ChatRules;
using Nullinside.Api.TwitchBot.Model;

namespace Nullinside.Api.TwitchBot.Tests.ChatRules;

/// <summary>
/// Tests the <see cref="Botsister" /> class.
/// </summary>
public class BotsisterTests : AChatRuleUnitTestBase<Botsister> {
/// <summary>
/// Tests the strings typed in chats.
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("Your chat’s so empty, it’s giving ‘no signal’ vibes. Fix it with botsister .com @uFi5gGov")]
public async Task TestKnownStrings(string badString) {
var rule = new Botsister();
var botProxy = new Mock<ITwitchApiProxy>();
var chat = new TwitchChatMessage(true, badString, "123", "456");

// Process the message and assert that we fail the message.
bool result = await rule.Handle("123", botProxy.Object, chat, _db);
Assert.That(result, Is.False);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class DiscordTests : AChatRuleUnitTestBase<Discord> {
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("Yo bruh \u2764\ufe0f let's sometimes play together and share tips add up on discord \ud83d\udc49 willam0340")]
[TestCase("Hello mate you stream pretty cool that's why I follow I would love to be a fan of yours if you don't mind kindly add me on Discord: 👉👉lacaster5")]
[TestCase("Hello, I just recently found your channel and can already tell that your content is great, and I would love to stick with you long term. If you're open to it, I'd be willing to connect with you on Discord. My username is teecash1000")]
[TestCase("Hey there 👋 You stream pretty cool that’s why I followed you. I will like to make you a friend and be a fan, if you don’t mind Kindly chat me on Discord, my Discord username is tuckzay")]
Expand Down
36 changes: 36 additions & 0 deletions src/Nullinside.Api.TwitchBot/ChatRules/Botsister.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Nullinside.Api.Common.Twitch;
using Nullinside.Api.Model;
using Nullinside.Api.TwitchBot.Model;

using TwitchLib.Client.Models;

using TwitchUserConfig = Nullinside.Api.Model.Ddl.TwitchUserConfig;

namespace Nullinside.Api.TwitchBot.ChatRules;

/// <summary>
/// Handles "botsister" spam.
/// </summary>
public class Botsister : AChatRule {
/// <inheritdoc />
public override bool ShouldRun(TwitchUserConfig config) {
return config is { Enabled: true, BanKnownBots: true };
}

/// <inheritdoc />
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, TwitchChatMessage message,
INullinsideContext db, CancellationToken stoppingToken = new()) {
// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
string normalized = string.Concat(message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
.ToLowerInvariant();

// Message will start with any of these variations.
if (message.IsFirstMessage && normalized.Contains("botsister")) {
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
"[Bot] Spam (Botsister)", db, stoppingToken);
return false;
}

return true;
}
}
3 changes: 2 additions & 1 deletion src/Nullinside.Api.TwitchBot/ChatRules/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class Discord : AChatRule {
"chat with me",
"my discord username",
"my username",
"connect on discord"
"connect on discord",
"add up"
];

/// <inheritdoc />
Expand Down