Skip to content

Commit 013d0f1

Browse files
Merge pull request #100 from nullinside-development-group/chore/sync
Chore/sync
2 parents b8349d0 + e2206fa commit 013d0f1

28 files changed

+115
-141
lines changed

src/Nullinside.Api.TwitchBot.Tests/.editorconfig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ end_of_line = lf
2525
insert_final_newline = false
2626

2727
#### .NET Coding Conventions ####
28-
[*.{cs,vb}]
2928

3029
# Organize usings
3130
dotnet_separate_import_directive_groups = true
3231
dotnet_sort_system_directives_first = true
33-
file_header_template = # this. and Me. preferences
34-
35-
32+
file_header_template = unset
3633

34+
# this. and Me. preferences
3735
dotnet_style_qualification_for_event = false:silent
3836
dotnet_style_qualification_for_field = false:silent
3937
dotnet_style_qualification_for_method = false:silent
@@ -79,7 +77,6 @@ dotnet_code_quality_unused_parameters = all:suggestion
7977
dotnet_remove_unnecessary_suppression_exclusions = none
8078

8179
#### C# Coding Conventions ####
82-
[*.cs]
8380

8481
# var preferences
8582
csharp_style_var_elsewhere = false:silent
@@ -176,7 +173,6 @@ csharp_preserve_single_line_blocks = true
176173
csharp_preserve_single_line_statements = true
177174

178175
#### Naming styles ####
179-
[*.{cs,vb}]
180176

181177
# Naming rules
182178

@@ -230,19 +226,19 @@ dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelca
230226

231227
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion
232228
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields
233-
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase
229+
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = all_upper
234230

235231
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion
236232
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields
237-
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase
233+
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = all_upper
238234

239235
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion
240236
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields
241-
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase
237+
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = all_upper
242238

243239
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion
244240
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields
245-
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase
241+
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = all_upper
246242

247243
dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion
248244
dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums
@@ -366,3 +362,7 @@ dotnet_naming_style.s_camelcase.required_suffix =
366362
dotnet_naming_style.s_camelcase.word_separator =
367363
dotnet_naming_style.s_camelcase.capitalization = camel_case
368364

365+
dotnet_naming_style.all_upper.required_prefix =
366+
dotnet_naming_style.all_upper.required_suffix =
367+
dotnet_naming_style.all_upper.word_separator = _
368+
dotnet_naming_style.all_upper.capitalization = all_upper

