Skip to content

Commit b8349d0

Browse files
Merge pull request #95 from nullinside-development-group/chore/config
Chore/config
2 parents 0ba592f + a8bd751 commit b8349d0

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/Nullinside.Api.TwitchBot/Services/MainService.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,13 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) {
180180
// Join all the channels we're a mod in. Why do we limit it to channels we are a mod in? Twitch changed
181181
// its chat limits so that "verified bots" like us don't get special treatment anymore. The only thing
182182
// that skips the chat limits is if it's a channel you're a mod in.
183-
var bannedUsers = (await GetBannedUsers(db, stoppingToken))
184-
.Where(u => !string.IsNullOrWhiteSpace(u.TwitchId))
185-
.Select(u => u.TwitchId!.Trim())
186-
.ToHashSet();
187-
var allModdedAndNotBannedUsers = moddedChannels
188-
.Where(m => !bannedUsers.Contains(m.broadcaster_id));
189-
var joinChannels = usersWithBotEnabled
190-
.Select(u => u.TwitchUsername)
191-
.Concat(allModdedAndNotBannedUsers.Select(j => j.broadcaster_login));
192-
foreach (var channel in joinChannels) {
193-
if (string.IsNullOrWhiteSpace(channel)) {
183+
foreach (User channel in usersWithBotEnabled) {
184+
if (string.IsNullOrWhiteSpace(channel.TwitchUsername)) {
194185
continue;
195186
}
196187

197-
await _client.AddMessageCallback(channel, OnTwitchMessageReceived);
198-
await _client.AddBannedCallback(channel, OnTwitchBanReceived);
188+
await _client.AddMessageCallback(channel.TwitchUsername, OnTwitchMessageReceived);
189+
await _client.AddBannedCallback(channel.TwitchUsername, OnTwitchBanReceived);
199190
}
200191
}
201192

@@ -299,7 +290,7 @@ orderby user.TwitchLastScanned
299290
/// <param name="db">The database.</param>
300291
/// <param name="stoppingToken">The stopping token.</param>
301292
/// <returns>The list of users with the bot enabled.</returns>
302-
private async Task<List<User>> GetBannedUsers(INullinsideContext db, CancellationToken stoppingToken) {
293+
private async Task<List<User>?> GetBannedUsers(INullinsideContext db, CancellationToken stoppingToken) {
303294
return await
304295
(from user in db.Users
305296
orderby user.TwitchLastScanned

src/global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"rollForward": "latestMajor",
4+
"allowPrerelease": false
5+
}
6+
}

0 commit comments

Comments
 (0)