Skip to content

Commit 2627b00

Browse files
committed
Updated to integrate the TextCommand better
1 parent 7d6668f commit 2627b00

File tree

3 files changed

+225
-213
lines changed

3 files changed

+225
-213
lines changed

Fritz.Chatbot/Commands/HelpCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public async Task Execute(IChatService chatService, string userName, ReadOnlyMem
2727

2828
if (rhs.IsEmpty)
2929
{
30-
var availableCommands = String.Join(" ", commands.Where(c => !string.IsNullOrEmpty(c.Trigger)).Select(c => $"!{c.Trigger.ToLower()}"));
30+
31+
var availableCommandArray = commands.Where(c => !string.IsNullOrEmpty(c.Trigger)).Select(c => $"!{c.Trigger.ToLower()}");
32+
var textCommandArray = TextCommand._Commands.Select(kv => "!" + kv.Key.ToLower());
33+
34+
var availableCommands = string.Join(' ', availableCommandArray.Union(textCommandArray).OrderBy(s => s));
3135

3236
await chatService.SendMessageAsync($"Supported commands: {availableCommands}");
3337
return;

Fritz.Chatbot/Commands/TextCommand.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ public class TextCommand : IExtendedCommand
1818
public bool Final => true;
1919
public TimeSpan? Cooldown => TimeSpan.FromSeconds(5);
2020

21-
private static readonly Dictionary<string, string> _Commands = new Dictionary<string, string>
21+
internal static readonly Dictionary<string, string> _Commands = new Dictionary<string, string>
2222
{
2323
{ "music", "Jeff plays 'Music to Code By' from Carl Franklin: http://mtcb.pwop.com" },
2424
{ "discord", "Join us on the Fritz and Friends Discord server at: https://discord.gg/RnJhrJq" },
2525
{ "github", "Checkout Jeff's GitHub at: https://github.com/csharpfritz" },
2626
{ "keyboard", "Jeff uses a Vortex Race 3 with Cherry MX Blue switches, details on his blog at: https://jeffreyfritz.com/2018/07/mechanical-keyboards-i-just-got-one-and-why-you-need-one-too/" },
2727
{ "blog", "Jeff's blog is at: https://jeffreyfritz.com" },
2828
{ "lurk", "is stepping away from keyboard and lurking" },
29-
{ "raid", @"Prepare to RAID! Copy this text to use when we reach our raid target: ----------------------------------------------- csharpRaid csharpRaid csharpRaid CsharpFritz's Coding Squad is Here! All your base are belong to us! csharpRaid csharpRaid csharpRaid" +
30-
"----------------------------------------------- twitchRaid twitchRaid twitchRaid CsharpFritz's Coding Squad is Here! All your base are belong to us! twitchRaid twitchRaid twitchRaid " }
29+
{ "raid", @"Prepare to RAID! Copy this text to use when we reach our raid target: ------------ Subscribers copy -------------\n\ncsharpRaid csharpRaid csharpRaid CsharpFritz's Coding Squad is Here! All your base are belong to us! csharpRaid csharpRaid csharpRaid\n" +
30+
" ------------ Non-Subscribers copy -------------\n\n twitchRaid twitchRaid twitchRaid CsharpFritz's Coding Squad is Here! All your base are belong to us! twitchRaid twitchRaid twitchRaid " }
3131
};
3232

33+
internal static bool IsCommand(string commandText)
34+
{
35+
36+
return _Commands.ContainsKey(commandText);
37+
38+
}
39+
3340
public bool CanExecute(string userName, string fullCommandText)
3441
{
3542

0 commit comments

Comments
 (0)