Skip to content

Commit

Permalink
Merge pull request #214 from Eleirbag89/analysis-lKYMmr
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
Eleirbag89 committed Jun 24, 2020
2 parents 1a3956b + 2ceaf20 commit d5464bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
26 changes: 14 additions & 12 deletions Telegram.php
Expand Up @@ -106,7 +106,7 @@ public function __construct($bot_token, $log_errors = true, array $proxy = [])
*/
public function endpoint($api, array $content, $post = true)
{
$url = 'https://api.telegram.org/bot' . $this->bot_token . '/' . $api;
$url = 'https://api.telegram.org/bot'.$this->bot_token.'/'.$api;
if ($post) {
$reply = $this->sendAPIRequest($url, $content);
} else {
Expand Down Expand Up @@ -1684,7 +1684,7 @@ public function editMessageReplyMarkup(array $content)
*/
public function downloadFile($telegram_file_path, $local_file_path)
{
$file_url = 'https://api.telegram.org/file/bot' . $this->bot_token . '/' . $telegram_file_path;
$file_url = 'https://api.telegram.org/file/bot'.$this->bot_token.'/'.$telegram_file_path;
$in = fopen($file_url, 'rb');
$out = fopen($local_file_path, 'wb');

Expand Down Expand Up @@ -1776,6 +1776,7 @@ public function Caption()
if ($type == self::CHANNEL_POST) {
return @$this->data['channel_post']['caption'];
}

return @$this->data['message']['caption'];
}

Expand Down Expand Up @@ -2041,6 +2042,7 @@ public function messageFromGroupTitle()
if ($this->data['message']['chat']['type'] != 'private') {
return $this->data['message']['chat']['title'];
}

return '';
}

Expand All @@ -2056,10 +2058,10 @@ public function messageFromGroupTitle()
public function buildKeyBoard(array $options, $onetime = false, $resize = false, $selective = true)
{
$replyMarkup = [
'keyboard' => $options,
'keyboard' => $options,
'one_time_keyboard' => $onetime,
'resize_keyboard' => $resize,
'selective' => $selective,
'resize_keyboard' => $resize,
'selective' => $selective,
];
$encodedMarkup = json_encode($replyMarkup, true);

Expand Down Expand Up @@ -2134,8 +2136,8 @@ public function buildInlineKeyboardButton(
public function buildKeyboardButton($text, $request_contact = false, $request_location = false)
{
$replyMarkup = [
'text' => $text,
'request_contact' => $request_contact,
'text' => $text,
'request_contact' => $request_contact,
'request_location' => $request_location,
];

Expand All @@ -2152,7 +2154,7 @@ public function buildKeyBoardHide($selective = true)
{
$replyMarkup = [
'remove_keyboard' => true,
'selective' => $selective,
'selective' => $selective,
];
$encodedMarkup = json_encode($replyMarkup, true);

Expand All @@ -2168,7 +2170,7 @@ public function buildForceReply($selective = true)
{
$replyMarkup = [
'force_reply' => true,
'selective' => $selective,
'selective' => $selective,
];
$encodedMarkup = json_encode($replyMarkup, true);

Expand Down Expand Up @@ -3169,7 +3171,7 @@ public function getUpdateType()
private function sendAPIRequest($url, array $content, $post = true)
{
if (isset($content['chat_id'])) {
$url = $url . '?chat_id=' . $content['chat_id'];
$url = $url.'?chat_id='.$content['chat_id'];
unset($content['chat_id']);
}
$ch = curl_init();
Expand Down Expand Up @@ -3225,7 +3227,7 @@ private function sendAPIRequest($url, array $content, $post = true)
function curl_file_create($filename, $mimetype = '', $postname = '')
{
return "@$filename;filename="
. ($postname ?: basename($filename))
. ($mimetype ? ";type=$mimetype" : '');
.($postname ?: basename($filename))
.($mimetype ? ";type=$mimetype" : '');
}
}
1 change: 0 additions & 1 deletion TelegramErrorLogger.php
@@ -1,6 +1,5 @@
<?php


/**
* Telegram Error Logger Class.
*
Expand Down
6 changes: 3 additions & 3 deletions bot examples/webhook/update.php
Expand Up @@ -85,11 +85,11 @@
} elseif ($text == '/inlinekeyboard') {
// Shows the Inline Keyboard and Trigger a callback on a button press
$option = [
[
[
$telegram->buildInlineKeyBoardButton('Callback 1', $url = '', $callback_data = '1'),
$telegram->buildInlineKeyBoardButton('Callback 2', $url = '', $callback_data = '2'),
],
];
],
];

$keyb = $telegram->buildInlineKeyBoard($option);
$content = ['chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => 'This is an InlineKeyboard Test with Callbacks'];
Expand Down

0 comments on commit d5464bc

Please sign in to comment.