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 @@ -14,6 +14,7 @@ public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers> {
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("Best\u036e vie\u0350wers \u0337on ***")]
[TestCase("Best viewers on ***")]
[TestCase("Best viewers on ***")]
[TestCase("Best vie̮wers on ***")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class DogehypeTests : AChatRuleUnitTestBase<Dogehype> {
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("Visit dogehype dot com and watch your channel grow today! @5MGxTnYl")]
[TestCase("Visit dogehype dot com today and climb the Twitch rankings with ease! Whether you're just starting out or looking to take your stream to the next level, DogeHype has the tools you need to succeed. @gqznceDC")]
[TestCase("Visit dogehype .biz com today and climb the Twitch rankings with ease! Whether you're just starting out or looking to take your stream to the next level, DogeHype has the tools you need to succeed. @Axxq7ntz")]
public async Task TestKnownStrings(string badString) {
var rule = new Dogehype();
Expand Down
2 changes: 2 additions & 0 deletions src/Nullinside.Api.TwitchBot.Tests/ChatRules/NezhnaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class NezhnaTests : AChatRuleUnitTestBase<Nezhna> {
/// </summary>
/// <param name="badString">The string that should fail.</param>
[Test]
[TestCase("Visit nezhna .com and watch your channel grow today! @gG6SC5d3")]
[TestCase("Visit nezhna dot com to boost your viewers and climb the Twitch rankings. Join thousands of successful streamers now! @0tlVpgrw")]
[TestCase("Visit nezhna dot com com to boost your viewers and climb the Twitch rankings. Join thousands of successful streamers now! @7xgkq3EK")]
public async Task TestKnownStrings(string badString) {
var rule = new Nezhna();
Expand Down
8 changes: 2 additions & 6 deletions src/Nullinside.Api.TwitchBot/ChatRules/Nezhna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
/// Handles the "nezhna dot com" bots.
/// </summary>
public class Nezhna : AChatRule {
private const string SPAM = "Visit nezhna dot com com to boost your viewers and climb the Twitch rankings. Join thousands of successful streamers now!";
private const string SPAM = "nezhna";

/// <inheritdoc />
public override bool ShouldRun(TwitchUserConfig config) {
Expand All @@ -24,11 +24,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
return true;
}

// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
string normalized = string.Join(' ', message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
.ToLowerInvariant();

if (normalized.StartsWith(SPAM, StringComparison.InvariantCultureIgnoreCase)) {
if (message.Message.Contains(SPAM, StringComparison.InvariantCultureIgnoreCase)) {
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
"[Bot] Spam (Nezhna)", db, stoppingToken);
return false;
Expand Down