Объединяем с викиботом
This commit is contained in:
parent
6c219330ef
commit
9019e9c26e
53
Source.php
53
Source.php
|
@ -14,9 +14,12 @@ abstract class Source {
|
|||
$this->period = strtotime("1 week ago");
|
||||
$this->output = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to start the section.
|
||||
* @param whether to return or print the text
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
protected function startSection($return = false) {
|
||||
if (FORMAT === 'MARKDOWN') {
|
||||
|
@ -30,27 +33,21 @@ abstract class Source {
|
|||
}
|
||||
$this->output .= $text;
|
||||
}
|
||||
|
||||
protected function endSection() {
|
||||
if (FORMAT === 'HTML') {
|
||||
$text = "</ul></spoiler>\n";
|
||||
}
|
||||
$this->output .= $text;
|
||||
}
|
||||
|
||||
abstract protected function parse();
|
||||
public function print() {
|
||||
$this->startSection();
|
||||
try {
|
||||
$this->parse();
|
||||
} catch (\Exception $e) {
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
echo $e->getTraceAsString();
|
||||
return;
|
||||
}
|
||||
$this->endSection();
|
||||
if ($this->output === $this->startSection(true)) // nothing to print
|
||||
return;
|
||||
echo $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* System function to download page HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_text($url) {
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
|
@ -62,12 +59,38 @@ abstract class Source {
|
|||
curl_close($curl);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the game line and catch all exceptions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function check() {
|
||||
try {
|
||||
$this->print();
|
||||
$this->startSection();
|
||||
try {
|
||||
$this->parse();
|
||||
} catch (\Exception $e) {
|
||||
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
echo $e->getTraceAsString();
|
||||
return;
|
||||
}
|
||||
$this->endSection();
|
||||
if ($this->output === $this->startSection(true)) // nothing to print
|
||||
return;
|
||||
echo $this->output;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if URL corresponds to this source.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function checkPage($url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"paquettg/php-html-parser": "^1.7",
|
||||
"aura/autoload": "^2.0",
|
||||
"sabre/xml": "^2.0",
|
||||
"league/html-to-markdown": "^4.4"
|
||||
"league/html-to-markdown": "^4.4",
|
||||
"addwiki/mediawiki-api": "^0.7.2"
|
||||
}
|
||||
}
|
||||
|
|
382
composer.lock
generated
382
composer.lock
generated
|
@ -4,8 +4,157 @@
|
|||
"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": "c9715035ce158bfa729e665ae0b87544",
|
||||
"content-hash": "f18a94a205dd3f539f5d191093fc70e7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "addwiki/mediawiki-api",
|
||||
"version": "0.7.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/addwiki/mediawiki-api.git",
|
||||
"reference": "f52fc3760d82774512d344e41c45c878a2c6659e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/addwiki/mediawiki-api/zipball/f52fc3760d82774512d344e41c45c878a2c6659e",
|
||||
"reference": "f52fc3760d82774512d344e41c45c878a2c6659e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"addwiki/mediawiki-api-base": "~2.4",
|
||||
"addwiki/mediawiki-datamodel": "~0.7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-parallel-lint": "^0.9.2",
|
||||
"mediawiki/mediawiki-codesniffer": "^13.0",
|
||||
"monolog/monolog": "^1.23",
|
||||
"phpunit/phpunit": "~4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.7.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mediawiki\\Api\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0+"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Addshore"
|
||||
}
|
||||
],
|
||||
"description": "A MediaWiki API library",
|
||||
"keywords": [
|
||||
"mediawiki"
|
||||
],
|
||||
"time": "2017-11-20T03:08:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "addwiki/mediawiki-api-base",
|
||||
"version": "2.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/addwiki/mediawiki-api-base.git",
|
||||
"reference": "33c147e91d05a48e953839fb3ad9e6386cfd85c1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/addwiki/mediawiki-api-base/zipball/33c147e91d05a48e953839fb3ad9e6386cfd85c1",
|
||||
"reference": "33c147e91d05a48e953839fb3ad9e6386cfd85c1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"guzzlehttp/promises": "~1.0",
|
||||
"php": ">=5.5",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-parallel-lint": "0.9.2",
|
||||
"mediawiki/mediawiki-codesniffer": "^13.0",
|
||||
"phpunit/phpunit": "~4.8.0|~5.3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"etsy/phan": "Allows running static analysis on the package (requires PHP 7+)"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mediawiki\\Api\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0+"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Addshore"
|
||||
}
|
||||
],
|
||||
"description": "A basic Mediawiki api base library",
|
||||
"keywords": [
|
||||
"mediawiki"
|
||||
],
|
||||
"time": "2017-11-02T10:53:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "addwiki/mediawiki-datamodel",
|
||||
"version": "0.7.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/addwiki/mediawiki-datamodel.git",
|
||||
"reference": "05dd783715a92ec5449bab4091c0482cf3fcface"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/addwiki/mediawiki-datamodel/zipball/05dd783715a92ec5449bab4091c0482cf3fcface",
|
||||
"reference": "05dd783715a92ec5449bab4091c0482cf3fcface",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-parallel-lint": "0.9.2",
|
||||
"mediawiki/mediawiki-codesniffer": "^13.0",
|
||||
"phpunit/phpunit": "~4.8.0|~5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.7.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mediawiki\\DataModel\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0+"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Addshore"
|
||||
}
|
||||
],
|
||||
"description": "A Mediawiki datamodel",
|
||||
"keywords": [
|
||||
"mediawiki"
|
||||
],
|
||||
"time": "2018-01-10T19:14:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "aura/autoload",
|
||||
"version": "2.0.4",
|
||||
|
@ -55,6 +204,187 @@
|
|||
],
|
||||
"time": "2016-10-03T19:36:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "6.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.4",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"phpunit/phpunit": "^4.0 || ^5.0",
|
||||
"psr/log": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.2-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": "2017-06-22T18:50:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
"version": "v1.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/promises.git",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0"
|
||||
},
|
||||
"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": "2016-12-20T10:07:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "1.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-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",
|
||||
"request",
|
||||
"response",
|
||||
"stream",
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2017-03-20T17:10:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/html-to-markdown",
|
||||
"version": "4.4.1",
|
||||
|
@ -307,6 +637,56 @@
|
|||
],
|
||||
"time": "2016-05-18T13:57:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"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": "1.0.2",
|
||||
|
|
40
wiki.php
Executable file
40
wiki.php
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require "vendor/autoload.php";
|
||||
require "Game.php";
|
||||
require "Source.php";
|
||||
$config = parse_ini_file("./config.ini");
|
||||
$loader = new \Aura\Autoload\Loader;
|
||||
$loader->register();
|
||||
$loader->addPrefix('Source', 'Source');
|
||||
|
||||
if (!isset($argv[1])) {
|
||||
echo 'Please provide the direct URL to the game page.'.PHP_EOL;
|
||||
die();
|
||||
}
|
||||
$url = strtolower($argv[1]);
|
||||
$game = new Game;
|
||||
|
||||
function check($classname) {
|
||||
global $game;
|
||||
global $url;
|
||||
|
||||
$cname = 'Source\\'.$classname;
|
||||
$cl = (new $cname());
|
||||
if ($cl->checkPage($url)) {
|
||||
$game = $cl->page($url);
|
||||
}
|
||||
}
|
||||
|
||||
check ('Urq', 'urq');
|
||||
check ('Qsp');
|
||||
check ('Kvester');
|
||||
check ('Apero');
|
||||
check ('Instead');
|
||||
check ('Hyperbook');
|
||||
check ('HyperbookEn');
|
||||
check ('Questbook');
|
||||
check ('Anivisual');
|
||||
check ('Itch');
|
||||
check ('Gamejolt');
|
||||
check ('Steam');
|
Reference in a new issue