mirror of
https://github.com/tonytins/PublishTimes.git
synced 2025-03-15 04:01:20 +00:00
Grab topics from config, if it exists
This commit is contained in:
parent
a485dc1a59
commit
8cf1e917f6
3 changed files with 12 additions and 10 deletions
|
@ -1,2 +1,3 @@
|
||||||
global using Tomlyn;
|
global using Tomlyn;
|
||||||
global using System.Diagnostics;
|
global using Tomlyn.Model;
|
||||||
|
global using System.Globalization;
|
||||||
|
|
|
@ -75,20 +75,21 @@ if (Console.ReadKey().Key == ConsoleKey.Y)
|
||||||
var model = Toml.ToModel(toml);
|
var model = Toml.ToModel(toml);
|
||||||
var usrDir = (string)model["path"];
|
var usrDir = (string)model["path"];
|
||||||
var usrFileName = (string)model["file"];
|
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))
|
if (!string.IsNullOrEmpty(usrDir))
|
||||||
fileDir = usrDir;
|
fileDir = usrDir;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(usrFileName))
|
if (!string.IsNullOrEmpty(usrFileName))
|
||||||
scheduleFile = usrFileName;
|
scheduleFile = usrFileName;
|
||||||
/*
|
|
||||||
if (usrList.Length > 0)
|
if (usrList.Length > 0)
|
||||||
{
|
{
|
||||||
var chooseUsrTopic = rng.Next(0, usrList.Length);
|
var chooseUsrTopic = rng.Next(0, usrList.Length);
|
||||||
topic = usrList[chooseUsrTopic];
|
topic = usrList[chooseUsrTopic];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Set new file Path
|
// Set new file Path
|
||||||
filePath = Path.Combine(fileDir, scheduleFile);
|
filePath = Path.Combine(fileDir, scheduleFile);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
path = "/home/tonytins/Documents/"
|
path = "/home/tonytins/Documents/"
|
||||||
file = "newscycle.txt"
|
file = "newscycle.txt"
|
||||||
communities = [ "Games", "Politics", "Research", "Technology" ]
|
topics = [ "Games", "Technology", "Cybersecurity" ]
|
||||||
|
|
Loading…
Add table
Reference in a new issue