From 0c49b1861205a57551f48d88011ae194a06e061d Mon Sep 17 00:00:00 2001 From: Alexander NeonXP Kiryukhin Date: Fri, 29 Jul 2016 13:27:56 +0300 Subject: Fix bugs --- composer.json | 3 +- composer.lock | 130 ++++++++++++++++++++++++++++++------------ log.1.html | 85 +++++++++++++++++++++++++++ log.txt | 85 +++++++++++++++++++++++++++ src/NeonXP/BotScript.php | 67 +++++++++++----------- src/NeonXP/DozorApi.php | 47 ++++++++------- www/index.php | 46 ++++++--------- www/static/openshift-logo.png | Bin 9714 -> 0 bytes 8 files changed, 346 insertions(+), 117 deletions(-) create mode 100755 log.1.html create mode 100644 log.txt delete mode 100644 www/static/openshift-logo.png diff --git a/composer.json b/composer.json index 67919f2..a3cbab0 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "minimum-stability": "dev", "require": { "neonxp/telegram-api": "dev-master", - "symfony/dom-crawler": "^3.0" + "symfony/dom-crawler": "^3.0", + "symfony/css-selector": "^3.1" } } diff --git a/composer.lock b/composer.lock index 9b09cb0..01b1eea 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b905a956faf901fc0ce67f9a4bca4445", - "content-hash": "c477f795380531a57cf3aa81e30c9dc3", + "hash": "4eea464407058e91b2e5a6e1d83bf070", + "content-hash": "a80265640d93978625f150ac21c0343c", "packages": [ { "name": "doctrine/annotations", @@ -81,12 +81,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "4e3b8b9464d511eccbefe07cef94c275bce7e434" + "reference": "fe68e4f78804684e31cce17590b0bd9f088db1b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/4e3b8b9464d511eccbefe07cef94c275bce7e434", - "reference": "4e3b8b9464d511eccbefe07cef94c275bce7e434", + "url": "https://api.github.com/repos/doctrine/cache/zipball/fe68e4f78804684e31cce17590b0bd9f088db1b0", + "reference": "fe68e4f78804684e31cce17590b0bd9f088db1b0", "shasum": "" }, "require": { @@ -142,7 +142,7 @@ "cache", "caching" ], - "time": "2016-03-11 16:30:04" + "time": "2016-07-15 15:57:08" }, { "name": "doctrine/instantiator", @@ -258,23 +258,23 @@ "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b1a96f6134f69cb41f8538d3a6491f4bb1dbab78" + "reference": "158c17127299b183d4b9784d7385bb29fe2f5982" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b1a96f6134f69cb41f8538d3a6491f4bb1dbab78", - "reference": "b1a96f6134f69cb41f8538d3a6491f4bb1dbab78", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/158c17127299b183d4b9784d7385bb29fe2f5982", + "reference": "158c17127299b183d4b9784d7385bb29fe2f5982", "shasum": "" }, "require": { - "guzzlehttp/promises": "~1.0", - "guzzlehttp/psr7": "~1.1", - "php": ">=5.5.0" + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.3.1", + "php": ">=5.5" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" }, "type": "library", "extra": { @@ -312,7 +312,7 @@ "rest", "web service" ], - "time": "2016-05-08 19:39:56" + "time": "2016-07-21 20:48:12" }, { "name": "guzzlehttp/promises", @@ -367,16 +367,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.3.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "31382fef2889136415751badebbd1cb022a4ed72" + "reference": "b1501c9fd5845473f39b89db5ac9a39a7ab62a38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", - "reference": "31382fef2889136415751badebbd1cb022a4ed72", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/b1501c9fd5845473f39b89db5ac9a39a7ab62a38", + "reference": "b1501c9fd5845473f39b89db5ac9a39a7ab62a38", "shasum": "" }, "require": { @@ -392,7 +392,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -412,16 +412,23 @@ "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", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ "http", "message", + "request", + "response", "stream", - "uri" + "uri", + "url" ], - "time": "2016-04-13 19:56:01" + "time": "2016-07-25 11:34:12" }, { "name": "jms/metadata", @@ -514,12 +521,12 @@ "source": { "type": "git", "url": "https://github.com/schmittjoh/serializer.git", - "reference": "b0a46c80cf3dbd97205f2e2ffeb9229080899c76" + "reference": "e0704d3959885d8999ff84791dcda19fb0b30980" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/b0a46c80cf3dbd97205f2e2ffeb9229080899c76", - "reference": "b0a46c80cf3dbd97205f2e2ffeb9229080899c76", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/e0704d3959885d8999ff84791dcda19fb0b30980", + "reference": "e0704d3959885d8999ff84791dcda19fb0b30980", "shasum": "" }, "require": { @@ -580,7 +587,7 @@ "serialization", "xml" ], - "time": "2016-05-21 12:25:17" + "time": "2016-07-27 11:04:12" }, { "name": "neonxp/telegram-api", @@ -814,18 +821,71 @@ ], "time": "2016-01-06 21:40:42" }, + { + "name": "symfony/css-selector", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "7a3ee9a4689295146659044f7c47c4734e0c552a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/7a3ee9a4689295146659044f7c47c4734e0c552a", + "reference": "7a3ee9a4689295146659044f7c47c4734e0c552a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\CssSelector\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "https://symfony.com", + "time": "2016-06-29 05:43:10" + }, { "name": "symfony/dom-crawler", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "d69763ec860db5f9e1b74d7cf06329030e24e170" + "reference": "2042e4285ed15bd36f7e82bce0dfc015ec60c2b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/d69763ec860db5f9e1b74d7cf06329030e24e170", - "reference": "d69763ec860db5f9e1b74d7cf06329030e24e170", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/2042e4285ed15bd36f7e82bce0dfc015ec60c2b3", + "reference": "2042e4285ed15bd36f7e82bce0dfc015ec60c2b3", "shasum": "" }, "require": { @@ -868,7 +928,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-05-13 18:13:23" + "time": "2016-07-26 08:08:27" }, { "name": "symfony/polyfill-mbstring", @@ -876,12 +936,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "67f0d2b927796648c5c38cedb7a2c8f1cf14e7dc" + "reference": "8a6bdec191138e01c92ae026e5aacb7b3e66267d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/67f0d2b927796648c5c38cedb7a2c8f1cf14e7dc", - "reference": "67f0d2b927796648c5c38cedb7a2c8f1cf14e7dc", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8a6bdec191138e01c92ae026e5aacb7b3e66267d", + "reference": "8a6bdec191138e01c92ae026e5aacb7b3e66267d", "shasum": "" }, "require": { @@ -927,7 +987,7 @@ "portable", "shim" ], - "time": "2016-05-26 01:13:28" + "time": "2016-06-29 14:58:48" } ], "packages-dev": [], diff --git a/log.1.html b/log.1.html new file mode 100755 index 0000000..91ba1a7 --- /dev/null +++ b/log.1.html @@ -0,0 +1,85 @@ + + + + + + + + DozoR.Lite / Joker`s revenge. + + + + + + + + +

