2018-05-13 10:02:22 +03:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
A set of utilities for tracking text-based game releases
|
|
|
|
Copyright (C) 2017-2018 Alexander Yakovlev
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-07-29 09:35:32 +03:00
|
|
|
require "vendor/autoload.php";
|
2018-05-13 10:02:22 +03:00
|
|
|
use Symfony\Component\Yaml\Yaml;
|
2019-07-29 09:35:32 +03:00
|
|
|
use Oreolek\Game;
|
|
|
|
use Oreolek\Source;
|
|
|
|
use Oreolek\Publisher;
|
2018-05-13 10:02:22 +03:00
|
|
|
use Revolution\Mastodon\MastodonClient;
|
|
|
|
use \GuzzleHttp\Client as GuzzleClient;
|
|
|
|
use Mremi\UrlShortener\Provider\Bitly\BitlyProvider;
|
|
|
|
use Mremi\UrlShortener\Provider\Bitly\GenericAccessTokenAuthenticator;
|
|
|
|
|
|
|
|
$config = Yaml::parse(file_get_contents('config.yml'));
|
|
|
|
define('STYLE',$config['STYLE']);
|
|
|
|
define('FORMAT',$config['FORMAT']);
|
|
|
|
|
2019-07-23 04:54:50 +03:00
|
|
|
$mastodon = new Publisher\Mastodon($config);
|
|
|
|
$jabber = new Publisher\Jabber($config);
|
|
|
|
$telegram = new Publisher\Telegram($config);
|
2018-05-13 10:02:22 +03:00
|
|
|
|
2019-08-06 16:59:04 +03:00
|
|
|
// $jabber->publish('hello world!'); die();
|
|
|
|
|
2018-05-13 10:02:22 +03:00
|
|
|
$parsers = [
|
2019-08-06 16:59:04 +03:00
|
|
|
// 'urq',
|
2018-05-13 10:02:22 +03:00
|
|
|
'anivisual',
|
|
|
|
'kvester',
|
|
|
|
'apero',
|
|
|
|
'instead',
|
|
|
|
'hyperbook_ru',
|
|
|
|
'hyperbook_en',
|
|
|
|
'questbook',
|
|
|
|
'textadventures',
|
|
|
|
'ifdb',
|
|
|
|
'dashingdon',
|
|
|
|
'itch',
|
|
|
|
'gamejolt',
|
|
|
|
'steam',
|
|
|
|
];
|
|
|
|
|
|
|
|
$lastrun = 0;
|
|
|
|
if (file_exists('.lastrun') && !$config['DRY_RUN']) {
|
|
|
|
$lastrun = file_get_contents('.lastrun');
|
|
|
|
}
|
|
|
|
|
|
|
|
$pandoc = new \Pandoc\Pandoc();
|
|
|
|
|
|
|
|
function check($classname, $command) {
|
|
|
|
global $parsers;
|
|
|
|
global $mastodon;
|
2019-07-23 04:54:50 +03:00
|
|
|
global $jabber;
|
2018-05-13 10:02:22 +03:00
|
|
|
global $telegram;
|
|
|
|
global $config;
|
|
|
|
if (in_array($command, $parsers)) {
|
2019-08-06 16:59:04 +03:00
|
|
|
$cname = 'Oreolek\\Source\\'.$classname;
|
2018-05-13 10:02:22 +03:00
|
|
|
$source = (new $cname());
|
|
|
|
$source->check();
|
|
|
|
if (empty($source->games)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
foreach ($source->games as $game) {
|
|
|
|
$description = $game->text();
|
|
|
|
if ($config['DRY_RUN']) {
|
|
|
|
echo $description."\n";
|
|
|
|
continue;
|
|
|
|
}
|
2019-07-23 04:54:50 +03:00
|
|
|
$telegram->publish($description);
|
|
|
|
$mastodon->publish($description);
|
|
|
|
$jabber->publish($description);
|
2018-05-13 10:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($config['parsers'] as $parser) {
|
|
|
|
$command = strtolower($parser['classname']);
|
|
|
|
if (isset($parser['command'])) {
|
|
|
|
$command = $parser['command'];
|
|
|
|
}
|
|
|
|
check ($parser['classname'], $command);
|
|
|
|
}
|