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