Skip to content

Commit 8b20e3f

Browse files
Swapping database references to interface
#39
1 parent 4a4c3fb commit 8b20e3f

20 files changed

+32
-33
lines changed

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

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

3636
/// <summary>
3737
/// Handles performing a ban only once, ever, on a user. Any future calls with the same user to be banned in the same
@@ -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, NullinsideContext db,
47+
protected virtual async Task<IEnumerable<BannedUser>?> BanOnce(TwitchApiProxy 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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
7070
/// <param name="db">The database.</param>
7171
/// <param name="stoppingToken">The cancellation token.</param>
7272
public override async Task Handle(User user, TwitchUserConfig config, TwitchApiProxy botProxy,
73-
NullinsideContext db, CancellationToken stoppingToken = new()) {
73+
INullinsideContext db, CancellationToken stoppingToken = new()) {
7474
if (null == user.TwitchId) {
7575
return;
7676
}

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

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

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public abstract class AChatRule : IChatRule {
1717

1818
/// <inheritdoc />
1919
public abstract Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
20-
NullinsideContext db,
21-
CancellationToken stoppingToken = new());
20+
INullinsideContext db, CancellationToken stoppingToken = new());
2221

2322
/// <summary>
2423
/// Bans a user and logs the ban attempt to the database.
@@ -30,7 +29,7 @@ public abstract Task<bool> Handle(string channelId, TwitchApiProxy botProxy, Cha
3029
/// <param name="db">The database.</param>
3130
/// <param name="stoppingToken">The cancellation token.</param>
3231
public async Task BanAndLog(string channelId, TwitchApiProxy botProxy,
33-
IEnumerable<(string Id, string Username)> users, string reason, NullinsideContext db,
32+
IEnumerable<(string Id, string Username)> users, string reason, INullinsideContext db,
3433
CancellationToken stoppingToken = new()) {
3534
await botProxy.BanUsers(channelId, Constants.BotId, users, reason, stoppingToken);
3635
await db.SaveTwitchBans(channelId, users, reason, stoppingToken);

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

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

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

src/Nullinside.Api.TwitchBot/ChatRules/Discord.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
/// <inheritdoc />
2525
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
26-
NullinsideContext db, CancellationToken stoppingToken = new()) {
26+
INullinsideContext db, CancellationToken stoppingToken = new()) {
2727
if (!message.IsFirstMessage) {
2828
return true;
2929
}

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

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

1818
/// <inheritdoc />
1919
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
20-
NullinsideContext db, CancellationToken stoppingToken = new()) {
20+
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)))
2323
.ToLowerInvariant();

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

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

1818
/// <inheritdoc />
1919
public override async Task<bool> Handle(string channelId, TwitchApiProxy botProxy, ChatMessage message,
20-
NullinsideContext db, CancellationToken stoppingToken = new()) {
20+
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)))
2323
.ToLowerInvariant();

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, NullinsideContext db,
30+
public Task<bool> Handle(string channelId, TwitchApiProxy 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
@@ -24,7 +24,7 @@ public override bool ShouldRun(TwitchUserConfig config) {
2424

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

0 commit comments

Comments
 (0)