Inheritance: extends TelegramBot\Api\BaseType, implements TelegramBot\Api\TypeInterface
示例#1
0
文件: Botan.php 项目: zzbomb/Api
 /**
  * Event tracking
  *
  * @param \TelegramBot\Api\Types\Message $message
  * @param string $eventName
  *
  * @throws \TelegramBot\Api\Exception
  * @throws \TelegramBot\Api\HttpException
  */
 public function track(Message $message, $eventName = 'Message')
 {
     $uid = $message->getFrom()->getId();
     $options = [CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_POSTFIELDS => $message->toJson()];
     curl_setopt_array($this->curl, $options);
     $result = BotApi::jsonValidate(curl_exec($this->curl), true);
     BotApi::curlValidate($this->curl);
     if ($result['status'] !== 'accepted') {
         throw new Exception('Error Processing Request');
     }
 }
示例#2
0
文件: BotApi.php 项目: baravak/Api
 /**
  * Use this method to send general files. On success, the sent Message is returned.
  * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
  *
  * @param int $chatId
  * @param \CURLFile|string $document
  * @param int|null $replyToMessageId
  * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup
  *
  * @return \TelegramBot\Api\Types\Message
  * @throws \TelegramBot\Api\InvalidArgumentException
  * @throws \TelegramBot\Api\Exception
  */
 public function sendDocument($chatId, $document, $replyToMessageId = null, $replyMarkup = null)
 {
     return Message::fromResponse($this->call('sendDocument', ['chat_id' => (int) $chatId, 'document' => $document, 'reply_to_message_id' => $replyToMessageId, 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson()]));
 }
示例#3
0
 /**
  * Use this method to edit only the reply markup of messages sent by the bot or via the bot
  *
  * @param int|string $chatId
  * @param int $messageId
  * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup
  *
  * @return \TelegramBot\Api\Types\Message
  * @throws \TelegramBot\Api\InvalidArgumentException
  * @throws \TelegramBot\Api\Exception
  */
 public function editMessageReplyMarkup($chatId, $messageId, $replyMarkup = null)
 {
     return Message::fromResponse($this->call('editMessageText', ['chat_id' => $chatId, 'message_id' => $messageId, 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson()]));
 }