. . .

22:18:26

+ + + + +

1. ( 22:00:00):

:

, . .



: 1, 1+, 1, 1+, 1, 1, 1
( - 7 , 6 , - 5)

: : 1939, 7721, 385, 4218, 3

+ + + + +
+ +
+ + :
+ :   + + + +
22:17:10 8331 
22:16:17 562 
22:15:40 4218 

+
+ + + + + +
+
+ + + + . +
+

! - . + +



+ + + +
+ +

: 2.0
: Joker`s revenge. . 2016-06-17 22:00:00.
: 11. : 0

: 20 .
: . ICQ: 332831243. tel: +79047650935

+ + \ No newline at end of file diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..b33cebe --- /dev/null +++ b/log.txt @@ -0,0 +1,85 @@ +a:2:{s:4:"http";a:3:{s:6:"method";s:4:"POST";s:6:"header";s:47:"Content-type: application/x-www-form-urlencoded";s:7:"content";s:93:"log=on&mes=&legend=on&nostat=¬ext=&refresh=0&bonus=&kladMap=¬ags=&cod=123&action=entcod";}s:6:"result";s:4383:" + + + + + + + DozoR.Lite / Joker`s revenge. + + + + + + + + +

. . .

22:18:26

+ + + + +

1. ( 22:00:00):

:

, . .



: 1, 1+, 1, 1+, 1, 1, 1
( - 7 , 6 , - 5)

: : 1939, 7721, 385, 4218, 3

+ + + + +
+ +
+ + :
+ :   + + + +
22:17:10 8331 
22:16:17 562 
22:15:40 4218 

