Skip to content

Commit e87ad3c

Browse files
committed
Fix issue #205
1 parent b1be9d8 commit e87ad3c

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Text;
3+
using System.Threading.Tasks;
4+
using Fritz.StreamLib.Core;
5+
using Microsoft.Extensions.Configuration;
6+
7+
8+
namespace Fritz.Chatbot.Commands
9+
{
10+
public class AttentionCommand : IBasicCommand
11+
{
12+
private readonly IConfiguration Configuration;
13+
14+
public AttentionCommand(IConfiguration configuration)
15+
{
16+
this.Configuration = configuration;
17+
}
18+
19+
public string Trigger => "Fritz";
20+
21+
public string Description => "Play audio queue to divert attention to chat";
22+
23+
public TimeSpan? Cooldown => TimeSpan.FromSeconds(5);
24+
25+
public async Task Execute(IChatService chatService, string userName, ReadOnlyMemory<char> rhs)
26+
{
27+
var player = new NetCoreAudio.Player();
28+
await player.Play("hey_listen.wav");
29+
30+
var attentionText = Configuration["FritzBot:AttentionCommand:TemplateText"];
31+
32+
var sb = new StringBuilder();
33+
sb.AppendFormat(attentionText, userName);
34+
35+
await chatService.SendMessageAsync(attentionText);
36+
}
37+
}
38+
}

Fritz.Chatbot/Fritz.Chatbot.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PackageReference Include="Microsoft.Extensions.Http" Version="2.1.1" />
1515
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
1616
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
17+
<PackageReference Include="NetCoreAudio" Version="1.4.0" />
1718
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
1819
</ItemGroup>
1920

@@ -22,6 +23,9 @@
2223
</ItemGroup>
2324

2425
<ItemGroup>
26+
<None Update="hey_listen.wav">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</None>
2529
<None Update="SkeetQuotes.txt">
2630
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2731
</None>

Fritz.Chatbot/hey_listen.wav

279 KB
Binary file not shown.

Fritz.StreamTools/appsettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
"HypeCommand": {
4646
"TemplateText": "PartyPopper PartyPopper HYPE! PartyPopper PartyPopper ",
4747
"RepeatCount": 3
48+
},
49+
"AttentionCommand": {
50+
"TemplateText": "Trying to get the attention of @csharpfritz for @{0}!"
4851
}
4952
},
5053
"FollowerGoal": {

0 commit comments

Comments
 (0)