Skip to content

Commit 0b8c24d

Browse files
Merge pull request #41 from nullinside-development-group/feature/Poc2Prod
Abstracting TwitchApiProxy -> ITwitchApiProxy
2 parents 0f92ee0 + 8a9488f commit 0b8c24d

20 files changed

+93
-61
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class ABotRule : IBotRule {
3030
/// <param name="db">The database.</param>
3131
/// <param name="stoppingToken">The cancellation token.</param>
3232
/// <returns>An asynchronous task.</returns>
33-
public abstract Task Handle(User user, TwitchUserConfig config, TwitchApiProxy botProxy,
33+
public abstract Task Handle(User user, TwitchUserConfig config, ITwitchApiProxy botProxy,
3434
INullinsideContext db, CancellationToken stoppingToken = new());
3535

3636
/// <summary>
@@ -44,7 +44,7 @@ public abstract Task Handle(User user, TwitchUserConfig config, TwitchApiProxy b
4444
/// <param name="reason">The reason for the ban.</param>
4545
/// <param name="stoppingToken">The cancellation token.</param>
4646
/// <returns>A collection of confirmed banned users.</returns>
47-
protected virtual async Task<IEnumerable<BannedUser>?> BanOnce(TwitchApiProxy botProxy, INullinsideContext db,
47+
protected virtual async Task<IEnumerable<BannedUser>?> BanOnce(ITwitchApiProxy botProxy, INullinsideContext db,
4848
string channelId, IEnumerable<(string Id, string Username)> users, string reason,
4949
CancellationToken stoppingToken = new()) {
5050
// Get the list of everyone to ban
@@ -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.BanUsers(channelId, Constants.BotId, bansToTry, reason, stoppingToken);
71+
await botProxy.BanChannelUsers(channelId, Constants.BotId, 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
6969
/// <param name="botProxy">The twitch api authenticated as the bot user.</param>
7070
/// <param name="db">The database.</param>
7171
/// <param name="stoppingToken">The cancellation token.</param>
72-
public override async Task Handle(User user, TwitchUserConfig config, TwitchApiProxy botProxy,
72+
public override async Task Handle(User user, TwitchUserConfig config, ITwitchApiProxy botProxy,
7373
INullinsideContext db, CancellationToken stoppingToken = new()) {
7474
if (null == user.TwitchId) {
7575
return;
@@ -79,7 +79,7 @@ public override async Task Handle(User user, TwitchUserConfig config, TwitchApiP
7979

8080
// Get the list of people in the chat.
8181
List<Chatter>? chatters =
82-
(await botProxy.GetChattersInChannel(user.TwitchId, Constants.BotId, stoppingToken))?.ToList();
82+
(await botProxy.GetChannelUsers(user.TwitchId, Constants.BotId, stoppingToken))?.ToList();
8383
if (null == chatters || chatters.Count == 0) {
8484
return;
8585
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public interface IBotRule {
2525
/// <param name="db">The database.</param>
2626
/// <param name="stoppingToken">The cancellation token.</param>
2727
/// <returns>An asynchronous task.</returns>
28-
public Task Handle(User user, TwitchUserConfig config, TwitchApiProxy botProxy,
28+
public Task Handle(User user, TwitchUserConfig config, ITwitchApiProxy botProxy,
2929
INullinsideContext db, CancellationToken stoppingToken = new());
3030
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public abstract class AChatRule : IChatRule {
1616
public abstract bool ShouldRun(TwitchUserConfig config);
1717

1818
/// <inheritdoc />
19-
public abstract Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
19+
public abstract Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
2020
INullinsideContext db, CancellationToken stoppingToken = new());
2121

2222
/// <summary>
@@ -28,10 +28,10 @@ public abstract Task<bool> Handle(string channelId, TwitchApiProxy botProxy, Cha
2828
/// <param name="reason">The ban reason.</param>
2929
/// <param name="db">The database.</param>
3030
/// <param name="stoppingToken">The cancellation token.</param>
31-
public async Task BanAndLog(string channelId, TwitchApiProxy botProxy,
31+
public async Task BanAndLog(string channelId, ITwitchApiProxy botProxy,
3232
IEnumerable<(string Id, string Username)> users, string reason, INullinsideContext db,
3333
CancellationToken stoppingToken = new()) {
34-
await botProxy.BanUsers(channelId, Constants.BotId, users, reason, stoppingToken);
34+
await botProxy.BanChannelUsers(channelId, Constants.BotId, users, reason, stoppingToken);
3535
await db.SaveTwitchBans(channelId, users, reason, stoppingToken);
3636
}
3737
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
2626
}
2727

2828
/// <inheritdoc />
29-
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
29+
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
3030
INullinsideContext db, CancellationToken stoppingToken = new()) {
3131
if (!message.IsFirstMessage) {
3232
return true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
2222
}
2323

2424
/// <inheritdoc />
25-
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
25+
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
2626
INullinsideContext db, CancellationToken stoppingToken = new()) {
2727
if (!message.IsFirstMessage) {
2828
return true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
1616
}
1717

1818
/// <inheritdoc />
19-
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
19+
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
2020
INullinsideContext db, CancellationToken stoppingToken = new()) {
2121
// The number of spaces per message may chance, so normalize that and lowercase it for comparison.
2222
string normalized = string.Concat(message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
1616
}
1717

1818
/// <inheritdoc />
19-
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
19+
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
2020
INullinsideContext db, CancellationToken stoppingToken = new()) {
2121
// The number of spaces per message may change, so normalize that and lowercase it for comparison.
2222
string normalized = string.Concat(message.Message.Split(" ").Where(s => !string.IsNullOrWhiteSpace(s)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public interface IChatRule {
2727
/// <param name="db">The database.</param>
2828
/// <param name="stoppingToken">The cancellation token.</param>
2929
/// <returns>An asynchronous task.</returns>
30-
public Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message, INullinsideContext db,
30+
public Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message, INullinsideContext db,
3131
CancellationToken stoppingToken = new());
3232
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
2323
}
2424

2525
/// <inheritdoc />
26-
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
26+
public override async Task<bool> Handle(string channelId, ITwitchApiProxy botProxy, ChatMessage message,
2727
INullinsideContext db, CancellationToken stoppingToken = new()) {
2828
if (!message.IsFirstMessage) {
2929
return true;

0 commit comments

Comments
 (0)