<?php
try {
// echo "hi";
include "../classes/MessageProcessor.php";
include "../classes/NewsDatabaseHandler.php";
include "../classes/BroadCast.php";
include "../classes/PostBaker.php";
include '../classes/MiniCurl.php';
$debug=false;
// define(BOT_USER, '@witzig_bot');
// define(BOT_TOKEN, '298464685:AAFcLFLihdT5luxv7qcXTARfU9M6Jo9V3Wc');
// define(WEBHOOK_URL, 'https://www.musicerian.tk/autopost/bots/witzig.php');
$BOT_USER= '@needGermany_bot';
$BOT_TOKEN= '328629017:AAFbyVIp7CaaTY5aqICu-wE1HTN7z1BODZM';
$WEBHOOK_URL= 'https://www.musicerian.tk/autopost/bots/needgermany.php';
$SIGN ="نیازمندی های آلمان @needgermany_bot";
$needGermany_bot = new BroadCast($BOT_USER,$BOT_TOKEN,$WEBHOOK_URL, $SIGN);
if (isset($_GET ['do']) && $_GET ['do'] == 'setWebhook') {
echo "setting webhook...\n";
// if run from console, set or delete webhook
$needGermany_bot->setWebhook();
exit ();
}
if (isset($_GET ['do']) && $_GET ['do'] == 'postNews') {
$postBaker= new PostBaker($BOT_USER,$BOT_TOKEN, $SIGN);
echo "post news";
// $postBaker->postNews();
exit ();
}
$content = file_get_contents ( "php://input" );
$update = json_decode ( $content, true );
// $testMessage = var_export ( $update, true );
// file_put_contents ( "testquery.html", $testMessage, FILE_APPEND | LOCK_EX );
if ($_SERVER ['SERVER_NAME'] == "localhost" || $debug) {
// $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' => 'bremen'
)
);
$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"] )) {
// print_r($update);
$needGermany_bot->process ( $update );
}
} catch ( Exception $e ) {
echo 'Exception abgefangen: ', $e->getMessage (), "\n";
}
?>