Skip to content

Commit 0bfdc01

Browse files
Merge pull request #80 from nullinside-development-group/feat/says
feat: add checkbox for reading username before name
2 parents 21fce2b + 8a8a291 commit 0bfdc01

File tree

7 files changed

+235
-195
lines changed

7 files changed

+235
-195
lines changed

src/TwitchStreamingTools/Configuration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public static Configuration Instance {
8383
/// </summary>
8484
public SoundStretchArgs? SoundStretchArgs { get; set; }
8585

86+
/// <inheritdoc />
87+
public bool SayUsernameWithMessage { get; set; }
88+
8689
/// <summary>
8790
/// Writes the configuration file to disk.
8891
/// </summary>

src/TwitchStreamingTools/IConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public interface IConfiguration {
4545
/// </summary>
4646
SoundStretchArgs? SoundStretchArgs { get; set; }
4747

48+
/// <summary>
49+
/// True if "username says message" should be used as the template for TTS messages, false to read just the message.
50+
/// </summary>
51+
bool SayUsernameWithMessage { get; set; }
52+
4853
/// <summary>
4954
/// Writes the configuration file to disk.
5055
/// </summary>

src/TwitchStreamingTools/Tts/TwitchChatTts.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ private void PlaySoundsThread() {
220220
continue;
221221
}
222222

223-
// todo: #51 make this a configuration option and a filter.
224-
string chatMessage = $"{convertedChatEvent.Item1} says {convertedChatEvent.Item2}";
223+
string chatMessage = convertedChatEvent.Item2;
224+
if (_configuration.SayUsernameWithMessage) {
225+
chatMessage = $"{convertedChatEvent.Item1} says {convertedChatEvent.Item2}";
226+
}
225227

226228
// Converts the text to an audio stream and plays it.
227229
InitializeAndPlayTts(e.ChatMessage.Username, chatMessage);

src/TwitchStreamingTools/ViewModels/Pages/SettingsView/SettingsViewModel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public class SettingsViewModel : PageViewModelBase {
5151
/// </summary>
5252
private int _rate;
5353

54+
/// <summary>
55+
/// True if "username says message" should be used as the template for TTS messages, false to read just the message.
56+
/// </summary>
57+
private bool _sayUsernameWithMessage;
58+
5459
/// <summary>
5560
/// The selected output device to send TTS to.
5661
/// </summary>
@@ -359,4 +364,17 @@ public double Speed {
359364
_configuration.WriteConfiguration();
360365
}
361366
}
367+
368+
/// <summary>
369+
/// True if "username says message" should be used as the template for TTS messages, false to read just the message.
370+
/// </summary>
371+
public bool SayUsernameWithMessage {
372+
get => _sayUsernameWithMessage;
373+
set {
374+
this.RaiseAndSetIfChanged(ref _sayUsernameWithMessage, value);
375+
376+
_configuration.SayUsernameWithMessage = true;
377+
_configuration.WriteConfiguration();
378+
}
379+
}
362380
}

src/TwitchStreamingTools/Views/MainWindow.axaml.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading.Tasks;
4-
5-
using Avalonia.Controls;
6-
7-
using Nullinside.Api.Common.Desktop;
81
#if !DEBUG
92
using Microsoft.Extensions.DependencyInjection;
103

114
using Avalonia.Threading;
125

136
using TwitchStreamingTools.ViewModels;
14-
157
#else
168
using Avalonia;
179
#endif
10+
using System;
11+
using System.Linq;
12+
using System.Threading.Tasks;
13+
14+
using Avalonia.Controls;
15+
16+
using Nullinside.Api.Common.Desktop;
1817

1918
namespace TwitchStreamingTools.Views;
2019

0 commit comments

Comments
 (0)