1- package simplexity .config . config ;
1+ package simplexity .config ;
22
33import com .amazonaws .regions .Region ;
44import com .amazonaws .regions .Regions ;
55import com .amazonaws .services .polly .model .VoiceId ;
66import org .slf4j .Logger ;
77import org .slf4j .LoggerFactory ;
88import org .slf4j .event .Level ;
9+ import simplexity .Main ;
910import simplexity .util .Logging ;
1011
1112import java .util .HashMap ;
@@ -25,11 +26,6 @@ public class ConfigHandler {
2526 private Integer serverPort ;
2627 private static ConfigHandler instance ;
2728
28- public ConfigHandler () {
29- super (); //todo figure out a better way to handle the config names
30- Logging .log (logger , "Initializing AWS config class" , Level .INFO );
31- }
32-
3329 public static ConfigHandler getInstance () {
3430 if (instance == null ) {
3531 instance = new ConfigHandler ();
@@ -38,13 +34,15 @@ public static ConfigHandler getInstance() {
3834 return instance ;
3935 }
4036
41- public void reloadValues (YmlConfig config ) {
37+ public void reloadValues () {
38+ YmlConfig config = Main .getConfig ();
4239 reloadSpeechEffects (config );
4340 reloadAwsValues (config );
41+ reloadTextReplace (config );
4442 serverPort = config .getOption ("internal-settings.server-port" , Integer .class , 3000 );
4543 }
4644
47- public void reloadAwsValues (YmlConfig config ){
45+ public void reloadAwsValues (YmlConfig config ) {
4846 awsAccessID = config .getOption ("aws-api.access-key" , String .class , "" );
4947 awsSecretKey = config .getOption ("aws-api.secret-key" , String .class , "" );
5048 Regions region = config .getOption ("aws-api.region" , Regions .class , Regions .US_EAST_1 );
@@ -85,7 +83,15 @@ public void reloadSpeechEffects(YmlConfig config) {
8583 }
8684 }
8785
88- public void reloadTextReplace (YmlConfig config ){}
86+ public void reloadTextReplace (YmlConfig config ) {
87+ textReplaceRules .clear ();
88+ for (String key : config .getKeys ("text-replacements" )) {
89+ String replacementText = config .getOption ("text-replacements." + key , String .class );
90+ if (replacementText == null ) continue ;
91+ TextReplaceRule replaceRule = new TextReplaceRule (key , replacementText );
92+ textReplaceRules .add (replaceRule );
93+ }
94+ }
8995
9096
9197 public String getAwsAccessID () {
0 commit comments