+
+ + + + + +
+
+ + + + . +
+

! - . + +



+ + + +
+ +

: 2.0
: Joker`s revenge. . 2016-06-17 22:00:00.
: 11. : 0

: 20 .
: . ICQ: 332831243. tel: +79047650935

+ +";} \ No newline at end of file diff --git a/src/NeonXP/BotScript.php b/src/NeonXP/BotScript.php index 9309b5a..12313d2 100644 --- a/src/NeonXP/BotScript.php +++ b/src/NeonXP/BotScript.php @@ -2,16 +2,15 @@ namespace NeonXP; -use Doctrine\Common\Cache\CacheProvider; use NeonXP\TelegramApi\Types\Location; -use \NeonXP\TelegramApi\Types\Message; -use \NeonXP\TelegramApi\Script; -use \NeonXP\TelegramApi\Script\State; -use \NeonXP\TelegramApi\Script\Conditions\isText; -use \NeonXP\TelegramApi\Script\Conditions\isLocation; -use \NeonXP\TelegramApi\Script\Conditions\isMatch; -use \NeonXP\TelegramApi\Script\Conditions\isAnyText; -use \NeonXP\TelegramApi\Telegram; +use NeonXP\TelegramApi\Types\Message; +use NeonXP\TelegramApi\Script; +use NeonXP\TelegramApi\Script\State; +use NeonXP\TelegramApi\Script\Conditions\isText; +use NeonXP\TelegramApi\Script\Conditions\isLocation; +use NeonXP\TelegramApi\Script\Conditions\isMatch; +use NeonXP\TelegramApi\Script\Conditions\isAnyText; +use NeonXP\TelegramApi\Telegram; class BotScript { @@ -19,7 +18,8 @@ class BotScript { $saveLink = function (Message $message, Telegram $telegram) { $telegram->getCache()->save("link_{$message->getChat()->getId()}", $message->getText()); - $telegram->getMethods()->sendMessage($message->getChat(), 'Ок, записал: ' . $message->getText()); + $link = $telegram->getCache()->fetch("link_{$message->getChat()->getId()}"); + $telegram->getMethods()->sendMessage($message->getChat(), 'Ок, записал: '.$link); return State::INITIAL; }; @@ -38,7 +38,7 @@ class BotScript try { $result = $dozorApi->sendCode($message->getChat(), $code); } catch (\Exception $e) { - $telegram->getMethods()->sendMessage($message->getChat(), 'Ошибка сети', true); + $telegram->getMethods()->sendMessage($message->getChat(), 'Ошибка сети: '.$e->getMessage(), true); } if ($result) { $telegram->getMethods()->sendMessage($message->getChat(), $result, true); @@ -67,15 +67,15 @@ class BotScript $getDb = function (Message $message, Telegram $telegram) { $text = trim(substr($message->getText(), 1)); $db = [ - '1' => ['А', 'Я', 'A', 'Z', '00000', '. -'], - '2' => ['Б', 'Ю', 'B', 'Y', '00001', '- . . .'], - '3' => ['В', 'Э', 'C', 'X', '00010', '. - -'], - '4' => ['Г', 'Ь', 'D', 'W', '00011', '- - .'], - '5' => ['Д', 'Ы', 'E', 'V', '00100', '- . .'], - '6' => ['Е', 'Ъ', 'F', 'U', '00101', '.'], - '7' => ['Ё', 'Щ', 'G', 'T', '00101', '.'], - '8' => ['Ж', 'Ш', 'H', 'S', '00110', '. . . -'], - '9' => ['З', 'Ч', 'I', 'R', '00111', '- - . .'], + '1' => ['А', 'Я', 'A', 'Z', '00000', '. -'], + '2' => ['Б', 'Ю', 'B', 'Y', '00001', '- . . .'], + '3' => ['В', 'Э', 'C', 'X', '00010', '. - -'], + '4' => ['Г', 'Ь', 'D', 'W', '00011', '- - .'], + '5' => ['Д', 'Ы', 'E', 'V', '00100', '- . .'], + '6' => ['Е', 'Ъ', 'F', 'U', '00101', '.'], + '7' => ['Ё', 'Щ', 'G', 'T', '00101', '.'], + '8' => ['Ж', 'Ш', 'H', 'S', '00110', '. . . -'], + '9' => ['З', 'Ч', 'I', 'R', '00111', '- - . .'], '10' => ['И', 'Ц', 'J', 'Q', '01000', '. .'], '11' => ['Й', 'Х', 'K', 'P', '01001', '. - - -'], '12' => ['К', 'Ф', 'L', 'O', '01010', '- . -'], @@ -102,48 +102,49 @@ class BotScript '33' => ['Я', 'А', ' ', ' ', '11111', '. - . -'], ]; $result = 'Непонятно :('; - $header = ' № | А | Я | A | Z | Двоичн | Морзе ' . PHP_EOL . '____________________________________'; + $header = ' № | А | Я | A | Z | Двоич | Морзе '.PHP_EOL. + '___________________________________'; if ($text == '?') { $result = ''; foreach ($db as $key => $value) { if ($key < 10) { - $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } else { - $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } } } elseif (is_numeric($text) && (isset($db[$text]))) { $value = $db[$text]; if ($text < 10) { - $result = "0$text | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result = "0$text | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } else { - $result = "$text | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result = "$text | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } } else { $result = ''; - for ($i = 0; $i < mb_strlen($text, 'utf8'); $i++) { + for ($i = 0; $i < mb_strlen($text, 'utf8'); ++$i) { $char = mb_substr($text, $i, 1, 'utf8'); foreach ($db as $key => $value) { if (mb_strtolower($value[0], 'utf8') == mb_strtolower($char)) { if ($key < 10) { - $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } else { - $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } } if (strtolower($value[2]) == strtolower($char)) { if ($key < 10) { - $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "0$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } else { - $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]" . PHP_EOL; + $result .= "$key | $value[0] | $value[1] | $value[2] | $value[3] | $value[4] | $value[5]".PHP_EOL; } } } } } if ($result) { - $telegram->getMethods()->sendMessage($message->getChat(), '```' . $header . PHP_EOL . $result . '```', true); + $telegram->getMethods()->sendMessage($message->getChat(), '```'.$header.PHP_EOL.$result.'```', true); } return State::INITIAL; //Set initial state @@ -161,11 +162,11 @@ class BotScript action(new isText('/link'), $showLink)-> action(new isText('/setlink'), [ 'Пришлите ссылку с пином /cancel', - 'STATE_SET_LINK' + 'STATE_SET_LINK', ])-> action(new isText('/pause'), [ 'Замер. /resume для возврата', - 'STATE_PAUSE' + 'STATE_PAUSE', ])-> action(new isMatch('/^\!.+?$/i'), $sendCode)-> action(new isMatch('/^\?.+?$/i'), $getDb)-> diff --git a/src/NeonXP/DozorApi.php b/src/NeonXP/DozorApi.php index da724a9..4865e96 100644 --- a/src/NeonXP/DozorApi.php +++ b/src/NeonXP/DozorApi.php @@ -2,16 +2,15 @@ /** * @author Alexander "NeonXP" Kiryukhin */ + namespace NeonXP; + use Doctrine\Common\Cache\CacheProvider; use NeonXP\TelegramApi\Types\Chat; -use Symfony\Component\CssSelector\Node\AbstractNode; use Symfony\Component\DomCrawler\Crawler; - /** - * Class DozorApi - * @package NeonXP + * Class DozorApi. */ class DozorApi { @@ -22,6 +21,7 @@ class DozorApi /** * DozorApi constructor. + * * @param CacheProvider $cache */ public function __construct(CacheProvider $cache) @@ -32,31 +32,35 @@ class DozorApi public function sendCode(Chat $chat, $code) { $params = [ - "log" => 'on', - "mes" => '', - "legend" => 'on', - "nostat" => '', - "notext" => '', - "refresh" => '0', - "bonus" => '', - "kladMap" => '', - "notags" => '', - "cod" => $code, - "action" => 'entcod', + 'log' => 'on', + 'mes' => '', + 'legend' => 'on', + 'nostat' => '', + 'notext' => '', + 'refresh' => '0', + 'bonus' => '', + 'kladMap' => '', + 'notags' => '', + 'cod' => $code, + 'action' => 'entcod', ]; $data = http_build_query($params); $contextData = [ 'http' => [ 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', - 'content' => $data - ] + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $data, + ], ]; $context = stream_context_create($contextData); + if (!$this->getLink($chat)) { + throw new \Exception('Не задана ссылка'); + } $result = file_get_contents($this->getLink($chat), false, $context); $contextData['result'] = $result; - file_put_contents(getenv('OPENSHIFT_DATA_DIR') . 'log.txt', serialize($contextData)); + file_put_contents(getenv('OPENSHIFT_DATA_DIR').'log.txt', serialize($contextData)); + return $this->parseResult($result); } @@ -66,7 +70,7 @@ class DozorApi $answer = [ $this->parseCodeEnter($html), - $this->parseTask($crawler) + $this->parseTask($crawler), ]; $answer = array_merge($answer, $this->parseCodes($crawler)); @@ -78,9 +82,10 @@ class DozorApi private function parseCodeEnter($html) { $html = iconv('cp1251', 'utf8', $html); - $regex = '/\<\!\-\-errorText\-\-\>\\(.+?)\<\/strong\>\<\/p\>\<\!\-\-errorTextEnd\-\-\>'; + $regex = '/\<\!\-\-errorText\-\-\>\\(.+?)\<\/strong\>\<\/p\>\<\!\-\-errorTextEnd\-\-\>/i'; $result = []; preg_match($regex, $html, $result); + return $result[1]; } diff --git a/www/index.php b/www/index.php index 592919c..c7459a4 100644 --- a/www/index.php +++ b/www/index.php @@ -2,39 +2,31 @@ use \NeonXP\TelegramApi\Telegram; use \Doctrine\Common\Annotations\AnnotationRegistry; -use \NeonXP\TelegramApi\Types\Message; -use \NeonXP\TelegramApi\Types\InputFile; -use \NeonXP\TelegramApi\Script; -use \NeonXP\TelegramApi\Script\State; -use \NeonXP\TelegramApi\Script\Conditions\isText; -use \NeonXP\TelegramApi\Script\Conditions\isMatch; -use \NeonXP\TelegramApi\Script\Conditions\isAnyText; -use \NeonXP\TelegramApi\Script\Conditions\isContact; -use \NeonXP\TelegramApi\Script\Conditions\isPhoto; -use \NeonXP\TelegramApi\Script\Conditions\isSticker; -use \NeonXP\TelegramApi\Script\Conditions\isLocation; -use \NeonXP\TelegramApi\Script\Conditions\isDocument; -use \NeonXP\TelegramApi\Script\Conditions\isReply; -use \NeonXP\TelegramApi\Script\Conditions\isForward; -use \NeonXP\TelegramApi\Script\Conditions\isVideo; -use \NeonXP\TelegramApi\Script\Conditions\isVoice; -use \NeonXP\TelegramApi\Script\Conditions\isAudio; -use \NeonXP\TelegramApi\Helpers\StatusActions; -require './../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; AnnotationRegistry::registerAutoloadNamespace( 'JMS\Serializer\Annotation', __DIR__.'/../vendor/jms/serializer/src' ); -$cache = new \Doctrine\Common\Cache\ApcuCache(); - -$dozorApi = new \NeonXP\DozorApi($cache); - $telegram = new Telegram([ - 'token' => getenv('TELEGRAM_BOT_TOKEN') + 'token' => getenv('TELEGRAM_BOT_TOKEN'), ]); -$telegram->setCache($cache); -$telegram->setScript(\NeonXP\BotScript::getScript($telegram, $dozorApi)); -$telegram->handleWebhook(); + +if (getenv('env') == 'dev') { + $cache = new \Doctrine\Common\Cache\ArrayCache(); + $dozorApi = new \NeonXP\DozorApi($cache); + $telegram->setCache($cache); + $telegram->setScript(\NeonXP\BotScript::getScript($telegram, $dozorApi)); + while(1) { + $telegram->handleGetUpdates(); + sleep(1); + } +} else { + $cache = new \Doctrine\Common\Cache\ApcuCache(); + $dozorApi = new \NeonXP\DozorApi($cache); + $telegram->setCache($cache); + $telegram->setScript(\NeonXP\BotScript::getScript($telegram, $dozorApi)); + $telegram->handleWebhook(); +} diff --git a/www/static/openshift-logo.png b/www/static/openshift-logo.png deleted file mode 100644 index e83e59b..0000000 Binary files a/www/static/openshift-logo.png and /dev/null differ -- cgit v1.2.3