src/Nullinside.Api.TwitchBot.Tests/ChatRules/BestCheapViewersTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers> {
4141
[TestCase("Cheaͧp v̫iewers on *** ")]
4242
[TestCase("Cheap viewers ͚on followersboosters.ru @U8y0GrKS")]
4343
[TestCase("Chea̓p viewers on streamboo. com (remove the space) @ND80DOGe")]
44-
[TestCase("Bestͮ vie͐wers ̷on cutt.ly/EeK6Anda")]
44+
[TestCase("Bestͮ vie͐wers ̷on cutt.ly/EeK6Anda")]
4545
[TestCase("Bestͮ vie͐wers ̷on viewerszone.online")]
4646
[TestCase("Best viěw\u0310e\u0329rs \u0333o\u032bno\u034en streamboo .com ( remove the space ) @WSZ7tPNI")]
4747
public async Task TestKnownStrings(string badString) {

src/Nullinside.Api.TwitchBot.Tests/Nullinside.Api.TwitchBot.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6" />
19-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.6" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6"/>
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.6"/>
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
2121
<PackageReference Include="Moq" Version="4.20.72"/>
22-
<PackageReference Include="NUnit" Version="4.3.2" />
22+
<PackageReference Include="NUnit" Version="4.3.2"/>
2323
<PackageReference Include="NUnit.Analyzers" Version="4.8.1">
2424
<PrivateAssets>all</PrivateAssets>
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
27-
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
27+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0"/>
2828
</ItemGroup>
2929

3030
<ItemGroup>

src/Nullinside.Api.TwitchBot/.editorconfig

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ end_of_line = lf
2525
insert_final_newline = false
2626

2727
#### .NET Coding Conventions ####
28-
[*.{cs,vb}]
2928

3029
# Organize usings
3130
dotnet_separate_import_directive_groups = true
@@ -78,7 +77,6 @@ dotnet_code_quality_unused_parameters = all:suggestion
7877
dotnet_remove_unnecessary_suppression_exclusions = none
7978

8079
#### C# Coding Conventions ####
81-
[*.cs]
8280

8381
# var preferences
8482
csharp_style_var_elsewhere = false:silent
@@ -175,7 +173,6 @@ csharp_preserve_single_line_blocks = true
175173
csharp_preserve_single_line_statements = true
176174

177175
#### Naming styles ####
178-
[*.{cs,vb}]
179176

180177
# Naming rules
181178

@@ -229,19 +226,19 @@ dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelca
229226

230227
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion
231228
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields
232-
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase
229+
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = all_upper
233230

234231
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion
235232
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields
236-
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase
233+
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = all_upper
237234

238235
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion
239236
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields
240-
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase
237+
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = all_upper
241238

242239
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion
243240
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields
244-
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase
241+
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = all_upper
245242

246243
dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion
247244
dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums
@@ -365,3 +362,7 @@ dotnet_naming_style.s_camelcase.required_suffix =
365362
dotnet_naming_style.s_camelcase.word_separator =
366363
dotnet_naming_style.s_camelcase.capitalization = camel_case
367364

365+
dotnet_naming_style.all_upper.required_prefix =
366+
dotnet_naming_style.all_upper.required_suffix =
367+
dotnet_naming_style.all_upper.word_separator = _
368+
dotnet_naming_style.all_upper.capitalization = all_upper

src/Nullinside.Api.TwitchBot/Bots/ABotRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ where string.Equals(bannedUsers.ChannelId, channelId) &&
6868

6969
// Perform the ban and get the list of people actually banned
7070
IEnumerable<BannedUser> confirmedBans =
71-
await botProxy.BanChannelUsers(channelId, Constants.BotId, bansToTry, reason, stoppingToken);
71+
await botProxy.BanChannelUsers(channelId, Constants.BOT_ID, bansToTry, reason, stoppingToken);
7272

7373
await db.SaveTwitchBans(channelId, users, reason, stoppingToken);
7474
return confirmedBans;

src/Nullinside.Api.TwitchBot/Bots/BanKnownBots.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,5 @@
195195
// jsonString = null;
196196
// return allBots;
197197
// }
198-
// }
198+
// }
199+

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Nullinside.Api.Model;
33
using Nullinside.Api.TwitchBot.Model;
44

5-
using TwitchLib.Client.Models;
6-
75
using TwitchUserConfig = Nullinside.Api.Model.Ddl.TwitchUserConfig;
86

97
namespace Nullinside.Api.TwitchBot.ChatRules;
@@ -31,7 +29,7 @@ public abstract Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, Tw
3129
public async Task BanAndLog(string channelId, ITwitchApiProxy botProxy,
3230
IEnumerable<(string Id, string Username)> users, string reason, INullinsideContext db,
3331
CancellationToken stoppingToken = new()) {
34-
await botProxy.BanChannelUsers(channelId, Constants.BotId, users, reason, stoppingToken);
32+
await botProxy.BanChannelUsers(channelId, Constants.BOT_ID, users, reason, stoppingToken);
3533
await db.SaveTwitchBans(channelId, users, reason, stoppingToken);
3634
}
3735
}

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Nullinside.Api.Model;
33
using Nullinside.Api.TwitchBot.Model;
44

5-
using TwitchLib.Client.Models;
6-
75
using TwitchUserConfig = Nullinside.Api.Model.Ddl.TwitchUserConfig;
86

97
namespace Nullinside.Api.TwitchBot.ChatRules;
@@ -13,15 +11,15 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1311
/// </summary>
1412
public class BestCheapViewers : AChatRule {
1513
/// <summary>
16-
/// The strings that we expect to receive if this is a bot.
14+
/// The strings that we expect to receive if this is a bot.
1715
/// </summary>
18-
public readonly string[] EXPECTED = [
19-
"best viewers on",
16+
public readonly string[] Expected = [
17+
"best viewers on",
2018
"cheap viewers on",
2119
"cheap folloewrs on",
2220
"do you want more viewers and to rank higher on the twitch list? you can visit the website"
2321
];
24-
22+
2523
/// <inheritdoc />
2624
public override bool ShouldRun(TwitchUserConfig config) {
2725
return config is { Enabled: true, BanKnownBots: true };
@@ -33,23 +31,23 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
3331
if (!message.IsFirstMessage) {
3432
return true;
3533
}
36-
34+
3735
// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
3836
string normalized = string.Join(' ', message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
3937
.ToLowerInvariant();
4038

4139
// Messages will be one of two variations with random special characters mixed in. Some of those special characters
4240
// will be accent marks. When we receive an accent mark it'll take the position of a real character, hence why we
4341
// need an offset applied only to the incoming string.
44-
foreach (var expected in EXPECTED) {
42+
foreach (string expected in Expected) {
4543
if (normalized.Length > expected.Length) {
4644
int matches = 0;
4745
int offset = 0;
4846
for (int i = 0; i < expected.Length; i++) {
4947
// If this is a normal character it should be in the correct position.
5048
if (i + offset < normalized.Length && normalized[i + offset] == expected[i]) {
5149
++matches;
52-
}
50+
}
5351
// If this is an accent mark then the next character should match and the whole string we're evalutating
5452
// will be off by 1 more position.
5553
else if (i + offset + 1 < normalized.Length && normalized[i + offset + 1] == expected[i]) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Nullinside.Api.Model;
33
using Nullinside.Api.TwitchBot.Model;
44

5-
using TwitchLib.Client.Models;
6-
75
using TwitchUserConfig = Nullinside.Api.Model.Ddl.TwitchUserConfig;
86

97
namespace Nullinside.Api.TwitchBot.ChatRules;

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Nullinside.Api.Model;
33
using Nullinside.Api.TwitchBot.Model;
44

5-
using TwitchLib.Client.Models;
6-
75
using TwitchUserConfig = Nullinside.Api.Model.Ddl.TwitchUserConfig;
86

97
namespace Nullinside.Api.TwitchBot.ChatRules;
@@ -12,7 +10,7 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1210
/// Handles the add me on discord bots.
1311
/// </summary>
1412
public class Discord : AChatRule {
15-
private readonly string[] KNOWN_PHRASES = [
13+
private readonly string[] _knownPhrases = [
1614
"add me",
1715
"add my",
1816
"add up",
@@ -38,7 +36,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
3836
if (!message.IsFirstMessage) {
3937
return true;
4038
}
41-
39+
4240
// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
4341
string normalized = string.Join(' ', message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
4442
.ToLowerInvariant();
@@ -47,7 +45,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
4745
return true;
4846
}
4947

50-
foreach (var phrase in KNOWN_PHRASES) {
48+
foreach (string phrase in _knownPhrases) {
5149
if (normalized.Contains(phrase, StringComparison.InvariantCultureIgnoreCase)) {
5250
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
5351
"[Bot] Spam (Discord Scammers)", db, stoppingToken);

0 commit comments

Comments
 (0)