Skip to content

Commit 36bc467

Browse files
committed
Added ability to ignore bots from Configuration
1 parent ff7765d commit 36bc467

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Fritz.Chatbot/FritzBot.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class FritzBot : IHostedService
2323
private readonly IChatService[] _chatServices;
2424
private readonly IBasicCommand[] _basicCommands;
2525
private readonly IExtendedCommand[] _extendedCommands;
26+
private readonly string[] _OtherBots;
2627

2728
private readonly ConcurrentDictionary<string, ChatUserInfo> _activeUsers = new ConcurrentDictionary<string, ChatUserInfo>();
2829
private readonly ConcurrentDictionary<string, DateTime> _commandExecutedTimeMap = new ConcurrentDictionary<string, DateTime>();
@@ -51,6 +52,8 @@ public FritzBot(IConfiguration configuration, IServiceProvider serviceProvider,
5152
var cooldownConfig = configuration[$"{ConfigurationRoot}:CooldownTime"];
5253
CooldownTime = !string.IsNullOrEmpty(cooldownConfig) ? TimeSpan.Parse(cooldownConfig) : TimeSpan.Zero;
5354

55+
_OtherBots = String.IsNullOrEmpty(configuration[$"{ConfigurationRoot}:Otherbots"]) ? new[] { "nightbot","fritzbot","streamelements","pretzelrocks" } : configuration[$"{ConfigurationRoot}:Otherbots"].Split(',');
56+
5457
_logger?.LogInformation("Command cooldown set to {0}", CooldownTime);
5558
}
5659

@@ -143,8 +146,8 @@ private async Task ProcessChatMessage(object sender, ChatMessageEventArgs chatMe
143146
{
144147

145148
// TODO: Capture and transmit the user who sent the message
146-
var otherBots = new[] { "nightbot", "fritzbot", "streamelements" };
147-
if (!otherBots.Contains(chatMessageArgs.UserName.ToLowerInvariant()))
149+
//var otherBots = new[] { "nightbot", "fritzbot", "streamelements", "pretzelrocks" };
150+
if (!_OtherBots.Contains(chatMessageArgs.UserName.ToLowerInvariant()))
148151
{
149152
SentimentSink.RecentChatMessages.Enqueue(chatMessageArgs.Message);
150153
}

Fritz.StreamTools/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"TemplateText": "csharpHypebot csharpHypebot bleedPurple PartyHat HYPE! PartyHat bleedPurple csharpHypebot csharpHypebot",
5050
"RepeatCount": 3
5151
},
52+
"Otherbots": "nightbot,fritzbot,streamelements,pretzelrocks",
5253
"AttentionCommand": {
5354
"TemplateText": "Trying to get the attention of @csharpfritz for @{0}!",
5455
"Cooldown": "00:10:00"

0 commit comments

Comments
 (0)