Browse Source

time cache

master
Alexander Yakovlev 4 years ago
parent
commit
990218238e
  1. 1
      .gitignore
  2. 9
      bot.php

1
.gitignore

@ -1,2 +1,3 @@
vendor
config.yml
.lastrun

9
bot.php

@ -3,6 +3,11 @@ require_once ("vendor/autoload.php");
use Symfony\Component\Yaml\Yaml;
$config = Yaml::parse(file_get_contents('config.yml'));
$lastrun = 0;
if (file_exists('.lastrun')) {
$lastrun = file_get_contents('.lastrun');
}
echo $lastrun;
function get_text($url) {
$curl = curl_init();
@ -29,6 +34,9 @@ $articles = $service->parse($string)[0]['value'];
unset($string);
$pandoc = new \Pandoc\Pandoc();
foreach ($articles as $article) {
if (strtotime($article['pubDate']) <= $lastrun) {
continue;
}
$title = $article['title'];
$link = $article['link'];
$description = $article['description'];
@ -52,3 +60,4 @@ foreach ($articles as $article) {
echo $description;
}
}
file_put_contents('.lastrun', time());
Loading…
Cancel
Save