Skip to content

Commit 663e478

Browse files
feat: joining more chats for more data
To help with debugging and gathering bot related activity and information, we will join all channels we are modded in except for those users that are explicitly banned.
1 parent d193157 commit 663e478

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,20 @@ 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-
foreach (User channel in usersWithBotEnabled) {
184-
if (string.IsNullOrWhiteSpace(channel.TwitchUsername)) {
183+
var bannedUsers = (await GetBannedUsers(db, stoppingToken))
184+
.Where(u => !string.IsNullOrWhiteSpace(u.TwitchId))
185+
.Select(u => u.TwitchId.Trim())
186+
.ToHashSet();
187+
var joinChannels = moddedChannels
188+
.Where(m => !bannedUsers.Contains(m.broadcaster_id));
189+
190+
foreach (var channel in joinChannels) {
191+
if (string.IsNullOrWhiteSpace(channel.broadcaster_login)) {
185192
continue;
186193
}
187194

188-
await _client.AddMessageCallback(channel.TwitchUsername, OnTwitchMessageReceived);
189-
await _client.AddBannedCallback(channel.TwitchUsername, OnTwitchBanReceived);
195+
await _client.AddMessageCallback(channel.broadcaster_login, OnTwitchMessageReceived);
196+
await _client.AddBannedCallback(channel.broadcaster_login, OnTwitchBanReceived);
190197
}
191198
}
192199

0 commit comments

Comments
 (0)