#!/usr/bin/php . */ require_once ("vendor/autoload.php"); use Symfony\Component\Yaml\Yaml; 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']); require_once "Game.php"; require_once "Source.php"; require_once "Publisher.php"; require_once "_download.php"; $loader = new \Aura\Autoload\Loader; $loader->register(); $loader->addPrefix('Source', 'Source'); $loader->addPrefix('Publisher', 'Publisher'); $mastodon = new Publisher\Mastodon($config); $jabber = new Publisher\Jabber($config); $telegram = new Publisher\Telegram($config); $parsers = [ // 'urq', '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; global $jabber; global $telegram; global $config; if (in_array($command, $parsers)) { $cname = 'Source\\'.$classname; $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; } $telegram->publish($description); $mastodon->publish($description); $jabber->publish($description); } } } foreach($config['parsers'] as $parser) { $command = strtolower($parser['classname']); if (isset($parser['command'])) { $command = $parser['command']; } check ($parser['classname'], $command); }