<?php
try {
include "./../drive-loader.php";
$debug=false;
$BOT_USER= '@FuehrerscheinBot';
$BOT_TOKEN= TOKEN_DRIVE_BOT;
$uriParts = explode("?",$_SERVER['REQUEST_URI']);
$actual_link = "https://$_SERVER[HTTP_HOST]".$uriParts[0];
$WEBHOOK_URL= $actual_link;
$SIGN ="پوشش خبری شهر های آلمان ".PHP_EOL.'@FuehrerscheinBot';
$bot = new DriveGerman($BOT_USER,$BOT_TOKEN,$WEBHOOK_URL, $SIGN);
if (isset($_GET ['do']) && $_GET ['do'] == 'setWebhook') {
echo "setting webhook...\n";
echo "</br>webhook : $WEBHOOK_URL</br>";
// if run from console, set or delete webhook
$bot->setWebhook();
exit ();
}
if (isset($_GET ['do']) && $_GET ['do'] == 'debug') {
$debug = true;
ini_set('error_reporting',8191);
ini_set('display_errors',1);
}
$content = file_get_contents ( "php://input" );
$update = json_decode ( $content, true );
if ($_SERVER['SERVER_NAME'] == "localhost" || $debug) {
$bot->debug = true;
$debugUserID = 44903244;
$debugUserID = 467170469;
$debugUserID = 531889508;
$debugUserID = 264271258;
$debugUserID = 911228571;
$debugUserID = 590059263;
$debugUserID = 974058313;
$update = $bot->getDebugsManager()->getUpdateForCallBack($debugUserID);
}
if (! $update) {
exit ();
}
if (isset ( $update ["update_id"] )) {
$supportMsg = "امروز ربات لغتنامه کمی مشکل داشت، مشکل برطرف شد، کمی طول می کشه تا سرعت درست شه، ببخشید عزیزم";
$supportMsg = "ربات لغتنامه در حال ارتقا هست. از اینکه فعلا نمی تونم پاسخ بدم عذر می خوام. تا ساعاتی دیگه درست می شه";
$now = microtime(true);
// $bot->sendMessage($supportMsg, $update['from']['chat_id']);
$bot->process ( $update );
$last = microtime(true);
$tookTime = $last-$now;
if(false && ($bot->message ['text'] == "uni2cantest" || rand(1, 95) > 105)){
$bot->getAdsManager()->fetchActiveAds();
$bot->getAdsManager()->advertise($bot->getUser());
}
}
}
catch (Error $e) {
echo 'Exception abgefangen: ',
$e->getTraceAsString().PHP_EOL."</br>".
$e->getLine().PHP_EOL."</br>".
$e->getFile(),
$e->getMessage (), "\n";
$bot->sendMessageLog(
" error happend ".$e->getMessage ().PHP_EOL.
$e->getTraceAsString().PHP_EOL.
$e->getLine().PHP_EOL.
$e->getFile());
}
catch (Throwable $e)
{
echo 'Exception abgefangen: ',
$e->getTraceAsString().PHP_EOL."</br>".
$e->getLine().PHP_EOL."</br>".
$e->getFile(),
$e->getMessage (), "\n";
$bot->sendMessageLog(
" error happend ".$e->getMessage ().PHP_EOL.
$e->getTraceAsString().PHP_EOL.
$e->getLine().PHP_EOL.
$e->getFile()
);
}
?>