Esempio n. 1
0
 /**
  * @param                                                       $text
  * @param ReplyKeyboardMarkup|ReplyKeyboardHide|ForceReply|null $reply_markup
  * @param null                                                  $reply_to_message_id
  * @param bool|false                                            $disable_web_page_preview
  *
  * @return mixed
  */
 protected function sendMessage($text, $reply_markup = null, $reply_to_message_id = null, $disable_web_page_preview = true)
 {
     try {
         $result = $this->telegram->sendMessage($this->context->user, $text, $reply_markup, $reply_to_message_id, $disable_web_page_preview);
         $this->context->lastMessage = func_get_args();
         return $result;
     } catch (ClientException $e) {
         $response_obj = json_decode($e->getResponse()->getBody());
         if (429 === $e->getResponse()->getStatusCode()) {
             sleep(5);
             return $this->sendMessage($text, $reply_markup, $reply_to_message_id, $disable_web_page_preview);
         } elseif ($response_obj && 'Error: PEER_ID_INVALID' === $response_obj->description) {
             Log::warning('Error on sendMessage: ' . json_encode($response_obj));
         } else {
             throw $e;
         }
     }
     return null;
 }
Esempio n. 2
0
 /**
  * @throws \GuzzleHttp\Exception\ClientException
  */
 public function testSendMessage_InlineKeyboard()
 {
     $this->telegram->sendMessage($this->user, 'inline keyboard', new InlineKeyboard(['inline_keyboard' => [[new InlineButton(['text' => 'url', 'url' => 'https://google.com/']), new InlineButton(['text' => 'callback_data', 'callback_data' => 'foo'])], [new InlineButton(['text' => 'switch_inline_query', 'switch_inline_query' => 'switch_inline_query text'])]]]));
 }