Skip to content

Commit a8bd751

Browse files
Revert "feat: joining more chats for more data"
This reverts commit 7216e11. This was better in theory than practice. The joining of channels got so backed up that it took 17 minutes to finish the first loop of joins. Meaning anyone that goes live between 0-17 minutes of the application starting up will not be joined until the 17 minutes is over.
1 parent d26ce79 commit a8bd751

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-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

0 commit comments

Comments
 (0)