Post new items.
This commit is contained in:
parent
477bf265d4
commit
8bfd9218cb
17
src/main.cpp
17
src/main.cpp
|
@ -1,25 +1,30 @@
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
|
#include "mastoapi.hpp"
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
#include <boost/log/core.hpp>
|
#include <boost/log/core.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <boost/log/utility/setup/console.hpp>
|
#include <boost/log/utility/setup/console.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace mastorss;
|
using namespace mastorss;
|
||||||
|
using std::chrono::seconds;
|
||||||
using std::getenv;
|
using std::getenv;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
using std::string_view;
|
using std::string_view;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::this_thread::sleep_for;
|
||||||
|
|
||||||
namespace mastorss
|
namespace mastorss
|
||||||
{
|
{
|
||||||
|
@ -94,9 +99,19 @@ int main(int argc, char *argv[])
|
||||||
Document doc{cfg};
|
Document doc{cfg};
|
||||||
doc.parse();
|
doc.parse();
|
||||||
|
|
||||||
|
MastoAPI masto{cfg.data};
|
||||||
|
if (!doc.new_items.empty())
|
||||||
|
{
|
||||||
for (const auto &item : doc.new_items)
|
for (const auto &item : doc.new_items)
|
||||||
{
|
{
|
||||||
cout << "--\n" << item.description.substr(0, 200) << "\n";
|
masto.post_item(item);
|
||||||
|
cfg.data.last_guid = item.guid;
|
||||||
|
if (item != *doc.new_items.rbegin())
|
||||||
|
{ // Don't sleep if this is the last item.
|
||||||
|
sleep_for(seconds(cfg.data.interval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg.write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const FileException &e)
|
catch (const FileException &e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user