Grab topics from config, if it exists

This commit is contained in:
Tony Bark 2025-03-12 02:11:58 -04:00
parent a485dc1a59
commit 8cf1e917f6
3 changed files with 12 additions and 10 deletions

View file

@ -1,2 +1,3 @@
global using Tomlyn;
global using System.Diagnostics;
global using Tomlyn.Model;
global using System.Globalization;

View file

@ -75,20 +75,21 @@ if (Console.ReadKey().Key == ConsoleKey.Y)
var model = Toml.ToModel(toml);
var usrDir = (string)model["path"];
var usrFileName = (string)model["file"];
// var usrList = (string[])model["communities"];
var tomlList = string.Join(", ", (TomlArray)model["topics"]);
var usrList = tomlList.Split(',');
if (!string.IsNullOrEmpty(usrDir))
fileDir = usrDir;
if (!string.IsNullOrEmpty(usrFileName))
scheduleFile = usrFileName;
/*
if (usrList.Length > 0)
{
var chooseUsrTopic = rng.Next(0, usrList.Length);
topic = usrList[chooseUsrTopic];
}
*/
if (usrList.Length > 0)
{
var chooseUsrTopic = rng.Next(0, usrList.Length);
topic = usrList[chooseUsrTopic];
}
// Set new file Path
filePath = Path.Combine(fileDir, scheduleFile);

View file

@ -1,3 +1,3 @@
path = "/home/tonytins/Documents/"
file = "newscycle.txt"
communities = [ "Games", "Politics", "Research", "Technology" ]
topics = [ "Games", "Technology", "Cybersecurity" ]