mirror of
https://gitlab.com/ifiction/ifhub-telegram.git
synced 2024-10-22 22:15:31 +00:00
time cache
This commit is contained in:
parent
28fdff3ffe
commit
990218238e
2 changed files with 10 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
vendor
|
vendor
|
||||||
config.yml
|
config.yml
|
||||||
|
.lastrun
|
||||||
|
|
9
bot.php
9
bot.php
|
@ -3,6 +3,11 @@ require_once ("vendor/autoload.php");
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
$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) {
|
function get_text($url) {
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
@ -29,6 +34,9 @@ $articles = $service->parse($string)[0]['value'];
|
||||||
unset($string);
|
unset($string);
|
||||||
$pandoc = new \Pandoc\Pandoc();
|
$pandoc = new \Pandoc\Pandoc();
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
if (strtotime($article['pubDate']) <= $lastrun) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$title = $article['title'];
|
$title = $article['title'];
|
||||||
$link = $article['link'];
|
$link = $article['link'];
|
||||||
$description = $article['description'];
|
$description = $article['description'];
|
||||||
|
@ -52,3 +60,4 @@ foreach ($articles as $article) {
|
||||||
echo $description;
|
echo $description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_put_contents('.lastrun', time());
|
||||||
|
|
Loading…
Reference in a new issue