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));
|
File.WriteAllText(configPath, JsonConvert.SerializeObject(sampleCfg));
|
||||||
}
|
}
|
||||||
var cfg = JsonConvert.DeserializeObject<Config>(File.ReadAllText(configPath));
|
var cfg = JsonConvert.DeserializeObject<Config>(File.ReadAllText(configPath));
|
||||||
|
|
||||||
Console.WriteLine("rss reader alive");
|
Console.WriteLine("rss reader alive");
|
||||||
|
|
||||||
if (!File.Exists(archivePath))
|
if (!File.Exists(archivePath))
|
||||||
@ -35,13 +35,13 @@ namespace rssberg
|
|||||||
File.CreateText(archivePath);
|
File.CreateText(archivePath);
|
||||||
}
|
}
|
||||||
doneIDs = File.ReadAllLines(archivePath).ToList();
|
doneIDs = File.ReadAllLines(archivePath).ToList();
|
||||||
|
|
||||||
var postMetaTasks = new List<Task>();
|
var postMetaTasks = new List<Task>();
|
||||||
foreach (var kvp in cfg.FeedPairs.ToList())
|
foreach (var kvp in cfg.FeedPairs.ToList())
|
||||||
{
|
{
|
||||||
postMetaTasks.Add(rss2webhook(kvp.Key, kvp.Value));
|
postMetaTasks.Add(rss2webhook(kvp.Key, kvp.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"rss reader collected {postMetaTasks.Count} post metatasks");
|
Console.WriteLine($"rss reader collected {postMetaTasks.Count} post metatasks");
|
||||||
Task.WaitAll(postMetaTasks.ToArray());
|
Task.WaitAll(postMetaTasks.ToArray());
|
||||||
while(doneIDs.Count > 5000){
|
while(doneIDs.Count > 5000){
|
||||||
@ -58,7 +58,7 @@ namespace rssberg
|
|||||||
postTasks.Add(Task.Run<ulong>(() => {return (ulong)1;})); //dummy task for debugging
|
postTasks.Add(Task.Run<ulong>(() => {return (ulong)1;})); //dummy task for debugging
|
||||||
var responseStream = await client.GetStreamAsync(key);
|
var responseStream = await client.GetStreamAsync(key);
|
||||||
var wh = new Discord.Webhook.DiscordWebhookClient(value);
|
var wh = new Discord.Webhook.DiscordWebhookClient(value);
|
||||||
|
|
||||||
using (XmlReader xr = XmlReader.Create(responseStream))
|
using (XmlReader xr = XmlReader.Create(responseStream))
|
||||||
{
|
{
|
||||||
var feed = SyndicationFeed.Load(xr);
|
var feed = SyndicationFeed.Load(xr);
|
||||||
@ -78,7 +78,7 @@ namespace rssberg
|
|||||||
// }
|
// }
|
||||||
Console.WriteLine($"to post! {item.Id} {item.Title?.Text}");
|
Console.WriteLine($"to post! {item.Id} {item.Title?.Text}");
|
||||||
doneIDs.Add(item.Id);
|
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>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<RootNamespace>rssberg</RootNamespace>
|
<RootNamespace>rssberg</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user