You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

97 lines
2.5 KiB

  1. #!/usr/bin/php
  2. <?php
  3. /*
  4. A set of utilities for tracking text-based game releases
  5. Copyright (C) 2017-2018 Alexander Yakovlev
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. require "vendor/autoload.php";
  18. use Symfony\Component\Yaml\Yaml;
  19. use Oreolek\Game;
  20. use Oreolek\Source;
  21. use Oreolek\Publisher;
  22. use Revolution\Mastodon\MastodonClient;
  23. use \GuzzleHttp\Client as GuzzleClient;
  24. use Mremi\UrlShortener\Provider\Bitly\BitlyProvider;
  25. use Mremi\UrlShortener\Provider\Bitly\GenericAccessTokenAuthenticator;
  26. $config = Yaml::parse(file_get_contents('config.yml'));
  27. define('STYLE',$config['STYLE']);
  28. define('FORMAT',$config['FORMAT']);
  29. $mastodon = new Publisher\Mastodon($config);
  30. $jabber = new Publisher\Jabber($config);
  31. $telegram = new Publisher\Telegram($config);
  32. // $jabber->publish('hello world!'); die();
  33. $parsers = [
  34. // 'urq',
  35. 'anivisual',
  36. 'kvester',
  37. 'apero',
  38. 'instead',
  39. 'hyperbook_ru',
  40. 'hyperbook_en',
  41. 'questbook',
  42. 'textadventures',
  43. 'ifdb',
  44. 'dashingdon',
  45. 'itch',
  46. 'gamejolt',
  47. 'steam',
  48. ];
  49. $lastrun = 0;
  50. if (file_exists('.lastrun') && !$config['DRY_RUN']) {
  51. $lastrun = file_get_contents('.lastrun');
  52. }
  53. $pandoc = new \Pandoc\Pandoc();
  54. function check($classname, $command) {
  55. global $parsers;
  56. global $mastodon;
  57. global $jabber;
  58. global $telegram;
  59. global $config;
  60. if (in_array($command, $parsers)) {
  61. $cname = 'Oreolek\\Source\\'.$classname;
  62. $source = (new $cname());
  63. $source->check();
  64. if (empty($source->games)) {
  65. return;
  66. }
  67. foreach ($source->games as $game) {
  68. $description = $game->text();
  69. if ($config['DRY_RUN']) {
  70. echo $description."\n";
  71. continue;
  72. }
  73. $telegram->publish($description);
  74. $mastodon->publish($description);
  75. $jabber->publish($description);
  76. }
  77. }
  78. }
  79. foreach($config['parsers'] as $parser) {
  80. $command = strtolower($parser['classname']);
  81. if (isset($parser['command'])) {
  82. $command = $parser['command'];
  83. }
  84. check ($parser['classname'], $command);
  85. }