From e321324785608a8a270850ed9cfd2201d25b5f8f Mon Sep 17 00:00:00 2001 From: Denny Dai Date: Mon, 29 Jun 2015 22:13:58 +0800 Subject: [PATCH] Bot Api Version Bot Api Version --- BOT.php | 2 -- classes/Telegram-Bot/Base.php | 26 ++++++++++++++++++++++++++ classes/Telegram-Bot/init.php | 14 ++++++++++++++ classes/Telegram/init.php | 2 +- config.php | 5 +++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 classes/Telegram-Bot/Base.php create mode 100644 classes/Telegram-Bot/init.php diff --git a/BOT.php b/BOT.php index 746ab71..ea7a603 100644 --- a/BOT.php +++ b/BOT.php @@ -5,8 +5,6 @@ require_once('functions.php'); $plugins = []; require(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'Base.php'); -$BOT = new DBot\Base('unix:///tmp/tg.sck'); - require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.php'); //load plugins diff --git a/classes/Telegram-Bot/Base.php b/classes/Telegram-Bot/Base.php new file mode 100644 index 0000000..8e7b5a9 --- /dev/null +++ b/classes/Telegram-Bot/Base.php @@ -0,0 +1,26 @@ + array ( + 'method' => 'POST', + 'header' => "Content-type: application/x-www-form-urlencoded", + 'content' => http_build_query($data) + ) + ); + $context = stream_context_create($opts); + } + return file_get_contents(TB_API_URL.$command, false, $context); + } + public function msg($id, $msg) + { + return $this->exec('sendMessage', array('chat_id' => $id, 'text' => $msg)); + } +} + diff --git a/classes/Telegram-Bot/init.php b/classes/Telegram-Bot/init.php new file mode 100644 index 0000000..cae12db --- /dev/null +++ b/classes/Telegram-Bot/init.php @@ -0,0 +1,14 @@ + 0) { + $isgroup = false; +}else{ + $isgroup = true; +} +//reply to... + + $from = $GET['message']['chat']['id']; + $text = $GET['message']['text']; \ No newline at end of file diff --git a/classes/Telegram/init.php b/classes/Telegram/init.php index 3e4b1e6..ade1636 100644 --- a/classes/Telegram/init.php +++ b/classes/Telegram/init.php @@ -1,5 +1,5 @@