|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | +using System.Threading.Tasks; |
| 5 | +using Fritz.StreamLib.Core; |
| 6 | + |
| 7 | +namespace Fritz.Chatbot.Commands |
| 8 | +{ |
| 9 | + |
| 10 | + public class TextCommand : IExtendedCommand |
| 11 | + { |
| 12 | + |
| 13 | + // Cheer 143 cpayette 03/3/19 |
| 14 | + |
| 15 | + public string Name => "TextCommand"; |
| 16 | + public string Description => "Return a simple line of text"; |
| 17 | + public int Order => 0; |
| 18 | + public bool Final => true; |
| 19 | + public TimeSpan? Cooldown => TimeSpan.FromSeconds(5); |
| 20 | + |
| 21 | + private static readonly Dictionary<string, string> _Commands = new Dictionary<string, string> |
| 22 | + { |
| 23 | + { "music", "Jeff plays 'Music to Code By' from Carl Franklin: http://mtcb.pwop.com" }, |
| 24 | + { "discord", "Join us on the Fritz and Friends Discord server at: https://discord.gg/RnJhrJq" }, |
| 25 | + { "github", "Checkout Jeff's GitHub at: https://github.com/csharpfritz" }, |
| 26 | + { "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/" }, |
| 27 | + { "blog", "Jeff's blog is at: https://jeffreyfritz.com" }, |
| 28 | + { "lurk", "is stepping away from keyboard and lurking" } |
| 29 | + }; |
| 30 | + |
| 31 | + public bool CanExecute(string userName, string fullCommandText) |
| 32 | + { |
| 33 | + |
| 34 | + if (!fullCommandText.StartsWith("!")) return false; |
| 35 | + var cmd = fullCommandText.Substring(1).ToLowerInvariant(); |
| 36 | + return _Commands.ContainsKey(cmd); |
| 37 | + |
| 38 | + } |
| 39 | + |
| 40 | + public Task Execute(IChatService chatService, string userName, string fullCommandText) |
| 41 | + { |
| 42 | + |
| 43 | + var cmd = fullCommandText.Substring(1).ToLowerInvariant(); |
| 44 | + |
| 45 | + if (cmd == "lurk") |
| 46 | + return chatService.SendMessageAsync($"@{userName} {_Commands[cmd]}"); |
| 47 | + |
| 48 | + return chatService.SendMessageAsync($"@{userName} - {_Commands[cmd]}"); |
| 49 | + |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments