post tweet content, because let's be honest, rss feeds are usually adapted from twitters
This commit is contained in:
parent
87201b9eed
commit
1072f4f5ca
10
Program.cs
10
Program.cs
@ -27,7 +27,7 @@ namespace rssberg
|
||||
File.WriteAllText(configPath, JsonConvert.SerializeObject(sampleCfg));
|
||||
}
|
||||
var cfg = JsonConvert.DeserializeObject<Config>(File.ReadAllText(configPath));
|
||||
|
||||
|
||||
Console.WriteLine("rss reader alive");
|
||||
|
||||
if (!File.Exists(archivePath))
|
||||
@ -35,13 +35,13 @@ namespace rssberg
|
||||
File.CreateText(archivePath);
|
||||
}
|
||||
doneIDs = File.ReadAllLines(archivePath).ToList();
|
||||
|
||||
|
||||
var postMetaTasks = new List<Task>();
|
||||
foreach (var kvp in cfg.FeedPairs.ToList())
|
||||
{
|
||||
postMetaTasks.Add(rss2webhook(kvp.Key, kvp.Value));
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine($"rss reader collected {postMetaTasks.Count} post metatasks");
|
||||
Task.WaitAll(postMetaTasks.ToArray());
|
||||
while(doneIDs.Count > 5000){
|
||||
@ -58,7 +58,7 @@ namespace rssberg
|
||||
postTasks.Add(Task.Run<ulong>(() => {return (ulong)1;})); //dummy task for debugging
|
||||
var responseStream = await client.GetStreamAsync(key);
|
||||
var wh = new Discord.Webhook.DiscordWebhookClient(value);
|
||||
|
||||
|
||||
using (XmlReader xr = XmlReader.Create(responseStream))
|
||||
{
|
||||
var feed = SyndicationFeed.Load(xr);
|
||||
@ -78,7 +78,7 @@ namespace rssberg
|
||||
// }
|
||||
Console.WriteLine($"to post! {item.Id} {item.Title?.Text}");
|
||||
doneIDs.Add(item.Id);
|
||||
postTasks.Add(wh.SendMessageAsync(item.Links?.ToList().FirstOrDefault()?.Uri.ToString()));
|
||||
postTasks.Add(wh.SendMessageAsync(item.Title?.Text + ' ' + item.Links?.ToList().FirstOrDefault()?.Uri.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RootNamespace>rssberg</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user