Changed behaviour when last entry is not in current feed
This commit is contained in:
parent
e6d12bc3dd
commit
696ea1ff57
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastorss
|
project (mastorss
|
||||||
VERSION 0.3.4
|
VERSION 0.3.5
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,12 @@ int main(int argc, char *argv[])
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the last entry is not in the current feed, set the oldest item as last entry
|
||||||
|
// Could lead to spamming if an item gets deleted or changed.
|
||||||
|
if (!new_content)
|
||||||
|
{
|
||||||
|
config.put(profile + ".last_entry", entries.at(entries.size() - 1));
|
||||||
|
}
|
||||||
pt::write_json(filepath + "config-" + profile + ".json", config);
|
pt::write_json(filepath + "config-" + profile + ".json", config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -121,7 +121,7 @@ std::vector<string> parse_website(const string &profile, const string &xml)
|
||||||
string str = title + "\n\n" + desc;
|
string str = title + "\n\n" + desc;
|
||||||
|
|
||||||
// ANF News puts this always on top, causing us to think it's new
|
// ANF News puts this always on top, causing us to think it's new
|
||||||
if (title.compare("Newsticker zu den Angriffen auf Efrîn ") == 0)
|
if (title.compare(0, 35, "Newsticker zu den Angriffen auf Efr") == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ std::vector<string> parse_website(const string &profile, const string &xml)
|
||||||
str = std::regex_replace(str, reindyfuckup, "");
|
str = std::regex_replace(str, reindyfuckup, "");
|
||||||
str = std::regex_replace(str, redaclosing, "");
|
str = std::regex_replace(str, redaclosing, "");
|
||||||
str = std::regex_replace(str, reggboclosing, "");
|
str = std::regex_replace(str, reggboclosing, "");
|
||||||
str = std::regex_replace(str, std::regex("[\\r\\n] [\\r\\n]"), "\n\n"); // remove space between newlines
|
str = std::regex_replace(str, std::regex("[\\r\\n] +[\\r\\n]"), "\n\n"); // remove space between newlines
|
||||||
str = std::regex_replace(str, std::regex("[\\r\\n]{3,}"), "\n"); // remove excess newlines
|
str = std::regex_replace(str, std::regex("[\\r\\n]{3,}"), "\n"); // remove excess newlines
|
||||||
|
|
||||||
for (const string &hashtag : watchwords)
|
for (const string &hashtag : watchwords)
|
||||||
|
@ -162,7 +162,7 @@ std::vector<string> parse_website(const string &profile, const string &xml)
|
||||||
if ((str.size() + link.size()) > (std::uint16_t)(max_size - 15))
|
if ((str.size() + link.size()) > (std::uint16_t)(max_size - 15))
|
||||||
{
|
{
|
||||||
str.resize((max_size - link.size() - 15));
|
str.resize((max_size - link.size() - 15));
|
||||||
str.resize(str.rfind(' '));
|
str.resize(str.rfind(' ')); // Cut at word boundary
|
||||||
str += " […]";
|
str += " […]";
|
||||||
}
|
}
|
||||||
str += "\n\n" + link + "\n\n#bot";
|
str += "\n\n" + link + "\n\n#bot";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user