<?php
try {
include "../classes/LoghatnamehEnglish.php";
include "../classes/MessageProcessor.php";
include "../classes/database/DictionaryEnglishDatabaseHandler.php";
include "../classes/TranslateEnglish.php";
include "../classes/PostBaker.php";
include '../classes/MiniCurl.php';
$debug=false;
$BOT_USER= '@TranslateEnglish_bot';
$BOT_TOKEN= '265804160:AAG4C2BAiBxN8Lgrmt61C_L9Jhpzwu8N1Bw';
$uriParts = explode("?",$_SERVER[REQUEST_URI]);
$actual_link = "https://$_SERVER[HTTP_HOST]".$uriParts[0];
//$WEBHOOK_URL= 'https://vpsapi.tk/loghatnameh/autoPost/bots/translategerman2.php';
$WEBHOOK_URL= $actual_link;
$SIGN ="پوشش خبری شهر های آلمان".PHP_EOL."@TranslateService";
$translate_bot = new TranslateEnglish($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
$translate_bot->setWebhook();
exit ();
}
if (isset($_GET ['do']) && $_GET ['do'] == 'newword') {
$translate_bot->sendMessage("new word ".$_GET ['word'], $translate_bot->adminId);
exit();
}
if (isset($_GET ['do']) && $_GET ['do'] == 'error') {
$translate_bot->sendMessage("error word ".$_GET ['word'], $translate_bot->adminId);
exit();
}
$content = file_get_contents ( "php://input" );
$update = json_decode ( $content, true );
// $testMessage = var_export ( $update, true );
// file_put_contents ( "testmessagetype.html", $testMessage, FILE_APPEND | LOCK_EX );
// exit();
if ($_SERVER ['SERVER_NAME'] == "localhost" || $debug) {
echo "debug : ".PHP_EOL;
// $update = array ( 'update_id' => 802512343, 'message' => array ( 'message_id' => 865, 'from' => array ( 'id' => 44903244445, 'first_name' => 'Saeed', 'username' => 'sinzed', ), 'chat' => array ( 'id' => 44903244, 'first_name' => 'Saeed', 'username' => 'sinzed', 'type' => 'private', ), 'date' => 1480911910, 'forward_from' => array ( 'id' => 44903244, 'first_name' => 'Saeed', 'username' => 'sinzed', ), 'forward_date' => 1480910459, 'video' => array ( 'duration' => 5, 'width' => 400, 'height' => 400, 'thumb' => array ( 'file_id' => 'AAQCABN4EIINAARY0M8fcMg54QLBAAIC', 'file_size' => 2464, 'width' => 90, 'height' => 90, ), 'file_id' => 'BAADAgAD6wUAAkwrrQJiWLK_HahlFQI', 'file_size' => 271180, ), ), );
$update1 = array (
'update_id' => 310853147,
'message' => array (
'message_id' => 10,
'from' => array (
'id' => 44903244,
'first_name' => 'Saeed',
'username' => 'sinzed'
),
'chat' => array (
'id' => 44903244,
'first_name' => 'Saeed',
'username' => 'sinzed',
'type' => 'private'
),
'date' => 1481901731,
'text' => 'color'
)
);
$update = array (
'update_id' => 310853411,
'callback_query' =>
array (
'id' => '192857965748151190',
'from' =>
array (
'id' => 44903244,
'first_name' => 'Saeed',
'username' => 'sinzed',
),
'message' =>
array (
'message_id' => 759,
'from' =>
array (
'id' => 287525955,
'first_name' => 'ربات خبر های آلمان',
'username' => 'khabaralman_bot',
),
'chat' =>
array (
'id' => 44903244,
'first_name' => 'Saeed',
'username' => 'sinzed',
'type' => 'private',
),
'date' => 1482078484,
'text' => 'Nachricht0 Nach Skandal um Ex-Chefin - Bremer Unternehmen rettet Nordsee-Pflege Nordsee-Pflege-Chefin Gülsen Sariergin (37) wurde zu fünf Jahren Gefängnis verurteiltAufatmen für 180 Mitarbeiter und rund 600 Kunden: Die „Nordsee-Pflege" und sämtliche Arbeits- und Pflegeplätze sind so gut wie gerettet! Foto: Sandra Beckefeldt Sun, 18 Dec 2016 13:59:52 +0100',
'entities' =>
array (
0 =>
array (
'type' => 'bold',
'offset' => 11,
'length' => 68,
),
1 =>
array (
'type' => 'text_link',
'offset' => 79,
'length' => 1,
'url' => 'http://bilder.bild.de/fotos/nordsee-pflege-chefin-guelsen-sariergin-37-wurde-zu-fuenf-jahren-gefaengnis-verurteilt-200191517-49375400/Bild/2.bild.jpg',
),
2 =>
array (
'type' => 'pre',
'offset' => 325,
'length' => 33,
),
),
),
'chat_instance' => '6071330103816430450',
'data' => 'ww',
),
);
$update = $update1;
}
if (! $update) {
exit ();
}
// $testMessage = var_export ( $update, true );
// file_put_contents ( "testquery.html", $testMessage, FILE_APPEND | LOCK_EX );
if (isset ( $update ["update_id"] )) {
$translate_bot->process ( $update );
}
} catch ( Exception $e ) {
echo 'Exception abgefangen: ', $e->getMessage (), "\n";
}
?>