-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (39 loc) · 1.48 KB
/
Copy pathProgram.cs
File metadata and controls
46 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using MastodonRssPoster.Mastodon;
using MastodonRssPoster.Rss;
using Serilog;
using Serilog.Events;
using System;
namespace MastodonRssPoster
{
public class Program
{
private static int miliSecondsToWait = 30000;
private static string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", "MastodonRssPosterLog.txt");
public static readonly ILogger _logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.WriteTo.File(logPath, rollingInterval: RollingInterval.Day)
.CreateLogger();
static void Main(string[] args)
{
_logger.Information("Starting Bot......");
IMastodonSlave mastodonClient = new MastodonSlave(_logger);
IRssReader rssReader = new RssReader(_logger);
IRssPublisher rssPublisher = new RssPublisher(rssReader, mastodonClient, _logger);
while(true)
{
try
{
rssPublisher.PublishNewArticles();
rssPublisher.CleanPublishedRssArticlesÎfTheAre2DaysOldOrMore();
_logger.Information("Batch completed......");
Thread.Sleep(miliSecondsToWait);
}
catch (Exception ex)
{
Log.Error(ex.ToString());
}
}
}
}
}