Skip to content

Commit d463d6e

Browse files
Adding hosthub spam
1 parent 8f72ba7 commit d463d6e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
/// Handles "hosthub.vip" spam.
11+
/// </summary>
12+
public class HostHub : AChatRule {
13+
/// <inheritdoc />
14+
public override bool ShouldRun(TwitchUserConfig config) {
15+
return config is { Enabled: true, BanKnownBots: true };
16+
}
17+
18+
/// <inheritdoc />
19+
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
20+
NullinsideContext db, CancellationToken stoppingToken = new()) {
21+
// The number of spaces per message may change, so normalize that and lowercase it for comparison.
22+
string normalized = string.Concat(message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
23+
.ToLowerInvariant();
24+
25+
// Message will contain the site name with different domains.
26+
if (message.IsFirstMessage && normalized.Contains("hosthub.")) {
27+
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
28+
"[Bot] Spam (HostHub)", db, stoppingToken);
29+
return false;
30+
}
31+
32+
return true;
33+
}
34+
}

0 commit comments

Comments
 (0)