├── .gitignore ├── LICENSE.md ├── README.md ├── Tekook └── TelegramLibrary │ ├── Actions.php │ ├── EventHandler.php │ ├── Events.php │ ├── Exceptions │ ├── ArgumentException.php │ ├── MissingKeyException.php │ └── TelegramException.php │ ├── Markups │ ├── ForceReply.php │ ├── IReplyMarkup.php │ ├── ReplyKeyboardHide.php │ └── ReplyKeyboardMarkup.php │ ├── TelegramBotApi.php │ └── Types │ ├── Audio.php │ ├── Contact.php │ ├── Document.php │ ├── File.php │ ├── GroupChat.php │ ├── IChat.php │ ├── IFile.php │ ├── ILocation.php │ ├── IMessage.php │ ├── IUser.php │ ├── Location.php │ ├── Message.php │ ├── PhotoSize.php │ ├── Sticker.php │ ├── Type.php │ ├── Update.php │ ├── User.php │ ├── UserProfilePhotos.php │ └── Video.php └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | Tekook/TelegramLibrary/include.php -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ##The MIT License (MIT)## 2 | 3 | Copyright (c) 2015 Julian Tekook 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP-TelegramLibrary 2 | PHP Library for the new Telegram Bot API 3 | 4 | * Event based programming for the [new bot api](https://core.telegram.org/bots/api) 5 | * Closures 6 | * Composer Ready 7 | * Fully OOP 8 | * All Methods and Types available 9 | * Documented 10 | 11 | ####Usage##### 12 | Initiate the TelegramBotApi object with your token. 13 | Register the wanted hook within the event handler 14 | Use the central "pushUpdate" Method to start the Handling 15 | 16 | 17 | 18 | ####Example#### 19 | 20 | ```` 21 | use Tekook\TelegramLibrary; 22 | 23 | $telegram = new TelegramLibrary\TelegramBotApi(""); 24 | 25 | 26 | $eventHandler = $telegram->getEventHandler(); 27 | $eventHandler->addHook(TelegramLibrary\Events::TEXT, 28 | function(\Tekook\TelegramLibrary\Types\Message $message) { 29 | if ($message->getText() == "A") { 30 | $message->reply("OK", ["reply_markup" => new TelegramLibrary\Markups\ReplyKeyboardHide()]); 31 | } else { 32 | $message->reply("Hello, " . $message->getFrom()->getFirstName() . " please answer A!", 33 | [ 34 | "reply_markup" => new TelegramLibrary\Markups\ReplyKeyboardMarkup([ 35 | ["A", "B"], 36 | ["C", "D"], 37 | ["E", "F"], 38 | ]) 39 | ]); 40 | } 41 | }); 42 | 43 | $telegram->pushUpdate(); 44 | ```` 45 | 46 | ##Author## 47 | [Julian Tekook](www.dj-digital.net) 48 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Actions.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 28.06.2015 22:56:12 8 | * $Rev: 549 $ 9 | * $Id: Actions.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary; 13 | 14 | /** 15 | * Contains the diffrent actions which can be used for sendChatAction 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Actions 20 | { 21 | const TYPING = "typing"; 22 | const UPLOADING_PHOTO = "upload_photo"; 23 | const UPLOADING_VIDEO = "upload_video"; 24 | const UPLOADING_AUDIO = "upload_audio"; 25 | const UPLOADING_DOCUMENT = "upload_document"; 26 | const FINDING_LOCATION = "find_location"; 27 | const RECORDING_VIDEO = "record_video"; 28 | } 29 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/EventHandler.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 29.06.2015 12:50:41 8 | * $Rev: 551 $ 9 | * $Id: EventHandler.php 551 2015-06-30 17:30:46Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary; 13 | 14 | /** 15 | * Manager for all events. You an hook an event here 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class EventHandler 20 | { 21 | 22 | /** 23 | * The api the handler belongs to 24 | * @var \Tekook\TelegramLibrary\TelegramBotApi 25 | */ 26 | protected $api; 27 | 28 | /** 29 | * Events with closures 30 | * @var array 31 | */ 32 | protected $events = array(); 33 | 34 | public function __construct(\Tekook\TelegramLibrary\TelegramBotApi $api) 35 | { 36 | $this->api = $api; 37 | } 38 | 39 | /** 40 | * Point to handle events 41 | * @param \Tekook\TelegramLibrary\Types\Update $update 42 | */ 43 | public function handle(\Tekook\TelegramLibrary\Types\Update $update) 44 | { 45 | $message = $update->getMessage(); 46 | 47 | if (isset($this->events[$message->getEvent()])) { 48 | foreach ($this->events[$message->getEvent()] as $closure) { 49 | $closure($message, $this->api); 50 | } 51 | } elseif ($message->isFile() && isset($this->events[Events::ANY_FILE])) { 52 | foreach ($this->events[Events::ANY_FILE] as $closure) { 53 | $closure($message, $this->api); 54 | } 55 | } elseif (isset($this->events[Events::NOT_REGISTERED])) { 56 | foreach ($this->events[Events::NOT_REGISTERED] as $closure) { 57 | $closure($message, $this->api); 58 | } 59 | } 60 | } 61 | 62 | /** 63 | * Adds a new hook the the event handler. 64 | * Returns the ID of the added hook 65 | * @param int $event ID of the Event. @see \Tekook\TelegramLibrary\Events 66 | * @param \Closure $closure Closure to execute 67 | * @return int 68 | */ 69 | public function addHook($event, \Closure $closure) 70 | { 71 | if (!is_int($event)) { 72 | throw new Exceptions\ArgumentException("Argument \$event must be int."); 73 | } 74 | 75 | if (!isset($this->events[$event])) { 76 | $this->events[$event] = array(); 77 | } 78 | $this->events[$event][] = $closure; 79 | return count($this->events[$event]) - 1; 80 | } 81 | 82 | /** 83 | * Removes the hook if it exists 84 | * @param int $event 85 | * @param int $id 86 | */ 87 | public function removeHook($event, $id) 88 | { 89 | if (isset($this->events[$event]) && isset($this->events[$event][$id])) { 90 | unset($this->events[$event][$id]); 91 | } 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Events.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 27.06.2015 18:55:00 8 | * $Rev: 549 $ 9 | * $Id: Events.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary; 13 | 14 | /** 15 | * Contains the diffrent event types of message objects 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Events 20 | { 21 | 22 | /** 23 | * Event of a simple text message 24 | */ 25 | const TEXT = 1; 26 | 27 | /** 28 | * Event of an audio file 29 | */ 30 | const AUDIO = 2; 31 | 32 | /** 33 | * Event of a document file 34 | */ 35 | const DOCUMENT = 3; 36 | 37 | /** 38 | * Event of a photo file 39 | */ 40 | const PHOTO = 4; 41 | 42 | /** 43 | * Event of a sticker file 44 | */ 45 | const STICKER = 5; 46 | 47 | /** 48 | * Event of a video file 49 | */ 50 | const VIDEO = 6; 51 | 52 | /** 53 | * Event of an attached contact 54 | */ 55 | const CONTACT = 7; 56 | 57 | /** 58 | * Event of an attached location 59 | */ 60 | const LOCATION = 8; 61 | 62 | /** 63 | * Event of a new participant in a groupchat 64 | */ 65 | const NEW_CHAT_PARTICIPANT = 9; 66 | 67 | /** 68 | * Event of a left participant in a groupchat 69 | */ 70 | const LEFT_CHAT_PARTICIPANT = 10; 71 | 72 | /** 73 | * Event of a new title in a groupchat 74 | */ 75 | const NEW_CHAT_TITLE = 11; 76 | 77 | /** 78 | * Event of a new photo in a groupchat 79 | */ 80 | const NEW_CHAT_PHOTO = 12; 81 | 82 | /** 83 | * Event a the groupchat photo been deleted 84 | */ 85 | const DELETE_CHAT_PHOTO = 13; 86 | 87 | /** 88 | * Event of a groupchat being created 89 | */ 90 | const GROUP_CHAT_CREATED = 14; 91 | 92 | /** 93 | * Event of ANY file being received 94 | * ATTENTION this will only be called if the file type is NOT registered 95 | */ 96 | const ANY_FILE = 15; 97 | 98 | /** 99 | * Event if the given event is not registered (e.g to capture events which the bot does not support) 100 | */ 101 | const NOT_REGISTERED = 16; 102 | 103 | } 104 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Exceptions/ArgumentException.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: DJ-Digital.Net 6 | * @copyright: 2015 7 | * @created: 29.06.2015 11:12:40 8 | * $Rev: 549 $ 9 | * $Id: ArgumentException.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Exceptions; 13 | 14 | /** 15 | * Description of WrongParameterException 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class ArgumentException extends TelegramException 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Exceptions/MissingKeyException.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: DJ-Digital.Net 6 | * @copyright: 2015 7 | * @created: 29.06.2015 11:12:40 8 | * $Rev: 549 $ 9 | * $Id: MissingKeyException.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Exceptions; 13 | 14 | /** 15 | * Description of MissingKeyException 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class MissingKeyException extends TelegramException 20 | { 21 | //put your code here 22 | } 23 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Exceptions/TelegramException.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: DJ-Digital.Net 6 | * @copyright: 2015 7 | * @created: 29.06.2015 11:12:40 8 | * $Rev: 549 $ 9 | * $Id: TelegramException.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Exceptions; 13 | 14 | /** 15 | * Description of TelegramException 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class TelegramException extends \Exception 20 | { 21 | //put your code here 22 | } 23 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Markups/ForceReply.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 29.06.2015 13:46:21 8 | * $Rev: 549 $ 9 | * $Id: ForceReply.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Markups; 13 | 14 | /** 15 | * Description of ForceReply 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class ForceReply implements IReplyMarkup 20 | { 21 | 22 | protected $selective = false; 23 | 24 | public function __construct($selective = false) 25 | { 26 | $this->selective = $selective; 27 | } 28 | 29 | /** 30 | * Returns the object as JSON string 31 | * @return string 32 | */ 33 | public function toJson() 34 | { 35 | return json_encode([ 36 | "force_reply" => true, 37 | "selective" => $this->selective, 38 | ]); 39 | } 40 | 41 | /** 42 | * Returns the object as JSON string 43 | * @return string 44 | */ 45 | public function toString() 46 | { 47 | return $this->toJson(); 48 | } 49 | 50 | /** 51 | * Returns the object as JSON string 52 | * @return string 53 | */ 54 | public function __toString() 55 | { 56 | return $this->toJson(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Markups/IReplyMarkup.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 29.06.2015 13:40:41 8 | * $Rev: 549 $ 9 | * $Id: IReplyMarkup.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Markups; 13 | 14 | /** 15 | * Description of IReplyMarkup 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface IReplyMarkup 20 | { 21 | 22 | /** 23 | * Returns the Object as json string 24 | * @return string 25 | */ 26 | public function toJson(); 27 | 28 | /** 29 | * Returns the object as string 30 | * @return string 31 | */ 32 | public function toString(); 33 | 34 | /** 35 | * Returns the object as string 36 | * @return string 37 | */ 38 | public function __toString(); 39 | } 40 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Markups/ReplyKeyboardHide.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 29.06.2015 13:46:21 8 | * $Rev: 549 $ 9 | * $Id: ReplyKeyboardHide.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Markups; 13 | 14 | /** 15 | * Description of ReplyKeyboardHide 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class ReplyKeyboardHide implements IReplyMarkup 20 | { 21 | 22 | protected $selective = false; 23 | 24 | public function __construct($selective = false) 25 | { 26 | $this->selective = $selective; 27 | } 28 | 29 | /** 30 | * Returns the object as JSON string 31 | * @return string 32 | */ 33 | public function toJson() 34 | { 35 | return json_encode([ 36 | "hide_keyboard" => true, 37 | "selective" => $this->selective, 38 | ]); 39 | } 40 | 41 | /** 42 | * Returns the object as JSON string 43 | * @return string 44 | */ 45 | public function toString() 46 | { 47 | return $this->toJson(); 48 | } 49 | 50 | /** 51 | * Returns the object as JSON string 52 | * @return string 53 | */ 54 | public function __toString() 55 | { 56 | return $this->toJson(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Markups/ReplyKeyboardMarkup.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 29.06.2015 13:41:37 8 | * $Rev: 549 $ 9 | * $Id: ReplyKeyboardMarkup.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Markups; 13 | 14 | /** 15 | * Description of ReplyKeyboardMarkup 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class ReplyKeyboardMarkup implements IReplyMarkup 20 | { 21 | 22 | protected $keyboard; 23 | protected $resizeKeyboard = false; 24 | protected $oneTimeKeyboard = false; 25 | protected $selective = false; 26 | 27 | public function __construct(array $keyboard, $resizeKeyboard = false, $oneTimeKeyboard = false, $selective = false) 28 | { 29 | $this->keyboard = $keyboard; 30 | $this->resizeKeyboard = $resizeKeyboard; 31 | $this->oneTimeKeyboard = $oneTimeKeyboard; 32 | $this->selective = $selective; 33 | } 34 | 35 | /** 36 | * Returns the object as JSON string 37 | * @return string 38 | */ 39 | public function toJson() 40 | { 41 | return json_encode([ 42 | "keyboard" => $this->keyboard, 43 | "resize_keyboard" => $this->resizeKeyboard, 44 | "one_time_keyboard" => $this->oneTimeKeyboard, 45 | "selective" => $this->selective, 46 | ]); 47 | } 48 | 49 | /** 50 | * Returns the object as JSON string 51 | * @return string 52 | */ 53 | public function toString() 54 | { 55 | return $this->toJson(); 56 | } 57 | 58 | /** 59 | * Returns the object as JSON string 60 | * @return string 61 | */ 62 | public function __toString() 63 | { 64 | return $this->toJson(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/TelegramBotApi.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: DJ-Digital.Net 6 | * @copyright: 2015 7 | * @created: 26.06.2015 18:10:40 8 | * $Rev: 550 $ 9 | * $Id: TelegramBotApi.php 550 2015-06-30 09:48:45Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary; 13 | 14 | /** 15 | * Central API class for managing the API 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class TelegramBotApi 20 | { 21 | 22 | /** 23 | * API Url of Telegram 24 | */ 25 | const API = "https://api.telegram.org/bot"; 26 | 27 | /** 28 | * Curl-Session for Requests 29 | * @var resource 30 | */ 31 | protected $curl = null; 32 | 33 | /** 34 | * The Prefix for all requests with the botToken 35 | * @var string 36 | */ 37 | protected $apiPrefix = ""; 38 | 39 | /** 40 | * EventHandler for this api 41 | * @var \Tekook\TelegramLibrary\EventHandler 42 | */ 43 | protected $eventHandler = null; 44 | 45 | /** 46 | * Creates a new TelegramBotApi object to manage your Bot 47 | * @param string $botToken The token to auth your bot 48 | */ 49 | public function __construct($botToken) 50 | { 51 | $this->curl = curl_init(); 52 | $this->apiPrefix = TelegramBotApi::API . $botToken . "/"; 53 | $this->eventHandler = new EventHandler($this); 54 | } 55 | 56 | /** 57 | * Calls a method of the bot-api with the given arguments 58 | * @param string $method Name of the Method 59 | * @param array $arguments Optional POST Arguments 60 | * @throws Exception 61 | * @return \stdClass 62 | */ 63 | protected function call($method, array $arguments = null, array $my_curl_options = array()) 64 | { 65 | $curl_options = array_merge($my_curl_options, [ 66 | CURLOPT_URL => $this->apiPrefix . $method, 67 | CURLOPT_RETURNTRANSFER => true, 68 | CURLOPT_POST => null, 69 | CURLOPT_POSTFIELDS => null, 70 | CURLOPT_SSL_VERIFYPEER => 0, 71 | ]); 72 | 73 | if (!is_null($arguments)) { 74 | $curl_options[CURLOPT_POST] = true; 75 | $curl_options[CURLOPT_POSTFIELDS] = $arguments; 76 | } 77 | 78 | curl_setopt_array($this->curl, $curl_options); 79 | $cont = curl_exec($this->curl); 80 | if (!$cont) { 81 | throw new Exceptions\TelegramException(curl_error($this->curl), curl_errno($this->curl)); 82 | } else { 83 | $response = json_decode($cont, false); 84 | 85 | if (!$response->ok) { 86 | throw new Exceptions\TelegramException($response->description, $response->error_code); 87 | } 88 | 89 | return $response; 90 | } 91 | } 92 | 93 | /** 94 | * Returns the event handler of this api 95 | * @return \Tekook\TelegramLibrary\EventHandler 96 | */ 97 | public function getEventHandler() 98 | { 99 | return $this->eventHandler; 100 | } 101 | 102 | /** 103 | * A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a User object. 104 | * @return \Tekook\TelegramLibrary\Types\User 105 | */ 106 | public function getMe() 107 | { 108 | return $this->call("getMe"); 109 | } 110 | 111 | /** 112 | * Central function to handle incoming Updates via WebHoook 113 | * Performs event handling and hook calling 114 | * @param string $input if not given, php://input will be used 115 | */ 116 | public function pushUpdate($input = null) 117 | { 118 | if (is_null($input)) { 119 | $input = file_get_contents("php://input"); 120 | } 121 | $json = json_decode($input, false); 122 | 123 | $update = new Types\Update($json, $this); 124 | 125 | $this->eventHandler->handle($update); 126 | } 127 | 128 | /** 129 | * Use this method to specify a url and receive incoming updates via an outgoing webhook. 130 | * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. 131 | * In case of an unsuccessful request, we will give up after a reasonable amount of attempts. 132 | * @param string $url 133 | * @return \stdClass 134 | */ 135 | public function setWebhook($url) 136 | { 137 | return $this->call("setWebhook", ["url" => $url]); 138 | } 139 | 140 | /** 141 | * Sends a text message to the given Chat (Can be a User or a Groupchat) 142 | * @param \Tekook\TelegramLibrary\Types\IChat $chat 143 | * @param string $text 144 | * @param array $options Optional options 145 | * @return \stdClass 146 | */ 147 | public function sendMessage(\Tekook\TelegramLibrary\Types\IChat $chat, $text, array $options = array()) 148 | { 149 | $myOptions = array_merge($options, ["chat_id" => $chat->getId(), "text" => $text]); 150 | return $this->call("sendMessage", $myOptions); 151 | } 152 | 153 | /** 154 | * Sends a file to the given $chat 155 | * @param \Tekook\TelegramLibrary\Types\IChat $chat The recipient 156 | * @param \Tekook\TelegramLibrary\Types\IFile $file The file to send 157 | * @param array $options Optional options 158 | * @return \stdClass 159 | */ 160 | public function sendFile(\Tekook\TelegramLibrary\Types\IChat $chat, \Tekook\TelegramLibrary\Types\IFile $file, 161 | array $options = array()) 162 | { 163 | $myOptions = array_merge($options, ["chat_id" => $chat->getId(), $file->getFileType() => $file->getFileId()]); 164 | return $this->call("send" . ucfirst($file->getFileType()), $myOptions); 165 | } 166 | 167 | /** 168 | * Uploads a new file to the given $chat from a file which lays in the filesystem 169 | * @param \Tekook\TelegramLibrary\Types\IChat $chat 170 | * @param string $fileType filetype to send. E.g. audio, video, photo, etc... 171 | * @param string $fileName the ABSOLUTE File Path to the file 172 | * @param array $options Optional options 173 | * @return \stdClass 174 | */ 175 | public function uploadFile(\Tekook\TelegramLibrary\Types\IChat $chat, $fileType, $fileName, array $options = array()) 176 | { 177 | $myOptions = array_merge($options, ["chat_id" => $chat->getId(), $fileType => "@" . $fileName]); 178 | return $this->call("send" . ucfirst($fileType), $myOptions, ["CURLOPT_INFILESIZE" => filesize($fileName)]); 179 | } 180 | 181 | /** 182 | * Sends a location to the given $chat 183 | * @param \Tekook\TelegramLibrary\Types\IChat $chat The recipient 184 | * @param \Tekook\TelegramLibrary\Types\ILocation $location The location to send 185 | * @param array $options Optional options 186 | * @return \stdClass 187 | */ 188 | public function sendLocation(\Tekook\TelegramLibrary\Types\IChat $chat, 189 | \Tekook\TelegramLibrary\Types\ILocation $location, array $options = array()) 190 | { 191 | $myOptions = array_merge($options, 192 | [ 193 | "chat_id" => $chat->getId(), 194 | "latitude" => $location->getLatitude(), 195 | "longitude" => $location->getLongitude() 196 | ]); 197 | return $this->call("sendLocation", $myOptions); 198 | } 199 | 200 | /** 201 | * Enumerates the profile photos of the given $user 202 | * @param \Tekook\TelegramLibrary\Types\IUser $user The user 203 | * @param int $offset Optional offset 204 | * @param int $limit Optional limit 205 | * @return \Tekook\TelegramLibrary\Types\UserProfilePhotos 206 | */ 207 | public function getUserProfilePhotos(\Tekook\TelegramLibrary\Types\IUser $user, $offset = 0, $limit = 100) 208 | { 209 | $response = $this->call("getUserProfilePhotos", 210 | ["user_id" => $user->getId(), "offset" => $offset, "limit" => $limit]); 211 | return new \Tekook\TelegramLibrary\Types\UserProfilePhotos($response->result); 212 | } 213 | 214 | /** 215 | * Use this method to receive incoming updates using long polling. An Array of Update objects is returned. 216 | * @param int $offset Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. 217 | * @param int $limit Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100 218 | * @param int $timeout Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling 219 | * @return \Tekook\TelegramLibrary\Types\Update 220 | */ 221 | public function getUpdates($offset = 0, $limit = 100, $timeout = 0) 222 | { 223 | $response = $this->call("getUpdates", ["offset" => $offset, "limit" => $limit, "timeout" => $timeout]); 224 | $updates = array(); 225 | foreach ($response->result as $update) { 226 | $updates[] = new Types\Update($update, $this); 227 | } 228 | return $updates; 229 | } 230 | 231 | /** 232 | * Sends a chat action to the given $chat indicating what the bot is doing right now 233 | * Should be one of \Tekook\TelegramLibrary\Actions constants 234 | * @param \Tekook\TelegramLibrary\Types\IChat $chat The recipient 235 | * @param string $action Constants of \Tekook\TelegramLibrary\Actions 236 | * @return \stdClass 237 | */ 238 | public function sendChatAction(\Tekook\TelegramLibrary\Types\IChat $chat, $action) 239 | { 240 | return $this->call("sendChatAction", ["chat_id" => $chat->getId(), "action" => $action]); 241 | } 242 | 243 | /** 244 | * Forwards the given $message to a $target. 245 | * If $source is not given, the chat of $message will be used 246 | * @param \Tekook\TelegramLibrary\Types\IChat $target The recipient 247 | * @param \Tekook\TelegramLibrary\Types\IMessage $message The message to forward 248 | * @param \Tekook\TelegramLibrary\Types\IChat $source Optional source chat 249 | * @return \stdClass 250 | */ 251 | public function forwardMessage(\Tekook\TelegramLibrary\Types\IChat $target, 252 | \Tekook\TelegramLibrary\Types\IMessage $message, \Tekook\TelegramLibrary\Types\IChat $source = null) 253 | { 254 | if ($source == null) { 255 | $source_id = $message->getFromChatId(); 256 | } else { 257 | $source_id = $source->getId(); 258 | } 259 | return $this->call("forwardMessage", 260 | [ 261 | "chat_id" => $target->getId(), 262 | "from_chat_id" => $source_id, 263 | "message_id" => $message->getMessageId() 264 | ]); 265 | } 266 | 267 | } 268 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Audio.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:47:17 8 | * $Rev: 549 $ 9 | * $Id: Audio.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents an audio file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Audio extends File 20 | { 21 | 22 | protected $fileType = "audio"; 23 | 24 | public function __construct(\stdClass $data) 25 | { 26 | parent::__construct($data); 27 | 28 | $this->checkData("duration", true); 29 | $this->checkData("mime_type", false, true); 30 | } 31 | 32 | /** 33 | * Returns the duration of the AudioFile 34 | * @return int 35 | */ 36 | public function getDuration() 37 | { 38 | return $this->data->duration; 39 | } 40 | 41 | /** 42 | * Returns the mime type of the AudioFile 43 | * @return string 44 | */ 45 | public function getMimeType() 46 | { 47 | return $this->data->mime_type; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Contact.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:52:40 8 | * $Rev: 549 $ 9 | * $Id: Contact.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents an contact file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Contact extends Type 20 | { 21 | 22 | public function __construct(\stdClass $data) 23 | { 24 | parent::__construct($data); 25 | 26 | $this->checkData("phone_number", true); 27 | $this->checkData("first_name", true); 28 | $this->checkData("last_name", false, true); 29 | $this->checkData("user_id", false, true); 30 | } 31 | 32 | /** 33 | * Returns the phone number of the contact 34 | * @return string 35 | */ 36 | public function getPhoneNumber() 37 | { 38 | return $this->data->phone_number; 39 | } 40 | 41 | /** 42 | * Returns the first name of the contact 43 | * @return string 44 | */ 45 | public function getFirstName() 46 | { 47 | return $this->data->first_name; 48 | } 49 | 50 | /** 51 | * Returns the last name of the contact 52 | * @return string 53 | */ 54 | public function getLastName() 55 | { 56 | return $this->data->last_name; 57 | } 58 | 59 | /** 60 | * Returns the user id of the telegram user 61 | * @return int 62 | */ 63 | public function getUserId() 64 | { 65 | return $this->data->user_id; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Document.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:48:06 8 | * $Rev: 549 $ 9 | * $Id: Document.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents an document file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Document extends File 20 | { 21 | 22 | protected $fileType = "document"; 23 | 24 | /** 25 | * The Thumbnail 26 | * @var \Tekook\TelegramLibrary\Types\PhotoSize 27 | */ 28 | protected $thumb = array(); 29 | 30 | public function __construct(\stdClass $data) 31 | { 32 | parent::__construct($data); 33 | 34 | $this->receiveData("thumb", null, "PhotoSize", true); 35 | 36 | 37 | $this->checkData("file_name", false, true); 38 | $this->checkData("mime_type", false, true); 39 | } 40 | 41 | /** 42 | * Returns the thumbnail 43 | * @return \Tekook\TelegramLibrary\Types\PhotoSize 44 | */ 45 | public function getThumb() 46 | { 47 | return $this->thumb; 48 | } 49 | 50 | /** 51 | * Returns the file name 52 | * @return string 53 | */ 54 | public function getFileName() 55 | { 56 | return $this->data->file_name; 57 | } 58 | 59 | /** 60 | * Returns the mime type of the Document 61 | * @return string 62 | */ 63 | public function getMimeType() 64 | { 65 | return $this->data->mime_type; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/File.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:43:52 8 | * $Rev: 549 $ 9 | * $Id: File.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Respresents any file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | abstract class File extends Type implements IFile 20 | { 21 | 22 | /** 23 | * The Type of the file. E.g "audio", "video" ... 24 | * @var string 25 | */ 26 | protected $fileType = null; 27 | 28 | public function __construct(\stdClass $data) 29 | { 30 | parent::__construct($data); 31 | 32 | $this->checkData("file_id", true); 33 | $this->checkData("file_size", false, true); 34 | } 35 | 36 | /** 37 | * Returns the file_id of the File 38 | * @return int 39 | */ 40 | public function getFileId() 41 | { 42 | return $this->data->file_id; 43 | } 44 | 45 | /** 46 | * Returns the file_size of the File 47 | * @return int 48 | */ 49 | public function getFileSize() 50 | { 51 | return $this->data->file_size; 52 | } 53 | 54 | /** 55 | * Returns the file type of the file 56 | * @return string 57 | */ 58 | public function getFileType() 59 | { 60 | return $this->fileType; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/GroupChat.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:40:44 8 | * $Rev: 549 $ 9 | * $Id: GroupChat.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents an GroupChat 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class GroupChat extends Type implements IChat 20 | { 21 | 22 | public function __construct(\stdClass $data) 23 | { 24 | parent::__construct($data); 25 | 26 | $this->checkData("id", true); 27 | $this->checkData("title", true); 28 | } 29 | 30 | /** 31 | * Returns the id of the groupchat 32 | * @return int 33 | */ 34 | public function getId() 35 | { 36 | return $this->data->id; 37 | } 38 | 39 | /** 40 | * Returns the title of the groupchat 41 | * @return string 42 | */ 43 | public function getTitle() 44 | { 45 | return $this->data->title; 46 | } 47 | 48 | /** 49 | * Returns the title of the groupchat 50 | * @return string 51 | */ 52 | public function getName() 53 | { 54 | return $this->getTitle(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/IChat.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 19:40:56 8 | * $Rev: 549 $ 9 | * $Id: IChat.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a chat (user or group chat) 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface IChat 20 | { 21 | 22 | /** 23 | * Returns the chat_id of the User or GroupChat 24 | * @return int 25 | */ 26 | public function getId(); 27 | 28 | /** 29 | * Returns the name of the User or GroupChat 30 | * @return string 31 | */ 32 | public function getName(); 33 | } 34 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/IFile.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 28.06.2015 13:42:49 8 | * $Rev: 549 $ 9 | * $Id: IFile.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents any file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface IFile 20 | { 21 | 22 | /** 23 | * Returns the FileId of the file 24 | * @return int 25 | */ 26 | public function getFileId(); 27 | 28 | /** 29 | * Returns the file type of the file 30 | * @return string 31 | */ 32 | public function getFileType(); 33 | } 34 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/ILocation.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 28.06.2015 22:47:04 8 | * $Rev: 549 $ 9 | * $Id: ILocation.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * represents a location 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface ILocation 20 | { 21 | 22 | /** 23 | * Returns the longitude as defined by sende 24 | * @return float 25 | */ 26 | public function getLongitude(); 27 | 28 | /** 29 | * Returns the latitude as defined by sende 30 | * @return float 31 | */ 32 | public function getLatitude(); 33 | } 34 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/IMessage.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 28.06.2015 23:00:40 8 | * $Rev: 549 $ 9 | * $Id: IMessage.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * represents a message 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface IMessage 20 | { 21 | 22 | /** 23 | * Gets the message_id of the message 24 | * @return int 25 | */ 26 | public function getMessageId(); 27 | 28 | /** 29 | * Returns the id of the chat the message was received in 30 | * @return int 31 | */ 32 | public function getFromChatId(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/IUser.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 28.06.2015 19:08:02 8 | * $Rev: 549 $ 9 | * $Id: IUser.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a user 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | interface IUser 20 | { 21 | 22 | /** 23 | * The ID of the User 24 | * @return int 25 | */ 26 | public function getId(); 27 | 28 | /** 29 | * The first name of the user 30 | * @return string 31 | */ 32 | public function getFirstName(); 33 | } 34 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Location.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:54:12 8 | * $Rev: 549 $ 9 | * $Id: Location.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a location 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Location extends Type implements ILocation 20 | { 21 | 22 | public function __construct(\stdClass $data) 23 | { 24 | parent::__construct($data); 25 | 26 | $this->checkData("longitude", true); 27 | $this->checkData("latitude", true); 28 | } 29 | 30 | /** 31 | * Returns the longitude as defined by sende 32 | * @return float 33 | */ 34 | public function getLongitude() 35 | { 36 | return $this->data->longitude; 37 | } 38 | 39 | /** 40 | * Returns the latitude as defined by sende 41 | * @return float 42 | */ 43 | public function getLatitude() 44 | { 45 | return $this->data->latitude; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Message.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 21:19:01 8 | * $Rev: 552 $ 9 | * $Id: Message.php 552 2015-06-30 17:33:30Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | use Tekook\TelegramLibrary\Events; 15 | 16 | /** 17 | * Represents a message (update->message) 18 | * Contains any data 19 | * 20 | * @author Julian 'Digital' Tekook 21 | */ 22 | class Message extends Type implements IMessage 23 | { 24 | /* 25 | * ********************************* 26 | * Constants 27 | * ********************************* 28 | */ 29 | 30 | /** 31 | * Message is a user message 32 | */ 33 | const SCOPE_USER_MESSAGE = 1; 34 | 35 | /** 36 | * Message is a groupchat message 37 | */ 38 | const SCOPE_GROUP_MESSAGE = 2; 39 | 40 | /** 41 | * Normal Message 42 | */ 43 | const TYPE_NORMAL = 1; 44 | 45 | /** 46 | * Message is a forwared message 47 | */ 48 | const TYPE_FORWARD = 2; 49 | 50 | /** 51 | * Message is a reply to an message 52 | */ 53 | const TYPE_REPLY = 3; 54 | 55 | /* 56 | * ********************************* 57 | * Variables 58 | * ********************************* 59 | */ 60 | 61 | /** 62 | * The scpoe of Message received 63 | * @var int 64 | */ 65 | protected $messageScope; 66 | 67 | /** 68 | * The Type of Message received 69 | * @var int 70 | */ 71 | protected $messageType; 72 | 73 | /** 74 | * The Event of the message received 75 | * @var int 76 | */ 77 | protected $messageEvent; 78 | 79 | /** 80 | * The User-Object the message came from 81 | * @var User 82 | */ 83 | protected $from; 84 | 85 | /** 86 | * The chat the message came from 87 | * User or GroupChat 88 | * @var IChat 89 | */ 90 | protected $chat; 91 | 92 | /** 93 | * Contains the original User which the message got forwared from (if forwarded) 94 | * @var User 95 | */ 96 | protected $forwardFrom = null; 97 | 98 | /** 99 | * Contains the original timestamp of the message which got forwared (if forwarded) 100 | * @var int 101 | */ 102 | protected $forwardDate = null; 103 | 104 | /** 105 | * AudioFile 106 | * @var Audio 107 | */ 108 | protected $audio = null; 109 | 110 | /** 111 | * DocumentFile 112 | * @var Document 113 | */ 114 | protected $document = null; 115 | 116 | /** 117 | * Array of the diffrent Photosizes (if message is a photo) 118 | * @var Array:PhotoSize 119 | */ 120 | protected $photo = array(); 121 | 122 | /** 123 | * StickerFile 124 | * @var Sticker 125 | */ 126 | protected $sticker = null; 127 | 128 | /** 129 | * VideoFile 130 | * @var Video 131 | */ 132 | protected $video = null; 133 | 134 | /** 135 | * ContactFile 136 | * @var Contact 137 | */ 138 | protected $contact = null; 139 | 140 | /** 141 | * Location 142 | * @var Location 143 | */ 144 | protected $location = null; 145 | 146 | /** 147 | * Contains the new User of the GroupChat 148 | * @var User 149 | */ 150 | protected $newChatParticipant = null; 151 | 152 | /** 153 | * Contains the User who left the GroupChat 154 | * @var User 155 | */ 156 | protected $leftChatParticipant = null; 157 | 158 | /** 159 | * Contains the new name of the GroupChat 160 | * @var String 161 | */ 162 | protected $newChatTitle = null; 163 | 164 | /** 165 | * Contains the diffrenz PhotoSizes of the new GroupChat photo 166 | * @var Array:PhotoSize 167 | */ 168 | protected $newChatPhoto = array(); 169 | 170 | /** 171 | * If true, the GroupChat photo has been deleted 172 | * @var boolean 173 | */ 174 | protected $deleteChatPhoto = false; 175 | 176 | /** 177 | * If true, the message contains a GroupChat being created 178 | * @var boolean 179 | */ 180 | protected $groupChatCreated = false; 181 | 182 | /** 183 | * Contains the message object if the message is an reply 184 | * @var \Tekook\TelegramLibrary\Types\Message 185 | */ 186 | protected $replyToMessage = null; 187 | 188 | /* 189 | * ********************************* 190 | * Construct and retrieving 191 | * ********************************* 192 | */ 193 | 194 | public function __construct(\stdClass $data, \Tekook\TelegramLibrary\TelegramBotApi $api) 195 | { 196 | parent::__construct($data, $api); 197 | 198 | $this->messageEvent = \Tekook\TelegramLibrary\Events::TEXT; 199 | $this->messageType = self::TYPE_NORMAL; 200 | 201 | $this->retrieveData(); 202 | } 203 | 204 | /** 205 | * Analyses the data and sets event corrensponding to the data 206 | */ 207 | protected function retrieveData() 208 | { 209 | // FROM 210 | $this->receiveData("from", null, "User", true); 211 | 212 | // CHAT 213 | if (isset($this->data->chat->first_name)) { 214 | $this->chat = new User($this->data->chat, $this->api); 215 | $this->messageScope = self::SCOPE_USER_MESSAGE; 216 | } elseif (isset($this->data->chat->title)) { 217 | $this->chat = new GroupChat($this->data->chat, $this->api); 218 | $this->messageScope = self::SCOPE_GROUP_MESSAGE; 219 | } else { 220 | $this->throwMissingError("chat"); 221 | } 222 | 223 | // FORWARD_FROM 224 | if (isset($this->data->forward_from)) { 225 | $this->forwardFrom = new User($this->data->forward_from, $this->api); 226 | $this->fordwardDate = $this->data->forward_date; 227 | $this->messageType = self::TYPE_FORWARD; 228 | } 229 | 230 | // Audio 231 | $this->receiveData("audio", null, "Audio"); 232 | 233 | // Document 234 | $this->receiveData("document", null, "Document"); 235 | 236 | // photo 237 | if (isset($this->data->photo)) { 238 | $this->messageEvent = Events::PHOTO; 239 | foreach ($this->data->photo as $photo) { 240 | $this->photo[] = new PhotoSize($photo); 241 | } 242 | } 243 | 244 | // Sticker 245 | $this->receiveData("sticker", null, "Sticker"); 246 | 247 | // Video 248 | $this->receiveData("video", null, "Video"); 249 | 250 | // Contact 251 | $this->receiveData("contact", null, "Contact"); 252 | 253 | // Location 254 | $this->receiveData("location", null, "Location"); 255 | 256 | // newChatParticipant 257 | $this->receiveData("new_chat_participant", "newChatParticipant", "User"); 258 | 259 | // leftChatParticipant 260 | $this->receiveData("left_chat_participant", "leftChatParticipant", "User"); 261 | 262 | // newChatTitle 263 | $this->receiveData("new_chat_title", "newChatTitle"); 264 | 265 | // newChatPhoto 266 | if (isset($this->data->new_chat_photo)) { 267 | $this->messageEvent = Events::NEW_CHAT_PHOTO; 268 | foreach ($this->data->new_chat_photo as $photo) { 269 | $this->new_chat_photo[] = new PhotoSize($photo); 270 | } 271 | } 272 | 273 | // deleteChatPhoto 274 | $this->receiveData("delete_chat_photo", "deleteChatPhoto"); 275 | 276 | // groupChatCreated 277 | $this->receiveData("group_chat_created", "groupChatCreated"); 278 | 279 | // Reply Message 280 | $this->receiveData("reply_to_message", "replyToMessage", "Message"); 281 | 282 | if (!is_null($this->replyToMessage)) { 283 | $this->messageType = self::TYPE_REPLY; 284 | } 285 | } 286 | 287 | /* 288 | * ********************************* 289 | * Various Checks 290 | * ********************************* 291 | */ 292 | 293 | /** 294 | * Determinates if the message is received in a GroupChat 295 | * @return boolean 296 | */ 297 | public function isGroupMessage() 298 | { 299 | return $this->messageScope === self::SCOPE_GROUP_MESSAGE; 300 | } 301 | 302 | /** 303 | * Determinates if the message is receiver from a User 304 | * @return type 305 | */ 306 | public function isUserMessage() 307 | { 308 | return $this->messageScope === self::SCOPE_USER_MESSAGE; 309 | } 310 | 311 | /** 312 | * Determinates if the message is a normal message 313 | * @return boolean 314 | */ 315 | public function isNormalMessage() 316 | { 317 | return $this->messageType === self::TYPE_NORMAL; 318 | } 319 | 320 | /** 321 | * Determinates if the message is a reply on another message 322 | * @return boolean 323 | */ 324 | public function isReplyMessage() 325 | { 326 | return $this->messageType === self::TYPE_REPLY; 327 | } 328 | 329 | /** 330 | * Determinates if the message is a forwared message 331 | * @return boolean 332 | */ 333 | public function isForwardMessage() 334 | { 335 | return $this->messageType === self::TYPE_FORWARD; 336 | } 337 | 338 | /** 339 | * Checks if the message is the given $event 340 | * @param int $event One of \Tekook\TelegramLibrary\Events Consts 341 | */ 342 | public function isEvent($event) 343 | { 344 | return $this->messageEvent === $event; 345 | } 346 | 347 | /** 348 | * Checks if the message is a attached file 349 | * @return boolean 350 | */ 351 | public function isFile() 352 | { 353 | return in_array($this->messageEvent, 354 | [ 355 | Events::AUDIO, 356 | Events::DOCUMENT, 357 | Events::PHOTO, 358 | Events::STICKER, 359 | Events::VIDEO, 360 | ]); 361 | } 362 | 363 | /* 364 | * ************************************** 365 | * Getters 366 | * ************************************** 367 | */ 368 | 369 | /** 370 | * Returns the Audio if message was an AudioFile 371 | * @return Audio 372 | */ 373 | public function getAudio() 374 | { 375 | return $this->audio; 376 | } 377 | 378 | /** 379 | * The chat the message came from 380 | * User or GroupChat 381 | * @var IChat 382 | */ 383 | public function getChat() 384 | { 385 | return $this->chat; 386 | } 387 | 388 | /** 389 | * Returns the Contact if message was a Contact 390 | * @return Contact 391 | */ 392 | public function getContact() 393 | { 394 | return $this->contact; 395 | } 396 | 397 | /** 398 | * The timestamp of the message 399 | * @return int 400 | */ 401 | public function getDate() 402 | { 403 | return $this->data->date; 404 | } 405 | 406 | /** 407 | * Returns the Document if message was an Document 408 | * @return Document 409 | */ 410 | public function getDocument() 411 | { 412 | return $this->document; 413 | } 414 | 415 | /** 416 | * Returns the Event ID of the message 417 | * @return int 418 | */ 419 | public function getEvent() 420 | { 421 | return $this->messageEvent; 422 | } 423 | 424 | /** 425 | * Contains the original timestamp of the message which got forwared (if forwarded) 426 | * @return int 427 | */ 428 | public function getForwardDate() 429 | { 430 | return $this->forwardDate; 431 | } 432 | 433 | /** 434 | * Contains the original User which the message got forwared from (if forwarded) 435 | * @return User 436 | */ 437 | public function getForwardFrom() 438 | { 439 | return $this->forwardFrom; 440 | } 441 | 442 | /** 443 | * The User-Object the message came from 444 | * @return User 445 | */ 446 | public function getFrom() 447 | { 448 | return $this->from; 449 | } 450 | 451 | /** 452 | * Returns the id of the chat the message was received in 453 | * @return int 454 | */ 455 | public function getFromChatId() 456 | { 457 | return $this->chat->getId(); 458 | } 459 | 460 | /** 461 | * Returns the left User of the GroupChat 462 | * @return User 463 | */ 464 | public function getLeftChatParticipan() 465 | { 466 | return $this->leftChatParticipant; 467 | } 468 | 469 | /** 470 | * Returns the send location 471 | * @return Location 472 | */ 473 | public function getLocation() 474 | { 475 | return $this->location; 476 | } 477 | 478 | /** 479 | * Gets the message_id of the message 480 | * @return int 481 | */ 482 | public function getMessageId() 483 | { 484 | return $this->data->message_id; 485 | } 486 | 487 | /** 488 | * Returns the new User of the GroupChat 489 | * @return User 490 | */ 491 | public function getNewChatParticipan() 492 | { 493 | return $this->newChatParticipant; 494 | } 495 | 496 | /** 497 | * Returns an array of PhotoSizes if a new GroupChat Photo has been set 498 | * @return array:PhotoSize 499 | */ 500 | public function getNewChatPhoto() 501 | { 502 | return $this->newChatPhoto; 503 | } 504 | 505 | /** 506 | * Returns an array of PhotoSizes if the message was a photo 507 | * @return array:PhotoSizes 508 | */ 509 | public function getPhoto() 510 | { 511 | return $this->photo; 512 | } 513 | 514 | /** 515 | * Returns the StickerFile if message was a sticker 516 | * @return Sticker 517 | */ 518 | public function getSticker() 519 | { 520 | return $this->sticker; 521 | } 522 | 523 | /** 524 | * Gets the text of the message 525 | * @return string 526 | */ 527 | public function getText() 528 | { 529 | return $this->data->text; 530 | } 531 | 532 | /** 533 | * Returns the VideoFile if message was a video 534 | * @return Video 535 | */ 536 | public function getVideo() 537 | { 538 | return $this->video; 539 | } 540 | 541 | /** 542 | * Returns the IFile 543 | * @return \Tekook\TelegramLibrary\Types\IFile 544 | */ 545 | public function getFile() 546 | { 547 | switch ($this->messageEvent) { 548 | case Events::AUDIO: 549 | return $this->getAudio(); 550 | case Events::VIDEO: 551 | return $this->getVideo(); 552 | case Events::DOCUMENT: 553 | return $this->getDocument(); 554 | case Events::STICKER: 555 | return $this->getSticker(); 556 | case Events::PHOTO: 557 | return $this->getPhoto()[count($this->getPhoto()) - 1]; 558 | } 559 | return null; 560 | } 561 | 562 | /* 563 | * ********************************* 564 | * Event Assignment 565 | * ********************************* 566 | */ 567 | 568 | /** 569 | * Override the receiveData of Type to make the event assignment 570 | * @param string $key 571 | * @param string $iKey 572 | * @param string $class 573 | * @param boolean $mandatory 574 | */ 575 | protected function receiveData($key, $iKey = null, $class = null, $mandatory = false) 576 | { 577 | if (parent::receiveData($key, $iKey, $class, $mandatory)) { 578 | $event = strtoupper($key); 579 | if (defined("\Tekook\TelegramLibrary\Events::" . $event)) { 580 | $this->messageEvent = constant("\Tekook\TelegramLibrary\Events::{$event}"); 581 | } 582 | } 583 | } 584 | 585 | /* 586 | * ********************************* 587 | * REPLY OPTIONS 588 | * ********************************* 589 | */ 590 | 591 | /** 592 | * Replies to the message with the given text 593 | * @param string $text The reply text 594 | * @param array $options Optional options 595 | * @return \stdClass 596 | */ 597 | public function reply($text, array $options = array()) 598 | { 599 | $myOptions = array_merge($options, [ 600 | "reply_to_message_id" => $this->getMessageId() 601 | ]); 602 | return $this->api->sendMessage($this->getChat(), $text, $myOptions); 603 | } 604 | 605 | /** 606 | * Replies to the message with a given file 607 | * @param \Tekook\TelegramLibrary\Types\IFile $file The file to send 608 | * @param array $options Optional options 609 | * @return \stdClass 610 | */ 611 | public function replyFile(\Tekook\TelegramLibrary\Types\IFile $file, array $options = array()) 612 | { 613 | $myOptions = array_merge($options, [ 614 | "reply_to_message_id" => $this->getMessageId() 615 | ]); 616 | return $this->api->sendFile($this->getChat(), $file, $myOptions); 617 | } 618 | 619 | /** 620 | * Uploads a new file to the chat of the mssage from a file which lays in the filesystem 621 | * @param string $fileType filetype to send. E.g. audio, video, photo, etc... 622 | * @param string $fileName the ABSOLUTE File Path to the file 623 | * @param array $options Optional options 624 | * @return \stdClass 625 | */ 626 | public function replyUploadFile($fileType, $fileName, array $options = array()) 627 | { 628 | return $this->api->uploadFile($this->getChat(), $fileType, $fileName, $options); 629 | } 630 | 631 | /** 632 | * Replies to the message with a given location 633 | * @param \Tekook\TelegramLibrary\Types\ILocation $location The location to send 634 | * @param array $options Optional options 635 | * @return \stdClass 636 | */ 637 | public function replyLocation(\Tekook\TelegramLibrary\Types\ILocation $location, array $options = array()) 638 | { 639 | $myOptions = array_merge($options, [ 640 | "reply_to_message_id" => $this->getMessageId() 641 | ]); 642 | return $this->api->sendLocation($this->getChat(), $location, $myOptions); 643 | } 644 | 645 | /** 646 | * Forwards the message to a given $target 647 | * @param \Tekook\TelegramLibrary\Types\IChat $target The chat to forward the message to 648 | * @return \stdClass 649 | */ 650 | public function forward(\Tekook\TelegramLibrary\Types\IChat $target) 651 | { 652 | return $this->api->forwardMessage($target, $this); 653 | } 654 | 655 | } 656 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/PhotoSize.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:44:51 8 | * $Rev: 549 $ 9 | * $Id: PhotoSize.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a photo file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class PhotoSize extends File 20 | { 21 | 22 | protected $fileType = "photo"; 23 | 24 | public function __construct(\stdClass $data) 25 | { 26 | parent::__construct($data); 27 | 28 | $this->checkData("width", true); 29 | $this->checkData("height", true); 30 | } 31 | 32 | /** 33 | * Returns the width of the photo 34 | * @return int 35 | */ 36 | public function getWidth() 37 | { 38 | return $this->data->width; 39 | } 40 | 41 | /** 42 | * Returns the height of the photo 43 | * @return int 44 | */ 45 | public function getHeight() 46 | { 47 | return $this->data->height; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Sticker.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:48:53 8 | * $Rev: 549 $ 9 | * $Id: Sticker.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * represents a sticker file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Sticker extends PhotoSize 20 | { 21 | 22 | protected $fileType = "sticker"; 23 | 24 | /** 25 | * The Thumbnail 26 | * @var \Tekook\TelegramLibrary\Types\PhotoSize 27 | */ 28 | protected $thumb; 29 | 30 | public function __construct(\stdClass $data) 31 | { 32 | parent::__construct($data); 33 | 34 | $this->receiveData("thumb", null, "PhotoSize", true); 35 | } 36 | 37 | /** 38 | * Returns the thumbnail 39 | * @return \Tekook\TelegramLibrary\Types\PhotoSize 40 | */ 41 | public function getThumb() 42 | { 43 | return $this->thumb; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Type.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 18:37:53 8 | * $Rev: 549 $ 9 | * $Id: Type.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Base class for any Type 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | abstract class Type 20 | { 21 | 22 | /** 23 | * Die Data des JSON-Obj 24 | * @var \stdClass 25 | */ 26 | protected $data = null; 27 | 28 | /** 29 | * The api the type belongs to 30 | * @var \Tekook\TelegramLibrary\TelegramBotApi 31 | */ 32 | protected $api = null; 33 | 34 | public function __construct(\stdClass $data, \Tekook\TelegramLibrary\TelegramBotApi $api = null) 35 | { 36 | $this->data = $data; 37 | $this->api = $api; 38 | } 39 | 40 | /** 41 | * Prüft die angegeben Key ob dieser existiert, wirf je nach Parameter eine Exception oder setzt den Parameter auf null 42 | * @param string $key Der zuprüfende Key 43 | * @param boolean $mandatory Gibt an, ob eine Exception ausgeworfen wird 44 | * @param boolean $setNull Gibt an, ob der Data-Key auf NULL gesetzt werden soll 45 | * @return boolean 46 | * @throws \Tekook\TelegramLibrary\Exceptions\MissingKeyException 47 | */ 48 | protected function checkData($key, $mandatory = false, $setNull = false) 49 | { 50 | if (isset($this->data->{$key})) { 51 | return true; 52 | } elseif ($mandatory) { 53 | $this->throwMissingError($key); 54 | } elseif ($setNull) { 55 | $this->data->{$key} = null; 56 | } 57 | return false; 58 | } 59 | 60 | /** 61 | * Prüft den Key und erstellt das entsprechende Object 62 | * @param string $key Der Key in $this->data 63 | * @param string $iKey Der Key in $this (wenn null wird $key benutzt) 64 | * @param string $class Die Klasse die erstellt werden soll (wenn null wird KEINE Klasse erstellt sondern die RAWDATEN genommen) 65 | * @param boolean $mandatory Defindes if the key is mandatory 66 | * @return boolean 67 | * @throws \Tekook\TelegramLibrary\Exceptions\MissingKeyException 68 | */ 69 | protected function receiveData($key, $iKey = null, $class = null, $mandatory = false) 70 | { 71 | $class = "\\Tekook\\TelegramLibrary\\Types\\" . $class; 72 | if (is_null($iKey)) { 73 | $iKey = $key; 74 | } 75 | if ($this->checkData($key, $mandatory)) { 76 | if (is_null($class)) { 77 | $this->{$iKey} = $this->data->{$key}; 78 | } else { 79 | $this->{$iKey} = new $class($this->data->{$key}, $this->api); 80 | } 81 | return true; 82 | } else { 83 | return false; 84 | } 85 | } 86 | 87 | /** 88 | * Throws a MissingKeyException if needed 89 | * @param string $key 90 | * @throws \Tekook\TelegramLibrary\Exceptions\MissingKeyException 91 | */ 92 | protected function throwMissingError($key) 93 | { 94 | throw new \Tekook\TelegramLibrary\Exceptions\MissingKeyException("key: $key is missing in data!"); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Update.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: DJ-Digital.Net 6 | * @copyright: 2015 7 | * @created: 29.06.2015 11:12:40 8 | * $Rev: 549 $ 9 | * $Id: Update.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a update 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Update extends Type 20 | { 21 | 22 | /** 23 | * The id of the update 24 | * @var int 25 | */ 26 | protected $id; 27 | 28 | /** 29 | * The message the update contains 30 | * @var \Tekook\TelegramLibrary\Types\Message 31 | */ 32 | protected $message; 33 | 34 | public function __construct(\stdClass $data, \Tekook\TelegramLibrary\TelegramBotApi $api) 35 | { 36 | parent::__construct($data, $api); 37 | 38 | $this->checkData("message", true); 39 | $this->message = new \Tekook\TelegramLibrary\Types\Message($data->message, $api); 40 | } 41 | 42 | /** 43 | * Returns the ID of the Update 44 | * @return int 45 | */ 46 | public function getId() 47 | { 48 | return $this->id; 49 | } 50 | 51 | /** 52 | * Returns the Message object of the update 53 | * @return \Tekook\TelegramLibrary\Types\Message 54 | */ 55 | public function getMessage() 56 | { 57 | return $this->message; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/User.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 18:35:24 8 | * $Rev: 549 $ 9 | * $Id: User.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a user 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class User extends Type implements IChat, IUser { 20 | 21 | 22 | 23 | public function __construct(\stdClass $data, \Tekook\TelegramLibrary\TelegramBotApi $api) { 24 | parent::__construct($data, $api); 25 | 26 | $this->checkData("id", true); 27 | $this->checkData("first_name", true); 28 | $this->checkData("last_name", false, true); 29 | $this->checkData("username", false, true); 30 | } 31 | 32 | /** 33 | * Returns the user_id of the user 34 | * @return int 35 | */ 36 | public function getId() { 37 | return $this->data->id; 38 | } 39 | 40 | /** 41 | * Returns the first name of the user 42 | * @return string 43 | */ 44 | public function getFirstName() { 45 | return $this->data->first_name; 46 | } 47 | 48 | /** 49 | * Returns the last name of the user 50 | * @return string 51 | */ 52 | public function getLastName() { 53 | return $this->data->last_name; 54 | } 55 | 56 | /** 57 | * Returns the user name of the user 58 | * @return string 59 | */ 60 | public function getUserName() { 61 | return $this->data->username; 62 | } 63 | 64 | /** 65 | * Returns the first name of the User 66 | * @return string 67 | */ 68 | public function getName() { 69 | return $this->getFirstName(); 70 | } 71 | 72 | /** 73 | * Returns the ProfilePhotos of the User 74 | * @param int $offset Optional offset 75 | * @param int $limit Optional limit 76 | * @return \Tekook\TelegramLibrary\Types\UserProfilePhotos 77 | */ 78 | public function getProfilePhotos($offset = 0, $limit = 100) { 79 | return $this->api->getUserProfilePhotos($this, $offset, $limit); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/UserProfilePhotos.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:59:43 8 | * $Rev: 549 $ 9 | * $Id: UserProfilePhotos.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents the profile photos of a given user 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class UserProfilePhotos extends Type 20 | { 21 | 22 | protected $photos = array(); 23 | 24 | public function __construct(\stdClass $data) 25 | { 26 | parent::__construct($data); 27 | 28 | $this->checkData("total_count", true); 29 | $this->checkData("photos", true); 30 | 31 | foreach ($data->photos as $key => $photos) { 32 | $this->photos[$key] = array(); 33 | foreach ($photos as $photo) { 34 | $this->photos[$key][] = new PhotoSize($photo); 35 | } 36 | } 37 | } 38 | 39 | /** 40 | * Gets the total number of profile photos 41 | * @return int 42 | */ 43 | public function getTotalCount() 44 | { 45 | return $this->data->total_count; 46 | } 47 | 48 | /** 49 | * Return the Array of user Photos each containing an array of PhotoSizes 50 | * @return array:array:PhotoSize 51 | */ 52 | public function getPhotos() 53 | { 54 | return $this->photos; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Tekook/TelegramLibrary/Types/Video.php: -------------------------------------------------------------------------------- 1 | 5 | * @company: NetJumpers.EU 6 | * @copyright: 2015 7 | * @created: 26.06.2015 20:50:42 8 | * $Rev: 549 $ 9 | * $Id: Video.php 549 2015-06-29 19:19:59Z julian $ 10 | */ 11 | 12 | namespace Tekook\TelegramLibrary\Types; 13 | 14 | /** 15 | * Represents a video file 16 | * 17 | * @author Julian 'Digital' Tekook 18 | */ 19 | class Video extends Sticker 20 | { 21 | 22 | protected $fileType = "video"; 23 | 24 | public function __construct(\stdClass $data) 25 | { 26 | parent::__construct($data); 27 | 28 | $this->checkData("duration", true); 29 | $this->checkData("mime_type", false, true); 30 | $this->checkData("caption", false, true); 31 | } 32 | 33 | /** 34 | * Returns the duration of the video 35 | * @return int 36 | */ 37 | public function getDuration() 38 | { 39 | return $this->data->duration; 40 | } 41 | 42 | /** 43 | * Returns the mime type of the Video 44 | * @return string 45 | */ 46 | public function getMimeType() 47 | { 48 | return $this->data->mime_type; 49 | } 50 | 51 | /** 52 | * Returns the caption of the video 53 | * @return string 54 | */ 55 | public function getCaption() 56 | { 57 | return $this->data->caption; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tekook/telegramlibrary", 3 | "description": "PHP Library for the new Telegram Bot API", 4 | "keywords": [ 5 | "telegram", 6 | "bot", 7 | "new api", 8 | "api", 9 | "library" 10 | ], 11 | "license": "MIT", 12 | "homepage": "https://github.com/tekook/TelegramLibrary", 13 | "authors": [ 14 | { 15 | "name": "Julian Tekook", 16 | "email": "info@tjsrv.de", 17 | "role": "Developer" 18 | } 19 | ], 20 | "require": { 21 | "php": ">=5.4.0" 22 | } 23 | } 24 | --------------------------------------------------------------------------------