|
| 1 | +using System; |
| 2 | +using System.Threading.Tasks; |
| 3 | +using Fritz.StreamLib.Core; |
| 4 | +using Microsoft.Extensions.Configuration; |
| 5 | + |
| 6 | +namespace Fritz.Chatbot.Commands |
| 7 | +{ |
| 8 | + public class ProjectCommand : IBasicCommand2 |
| 9 | + { |
| 10 | + private readonly IConfiguration Configuration; |
| 11 | + |
| 12 | + public ProjectCommand(IConfiguration configuration) |
| 13 | + { |
| 14 | + this.Configuration = configuration; |
| 15 | + } |
| 16 | + |
| 17 | + public string Trigger => "project"; |
| 18 | + |
| 19 | + public string Description => "Return the name of the project that is currently being worked on on stream"; |
| 20 | + |
| 21 | + public TimeSpan? Cooldown => TimeSpan.FromSeconds(30); |
| 22 | + |
| 23 | + private static string CurrentProject = null; |
| 24 | + |
| 25 | + public async Task Execute(IChatService chatService, string userName, bool isModerator, bool isBroadcaster, ReadOnlyMemory<char> rhs) |
| 26 | + { |
| 27 | + if ((isModerator || isBroadcaster) && !rhs.IsEmpty) |
| 28 | + { |
| 29 | + CurrentProject = rhs.ToString(); |
| 30 | + } |
| 31 | + |
| 32 | + var projectText = Configuration["FritzBot:ProjectCommand:TemplateText"]; |
| 33 | + |
| 34 | + var project = CurrentProject; |
| 35 | + if (CurrentProject == null) |
| 36 | + project = Configuration["FritzBot:ProjectCommand:DefaultText"]; |
| 37 | + else |
| 38 | + project = CurrentProject; |
| 39 | + |
| 40 | + await chatService.SendMessageAsync(string.Format(projectText, userName, project)); |
| 41 | + } |
| 42 | + |
| 43 | + public Task Execute(IChatService chatService, string userName, ReadOnlyMemory<char> rhs) |
| 44 | + { |
| 45 | + throw new NotImplementedException(); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments