summaryrefslogtreecommitdiff
path: root/www/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/index.php')
-rw-r--r--www/index.php46
1 files changed, 19 insertions, 27 deletions
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();
+}