Skip to content

Commit e2206fa

Browse files
chore: variable renames
1 parent b1a0091 commit e2206fa

File tree

13 files changed

+46
-46
lines changed

13 files changed

+46
-46
lines changed

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/ChatRules/AChatRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, Tw
2929
public async Task BanAndLog(string channelId, ITwitchApiProxy botProxy,
3030
IEnumerable<(string Id, string Username)> users, string reason, INullinsideContext db,
3131
CancellationToken stoppingToken = new()) {
32-
await botProxy.BanChannelUsers(channelId, Constants.BotId, users, reason, stoppingToken);
32+
await botProxy.BanChannelUsers(channelId, Constants.BOT_ID, users, reason, stoppingToken);
3333
await db.SaveTwitchBans(channelId, users, reason, stoppingToken);
3434
}
3535
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class BestCheapViewers : AChatRule {
1313
/// <summary>
1414
/// The strings that we expect to receive if this is a bot.
1515
/// </summary>
16-
public readonly string[] EXPECTED = [
16+
public readonly string[] Expected = [
1717
"best viewers on",
1818
"cheap viewers on",
1919
"cheap folloewrs on",
@@ -39,7 +39,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
3939
// Messages will be one of two variations with random special characters mixed in. Some of those special characters
4040
// will be accent marks. When we receive an accent mark it'll take the position of a real character, hence why we
4141
// need an offset applied only to the incoming string.
42-
foreach (string expected in EXPECTED) {
42+
foreach (string expected in Expected) {
4343
if (normalized.Length > expected.Length) {
4444
int matches = 0;
4545
int offset = 0;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1010
/// Handles the add me on discord bots.
1111
/// </summary>
1212
public class Discord : AChatRule {
13-
private readonly string[] KNOWN_PHRASES = [
13+
private readonly string[] _knownPhrases = [
1414
"add me",
1515
"add my",
1616
"add up",
@@ -45,7 +45,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
4545
return true;
4646
}
4747

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class IfYouWantViewers : AChatRule {
1313
/// <summary>
1414
/// The strings that we expect to receive if this is a bot.
1515
/// </summary>
16-
public readonly string[] EXPECTED = [
16+
public readonly string[] Expected = [
1717
"if you want more viewers for your stream, go to"
1818
];
1919

@@ -33,7 +33,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
3333
string normalized = string.Join(' ', message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))
3434
.ToLowerInvariant();
3535

36-
foreach (string expected in EXPECTED) {
36+
foreach (string expected in Expected) {
3737
if (normalized.Contains(expected, StringComparison.InvariantCultureIgnoreCase)) {
3838
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
3939
"[Bot] Spam (If You Want Viewers)", db, stoppingToken);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1010
/// Handles the want to see her naked porn bots.
1111
/// </summary>
1212
public class Naked : AChatRule {
13-
private const string _spam = "Want to see her naked?";
14-
private const string _spam2 = "Want to see me naked?";
13+
private const string SPAM = "Want to see her naked?";
14+
private const string SPAM2 = "Want to see me naked?";
1515

1616
/// <inheritdoc />
1717
public override bool ShouldRun(TwitchUserConfig config) {
@@ -22,8 +22,8 @@ public override bool ShouldRun(TwitchUserConfig config) {
2222
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, TwitchChatMessage message,
2323
INullinsideContext db, CancellationToken stoppingToken = new()) {
2424
if (message.IsFirstMessage &&
25-
(message.Message.TrimStart().StartsWith(_spam, StringComparison.InvariantCultureIgnoreCase) ||
26-
message.Message.TrimStart().StartsWith(_spam2, StringComparison.InvariantCultureIgnoreCase))) {
25+
(message.Message.TrimStart().StartsWith(SPAM, StringComparison.InvariantCultureIgnoreCase) ||
26+
message.Message.TrimStart().StartsWith(SPAM2, StringComparison.InvariantCultureIgnoreCase))) {
2727
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
2828
"[Bot] Spam (Naked)", db, stoppingToken);
2929
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1010
/// Handles "streamrise" spam.
1111
/// </summary>
1212
public class StreamRise : AChatRule {
13-
private const string _spam = "Hello, sorry for bothering you. I want to offer promotion of your channel, " +
13+
private const string SPAM = "Hello, sorry for bothering you. I want to offer promotion of your channel, " +
1414
"viewers, followers, views, chat bots, etc...The price is lower than any competitor, " +
1515
"the quality is guaranteed to be the best. Flexible and convenient order management " +
1616
"panel, chat panel, everything is in your hands, a huge number of custom settings. Go " +
@@ -24,7 +24,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
2424
/// <inheritdoc />
2525
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, TwitchChatMessage message,
2626
INullinsideContext db, CancellationToken stoppingToken = new()) {
27-
if (message.IsFirstMessage && _spam.Equals(message.Message, StringComparison.InvariantCultureIgnoreCase)) {
27+
if (message.IsFirstMessage && SPAM.Equals(message.Message, StringComparison.InvariantCultureIgnoreCase)) {
2828
await BanAndLog(channelId, botProxy, new[] { (message.UserId, message.Username) },
2929
"[Bot] Spam (StreamRise)", db, stoppingToken);
3030
return false;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Nullinside.Api.TwitchBot.ChatRules;
1010
/// Handles "streamviewers org" spam.
1111
/// </summary>
1212
public class StreamViewers : AChatRule {
13-
private const int MinThreshold = 70;
13+
private const int MIN_THRESHOLD = 70;
1414

15-
private const string ExpectedSpamMessage =
15+
private const string EXPECTED_SPAM_MESSAGE =
1616
"doyoualreadytriedstreamviewersorg?realviewers,fireworks!theyarenowgivingoutafreepackageforstreamersoo";
1717

1818
/// <inheritdoc />
@@ -47,13 +47,13 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
4747

4848
// With no spaces the message will be exactly the length of our spam message.
4949
string noSpaces = string.Concat(parts);
50-
if (noSpaces.Length != ExpectedSpamMessage.Length) {
50+
if (noSpaces.Length != EXPECTED_SPAM_MESSAGE.Length) {
5151
return true;
5252
}
5353

5454
// Determine how similar the message is to the spam message.
5555
int matches = 0;
56-
for (int i = 0; i < ExpectedSpamMessage.Length; i++) {
56+
for (int i = 0; i < EXPECTED_SPAM_MESSAGE.Length; i++) {
5757
// If it's not an ascii character it might mean they're trying to obfuscate by swapping out letters that look
5858
// like ascii characters. Like an e with an accent mark instead of an ascii e. They'll look almost the same to
5959
// the reader but the character will be different. We can skip these and assume it doesn't count as a match.
@@ -65,7 +65,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
6565
// strings must match. There shouldn't be any letters in order that we aren't expecting provided they're actually
6666
// ascii characters. If, for some reason, there is a letter in this position that we aren't expecting it means it
6767
// is not our spam message.
68-
if (noSpaces[i] != ExpectedSpamMessage[i]) {
68+
if (noSpaces[i] != EXPECTED_SPAM_MESSAGE[i]) {
6969
return true;
7070
}
7171

@@ -74,7 +74,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
7474
}
7575

7676
// If we had less character matches than our threshold then this wasn't a spam message.
77-
if (matches < MinThreshold) {
77+
if (matches < MIN_THRESHOLD) {
7878
return true;
7979
}
8080

src/Nullinside.Api.TwitchBot/Constants.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ public static class Constants {
77
/// <summary>
88
/// The email address associated with the twitch account for the bot.
99
/// </summary>
10-
public const string BotEmail = "[email protected]";
10+
public const string BOT_EMAIL = "[email protected]";
1111

1212
/// <summary>
1313
/// The twitch username for the bot account.
1414
/// </summary>
15-
public const string BotUsername = "nullinside";
15+
public const string BOT_USERNAME = "nullinside";
1616

1717
/// <summary>
1818
/// The twitch id for the bot account.
1919
/// </summary>
20-
public const string BotId = "640082552";
20+
public const string BOT_ID = "640082552";
2121

2222
// TODO: This should be dynamic but I need to find a source of "good bots" lists. Might have to cheap out and just do a database table with data entry. Let users of the bot submit suggestions that we approve manually.
2323
/// <summary>
2424
/// The whitelist of bots to not ban.
2525
/// </summary>
26-
public static readonly string[] WhitelistedBots = {
26+
public static readonly string[] WHITELISTED_BOTS = {
2727
"soundalerts", "nightbot", "streamlabs",
2828
"pokemoncommunitygame", "streamelements",
2929
"moobot", "wizebot", "bad_elbereth", "dixperbro",
@@ -37,10 +37,10 @@ public static class Constants {
3737
/// <summary>
3838
/// The minimum time that must elapse between user's getting scanned.
3939
/// </summary>
40-
public static readonly TimeSpan MinimumTimeBetweenScans = TimeSpan.FromSeconds(30);
40+
public static readonly TimeSpan MINIMUM_TIME_BETWEEN_SCANS = TimeSpan.FromSeconds(30);
4141

4242
/// <summary>
4343
/// The minimum time that must elapse between user's getting scanned if they are currently live.
4444
/// </summary>
45-
public static readonly TimeSpan MinimumTimeBetweenScansLive = TimeSpan.FromSeconds(1);
45+
public static readonly TimeSpan MINIMUM_TIME_BETWEEN_SCANS_LIVE = TimeSpan.FromSeconds(1);
4646
}

src/Nullinside.Api.TwitchBot/Controllers/BotController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public BotController(INullinsideContext dbContext, IConfiguration configuration)
7272
IEnumerable<Moderator> mods = await api.GetChannelMods(user.TwitchId, token);
7373
return Ok(new {
7474
isMod = null != mods.FirstOrDefault(m =>
75-
string.Equals(m.UserId, Constants.BotId, StringComparison.InvariantCultureIgnoreCase))
75+
string.Equals(m.UserId, Constants.BOT_ID, StringComparison.InvariantCultureIgnoreCase))
7676
});
7777
}
7878

@@ -97,7 +97,7 @@ public async Task<IActionResult> ModBotAccount([FromServices] ITwitchApiProxy ap
9797
}
9898

9999
api.Configure(user);
100-
bool success = await api.AddChannelMod(user.TwitchId, Constants.BotId, token);
100+
bool success = await api.AddChannelMod(user.TwitchId, Constants.BOT_ID, token);
101101
return Ok(success);
102102
}
103103

0 commit comments

Comments
 (0)