From 04a73cb018bc4d24978b9732bfc8428b1f85b244 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Fri, 2 Nov 2018 15:19:04 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20-=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=20=D0=B8=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D1=8B=D0=B2=D0=BA=D0=B8=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + README.md | 11 + composer.json | 16 + composer.lock | 1377 ++++++++++++++++++++++++++++++++++++++++++++ config.yml.example | 13 + run.php | 89 +++ 6 files changed, 1509 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config.yml.example create mode 100755 run.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57a5bb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/config.ini +/config.yml +/vendor diff --git a/README.md b/README.md new file mode 100644 index 0000000..8080a44 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Бот оглашения результатов КРИЛ + +Бот для оглашения результатов. + +Принимает список победителей и постит объявления в Twitter и Telegram с конца списка с интервалом 5 минут. + +## Установка + +1. Скопировать `config.yml.example` в `config.yml`, отредактировать. +1. `composer install` +1. Запустить `run.php` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d8b5568 --- /dev/null +++ b/composer.json @@ -0,0 +1,16 @@ +{ + "minimum-stability": "dev", + "require": { + "aura/autoload": "^2.0", + "ryakad/pandoc-php": "^1.0", + "longman/telegram-bot": "dev-master", + "mremi/url-shortener": "dev-master", + "revolution/laravel-mastodon-api": "dev-master", + "symfony/yaml": "^4.2@dev" + }, + "require-dev": { + }, + "scripts": { + "test": "phpunit tests/" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5b12da6 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1377 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "6903e9f20556c5d8505d2e29be759a61", + "packages": [ + { + "name": "aura/autoload", + "version": "2.x-dev", + "source": { + "type": "git", + "url": "https://github.com/auraphp/Aura.Autoload.git", + "reference": "306a7f8d3cb58fb6f94bcff1dddf20c543f68668" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/auraphp/Aura.Autoload/zipball/306a7f8d3cb58fb6f94bcff1dddf20c543f68668", + "reference": "306a7f8d3cb58fb6f94bcff1dddf20c543f68668", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "aura": { + "type": "library" + } + }, + "autoload": { + "psr-4": { + "Aura\\Autoload\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Aura.Autoload Contributors", + "homepage": "https://github.com/auraphp/Aura.Autoload/contributors" + } + ], + "description": "Provides a PSR-4 compliant autoloader implementation.", + "homepage": "https://github.com/auraphp/Aura.Autoload", + "keywords": [ + "PSR-4", + "SPL autoloader", + "autoload", + "autoloader", + "class loader" + ], + "time": "2016-10-03T19:36:19+00:00" + }, + { + "name": "doctrine/inflector", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "82890572668fc150f30046c5af7d6b277825c3b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/82890572668fc150f30046c5af7d6b277825c3b5", + "reference": "82890572668fc150f30046c5af7d6b277825c3b5", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^3.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2018-05-08T11:02:15+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "cf86e51dd6331187c0a5dfe03d15ef7950199b63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/cf86e51dd6331187c0a5dfe03d15ef7950199b63", + "reference": "cf86e51dd6331187c0a5dfe03d15ef7950199b63", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-11-01T21:47:08+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "926eaa3ff73cde2becf652b785831bcb7618568a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/926eaa3ff73cde2becf652b785831bcb7618568a", + "reference": "926eaa3ff73cde2becf652b785831bcb7618568a", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2018-10-30T00:20:04+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "23e7d3812a82bdbff4a5cb8e4628bcc06eec5d68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/23e7d3812a82bdbff4a5cb8e4628bcc06eec5d68", + "reference": "23e7d3812a82bdbff4a5cb8e4628bcc06eec5d68", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2018-11-01T01:48:29+00:00" + }, + { + "name": "illuminate/contracts", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "6c265114ce6ba749b06073556bb2a82e7a5b1581" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/6c265114ce6ba749b06073556bb2a82e7a5b1581", + "reference": "6c265114ce6ba749b06073556bb2a82e7a5b1581", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/container": "^1.0", + "psr/simple-cache": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.8-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "time": "2018-10-31T15:00:02+00:00" + }, + { + "name": "illuminate/support", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "3a4363fc563c317f7d9ee00fe4a0b4f840b8fc3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/3a4363fc563c317f7d9ee00fe4a0b4f840b8fc3e", + "reference": "3a4363fc563c317f7d9ee00fe4a0b4f840b8fc3e", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^1.1", + "ext-json": "*", + "ext-mbstring": "*", + "illuminate/contracts": "5.8.*", + "nesbot/carbon": "^1.26.3 || ^2.0", + "php": "^7.1.3" + }, + "conflict": { + "tightenco/collect": "<5.5.33" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (5.8.*).", + "moontoast/math": "Required to use ordered UUIDs (^1.1).", + "ramsey/uuid": "Required to use Str::uuid() (^3.7).", + "symfony/process": "Required to use the composer class (^4.1).", + "symfony/var-dumper": "Required to use the dd function (^4.1)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.8-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + }, + "files": [ + "helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "https://laravel.com", + "time": "2018-10-26T10:37:41+00:00" + }, + { + "name": "longman/telegram-bot", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-telegram-bot/core.git", + "reference": "7701428356a70b0b5d88404248a060ca1c43c6ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-telegram-bot/core/zipball/7701428356a70b0b5d88404248a060ca1c43c6ba", + "reference": "7701428356a70b0b5d88404248a060ca1c43c6ba", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-pdo": "*", + "guzzlehttp/guzzle": "^6.3", + "monolog/monolog": "^1.23", + "php": "^5.5|^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.5|^7.4", + "squizlabs/php_codesniffer": "^3.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Longman\\TelegramBot\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Avtandil Kikabidze aka LONGMAN", + "email": "akalongman@gmail.com", + "homepage": "http://longman.me", + "role": "Developer" + }, + { + "name": "PHP Telegram Bot Team", + "homepage": "https://github.com/php-telegram-bot/core/graphs/contributors", + "role": "Developer" + } + ], + "description": "PHP Telegram bot", + "homepage": "https://github.com/php-telegram-bot/core", + "keywords": [ + "api", + "bot", + "telegram" + ], + "time": "2018-10-23T16:50:28+00:00" + }, + { + "name": "monolog/monolog", + "version": "1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "c465e1144536862e03f519cb3d65e924062cabfb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c465e1144536862e03f519cb3d65e924062cabfb", + "reference": "c465e1144536862e03f519cb3d65e924062cabfb", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "jakub-onderka/php-parallel-lint": "0.9", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpunit/phpunit": "~4.5", + "phpunit/phpunit-mock-objects": "2.3.0", + "ruflin/elastica": ">=0.90 <3.0", + "sentry/sentry": "^0.13", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "sentry/sentry": "Allow sending log messages to a Sentry server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2018-06-19T07:22:34+00:00" + }, + { + "name": "mremi/url-shortener", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/mremi/UrlShortener.git", + "reference": "d814c07e27dedd359b865b27e8d01ed0f25b4a40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mremi/UrlShortener/zipball/d814c07e27dedd359b865b27e8d01ed0f25b4a40", + "reference": "d814c07e27dedd359b865b27e8d01ed0f25b4a40", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "php": "^5.5 || ^7.0", + "symfony/console": "^2.7 || ^3.1 || ^4.1" + }, + "require-dev": { + "fabpot/php-cs-fixer": "~0.1 || ~1.0", + "phpunit/phpunit": "~4.8", + "symfony/phpunit-bridge": "~2.7 || ~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Mremi\\UrlShortener\\": "src/Mremi/UrlShortener" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rémi Marseille", + "email": "marseille.remi@gmail.com" + } + ], + "description": "A PHP5 library using API to shorten/expand URL", + "homepage": "https://github.com/mremi/UrlShortener", + "keywords": [ + "api", + "shortener", + "url" + ], + "time": "2018-10-15T07:04:05+00:00" + }, + { + "name": "nesbot/carbon", + "version": "2.5.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "790f2bc8c560541cc5a12e506195e3df4ee2c862" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/790f2bc8c560541cc5a12e506195e3df4ee2c862", + "reference": "790f2bc8c560541cc5a12e506195e3df4ee2c862", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.1.8", + "symfony/translation": "^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.11", + "phpunit/phpunit": "^7.1.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2018-10-26T20:15:03+00:00" + }, + { + "name": "psr/container", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "2cc4a01788191489dc7459446ba832fa79a216a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/2cc4a01788191489dc7459446ba832fa79a216a7", + "reference": "2cc4a01788191489dc7459446ba832fa79a216a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-06-28T15:35:32+00:00" + }, + { + "name": "psr/http-message", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "3490ba5925e6dcbe6de950c5c6b8dce9f6e96eda" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/3490ba5925e6dcbe6de950c5c6b8dce9f6e96eda", + "reference": "3490ba5925e6dcbe6de950c5c6b8dce9f6e96eda", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2018-04-03T15:59:15+00:00" + }, + { + "name": "psr/simple-cache", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" + }, + { + "name": "revolution/laravel-mastodon-api", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/kawax/laravel-mastodon-api.git", + "reference": "5fd8083599174da4fe4d15e7386d670fe5f0099b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kawax/laravel-mastodon-api/zipball/5fd8083599174da4fe4d15e7386d670fe5f0099b", + "reference": "5fd8083599174da4fe4d15e7386d670fe5f0099b", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.2", + "illuminate/support": "^5.5", + "php": ">=7.0.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "orchestra/testbench": "~3.5", + "phpunit/phpunit": "6.*" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Revolution\\Mastodon\\Providers\\MastodonServiceProvider" + ], + "aliases": { + "Mastodon": "Revolution\\Mastodon\\Facades\\Mastodon" + } + } + }, + "autoload": { + "psr-4": { + "Revolution\\Mastodon\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "kawax", + "email": "kawaxbiz@gmail.com" + } + ], + "description": "Mastodon API for Laravel", + "keywords": [ + "laravel", + "mastodon" + ], + "time": "2018-05-17T06:29:25+00:00" + }, + { + "name": "ryakad/pandoc-php", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/ryakad/pandoc-php.git", + "reference": "0cfdf959408e4c481db942b26785d94b9fe46672" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ryakad/pandoc-php/zipball/0cfdf959408e4c481db942b26785d94b9fe46672", + "reference": "0cfdf959408e4c481db942b26785d94b9fe46672", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Pandoc": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "time": "2015-01-07T05:07:16+00:00" + }, + { + "name": "symfony/console", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "0a26a2eadf8d06b48074daae9ce7e208d690e151" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/0a26a2eadf8d06b48074daae9ce7e208d690e151", + "reference": "0a26a2eadf8d06b48074daae9ce7e208d690e151", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" + }, + "suggest": { + "psr/log-implementation": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2018-10-31T10:56:31+00:00" + }, + { + "name": "symfony/contracts", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/contracts.git", + "reference": "4a33574d5771f4b04334cd4f7d43de96a92efb62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/contracts/zipball/4a33574d5771f4b04334cd4f7d43de96a92efb62", + "reference": "4a33574d5771f4b04334cd4f7d43de96a92efb62", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-10-31T08:00:32+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, + { + "name": "symfony/translation", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "35acf59e7dafd3ac919e16babaae0b6378fab564" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/35acf59e7dafd3ac919e16babaae0b6378fab564", + "reference": "35acf59e7dafd3ac919e16babaae0b6378fab564", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<3.4", + "symfony/dependency-injection": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "symfony/translation-contracts-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/console": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/intl": "~3.4|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2018-10-31T10:56:31+00:00" + }, + { + "name": "symfony/yaml", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "7228a3e2163ab5623231f126cf8d7701072f9d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/7228a3e2163ab5623231f126cf8d7701072f9d16", + "reference": "7228a3e2163ab5623231f126cf8d7701072f9d16", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2018-10-02T16:38:08+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": { + "longman/telegram-bot": 20, + "mremi/url-shortener": 20, + "revolution/laravel-mastodon-api": 20, + "symfony/yaml": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/config.yml.example b/config.yml.example new file mode 100644 index 0000000..9e407de --- /dev/null +++ b/config.yml.example @@ -0,0 +1,13 @@ +DRY_RUN: true +TELEGRAM: true +MASTODON: true +MASTODON_ACCESS_TOKEN: token +MASTODON_SERVER: https://botsin.space +MASTODON_USER: user +TELEGRAM_API_KEY: some-key-here +TELEGRAM_BOT_NAME: bot name +TELEGRAM_CHAT_ID: id +BITLY_TOKEN: token +games: + 30: "«Тринадцать» — А.Я.Клешня, И.Я.Клешня" + 20: "«Хорошие числа» — Аноним" diff --git a/run.php b/run.php new file mode 100755 index 0000000..5124ad8 --- /dev/null +++ b/run.php @@ -0,0 +1,89 @@ +#!/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')); + +var_dump($config['games']); +die(); +$pandoc = new \Pandoc\Pandoc(); +$bitlyProvider = new BitlyProvider( + new GenericAccessTokenAuthenticator($config['BITLY_TOKEN']) +); +if ($config['TELEGRAM'] === true) { + $telegram = new Longman\TelegramBot\Telegram( + $config['TELEGRAM_API_KEY'], + $config['TELEGRAM_BOT_NAME'] + ); +} +if ($config['MASTODON'] === true) { + $guzzle = new GuzzleClient([ + 'timeout' => 30, + ]); + $mastodon = new MastodonClient($guzzle); +} + +foreach ($source->games as $game) { + $description = $game->text(); + if ($config['DRY_RUN']) { + echo $description."\n"; + continue; + } + if ($config['TELEGRAM'] === true) { + try { + $result = \Longman\TelegramBot\Request::sendMessage([ + 'chat_id' => $config['TELEGRAM_CHAT_ID'], + 'text' => $description, + 'parse_mode' => 'Markdown' + ]); + if (!$config['DRY_RUN']) { + file_put_contents('.lastrun', time()); + } + } catch (Longman\TelegramBot\Exception\TelegramException $e) { + echo $e; + } + } + if ($config['MASTODON'] === true) { + $mastodon->domain($config['MASTODON_SERVER'])->token($config['MASTODON_ACCESS_TOKEN']); + /* + if ($image) { + download('https://ifhub.club'.$image, './'.basename($image)); + $attachment = $mastodon->post('/media', [ + 'file' => file_get_contents('./'.basename($image)) + ]); + var_dump($attachment); + unlink('./'.basename($image)); + $mdescription .= $attachment->url; + } + */ + $mastodon->createStatus($description, [ + 'language' => 'en' + ]); + if (!$config['DRY_RUN']) { + file_put_contents('.lastrun', time()); + } + } +}