Skip to content

Commit ee33086

Browse files
Bardakycsharpfritz
authored andcommitted
Created project command (#217)
* Added project command * updated project command default text * updated project command, now storing the project in the command
1 parent 6bd9ac9 commit ee33086

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}

Fritz.StreamTools/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
"AttentionCommand": {
5151
"TemplateText": "Trying to get the attention of @csharpfritz for @{0}!",
5252
"Cooldown": "00:10:00"
53+
},
54+
"ProjectCommand": {
55+
"TemplateText": "@{0} Jeff is currently working on {1}",
56+
"DefaultText": "nothing! Are we not working on anything @csharpfritz?"
5357
}
5458
},
5559
"FollowerGoal": {

0 commit comments

Comments
 (0)