2
2
using System . Collections . ObjectModel ;
3
3
using System . Linq ;
4
4
using System . Reactive ;
5
- using System . Speech . Synthesis ;
6
5
using System . Threading . Tasks ;
7
6
8
7
using Nullinside . Api . Common . Twitch ;
@@ -131,14 +130,16 @@ private void OnAddChatCommand() {
131
130
return ;
132
131
}
133
132
133
+ // Add it to the list.
134
134
_selectedTwitchChatNames . Add ( username ) ;
135
135
136
136
// Add the callback, we don't need to wait for it to return it can run in the background.
137
137
_ = _twitchClient . AddMessageCallback ( username , OnChatMessage ) ;
138
138
139
-
140
- using var speech = new SpeechSynthesizer ( ) ;
139
+ // Clear out the textbox so the user knows we took their input
141
140
TwitchChatName = null ;
141
+
142
+ // Update and write the configuration
142
143
_configuration . TwitchChats = (
143
144
from user in _selectedTwitchChatNames
144
145
select new TwitchChatConfiguration {
@@ -148,13 +149,22 @@ from user in _selectedTwitchChatNames
148
149
TtsVoice = Configuration . GetDefaultTtsVoice ( ) ,
149
150
TtsVolume = 100
150
151
} ) . ToList ( ) ;
152
+
151
153
_configuration . WriteConfiguration ( ) ;
152
154
}
153
155
156
+ /// <summary>
157
+ /// Handles removing a chat we were monitoring.
158
+ /// </summary>
159
+ /// <param name="channel">The chat to remove.</param>
154
160
private void OnRemoveChatCommand ( string channel ) {
161
+ // Remove it from the list
155
162
_selectedTwitchChatNames . Remove ( channel ) ;
163
+
164
+ // Remove the callback
156
165
_twitchClient . RemoveMessageCallback ( channel , OnChatMessage ) ;
157
- using var speech = new SpeechSynthesizer ( ) ;
166
+
167
+ // Update and write the configuration
158
168
_configuration . TwitchChats = (
159
169
from user in _selectedTwitchChatNames
160
170
select new TwitchChatConfiguration {
@@ -168,6 +178,10 @@ from user in _selectedTwitchChatNames
168
178
_configuration . WriteConfiguration ( ) ;
169
179
}
170
180
181
+ /// <summary>
182
+ /// Handles a new chat message being received from <see cref="_twitchClient" />.
183
+ /// </summary>
184
+ /// <param name="msg">The message received.</param>
171
185
private void OnChatMessage ( OnMessageReceivedArgs msg ) {
172
186
if ( _selectedTwitchChatNames . Count > 1 ) {
173
187
TwitchChat = ( TwitchChat + $ "\n ({ msg . ChatMessage . Channel } ) { msg . ChatMessage . Username } : { msg . ChatMessage . Message } ") . Trim ( ) ;
0 commit comments