Handled airing multi-post
This commit is contained in:
@@ -63,7 +63,7 @@ namespace AnimeAnnouncer
|
|||||||
nyaaIndexer.NewPost += OnNewPost;
|
nyaaIndexer.NewPost += OnNewPost;
|
||||||
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
nyaaIndexer.RssReadFinished += OnRssReadFinished;
|
||||||
nyaaIndexer.Start(true);
|
nyaaIndexer.Start(true);
|
||||||
|
|
||||||
Console.WriteLine("Press enter to quit...");
|
Console.WriteLine("Press enter to quit...");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
@@ -335,21 +335,30 @@ namespace AnimeAnnouncer
|
|||||||
var airingThisMonth = airingSoon.Where(p => p.LastAirDate >= beginningOfMonth && p.LastAirDate <= endOfMonth).ToList();
|
var airingThisMonth = airingSoon.Where(p => p.LastAirDate >= beginningOfMonth && p.LastAirDate <= endOfMonth).ToList();
|
||||||
String statusText = $"DUBBED anime airing this month (probably){Environment.NewLine + Environment.NewLine}";
|
String statusText = $"DUBBED anime airing this month (probably){Environment.NewLine + Environment.NewLine}";
|
||||||
int cnt = 1;
|
int cnt = 1;
|
||||||
for(int i = 0;i < airingThisMonth.Count;i++, cnt++)
|
for(int i = 0;i < airingThisMonth.Count;i++)
|
||||||
{
|
{
|
||||||
var airing = airingThisMonth[i];
|
var airing = airingThisMonth[i];
|
||||||
if(!await tmdbCache.KeyExists($"ShowAnnounced-{airing.ShowID}"))
|
if(!await tmdbCache.KeyExists($"ShowAnnounced-{airing.ShowID}"))
|
||||||
{ //TODO: fix for seasons
|
{ //TODO: fix for seasons
|
||||||
statusText += $"{cnt}. {airing.Title} on {airing.LastAirDate:MM/dd/yyyy}{Environment.NewLine}";
|
statusText += $"{cnt++}. {airing.Title} on {airing.LastAirDate:MM/dd/yyyy}{Environment.NewLine}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int neededPostCount = (int)Math.Ceiling((decimal)statusText.Length / 500);
|
int neededPostCount = (int)Math.Ceiling((decimal)statusText.Length / 500);
|
||||||
if(neededPostCount >= 2)
|
if(neededPostCount >= 2)
|
||||||
{
|
{
|
||||||
statusText = statusText[..497] + "...";
|
//statusText = statusText[..497] + "...";
|
||||||
|
int lineBreakIdx = 500 - new string(statusText.Take(500).Reverse().ToArray()).IndexOf(Environment.NewLine);
|
||||||
|
String postOne = statusText.Substring(0, lineBreakIdx);
|
||||||
|
String postTwo = statusText.Substring(lineBreakIdx);
|
||||||
|
|
||||||
|
var statusOne = await mastodonClient.PublishStatus(postOne,
|
||||||
|
Visibility.Public, null);
|
||||||
|
var statusTwo = await mastodonClient.PublishStatus(postTwo, Visibility.Public, statusOne.Id);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
_ = mastodonClient.PublishStatus(statusText,
|
||||||
|
Visibility.Public, null);
|
||||||
}
|
}
|
||||||
_ = mastodonClient.PublishStatus(statusText,
|
|
||||||
Visibility.Public, null);
|
|
||||||
/*
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user