Skip to content

Commit 38c1891

Browse files
authored
added ANIMATION type const and fixed some bugs
In getUpdateType method, if a user sends his/her location or contact, the "message" type will return. As a result, for fixing this issue, we should change priority and push location and contact condition upper than "reply". It's same for "animation" and "document" type, because in receiving json from server animation data is upper than document
1 parent d9f896e commit 38c1891

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

Telegram.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class Telegram
6363
* Constant for type Channel Post.
6464
*/
6565
const CHANNEL_POST = 'channel_post';
66+
/**
67+
* Constant for type animation.
68+
*/
69+
const ANIMATION = 'animation'
6670

6771
private $bot_token = '';
6872
private $data = [];
@@ -3014,9 +3018,6 @@ public function getUpdateType()
30143018
if (isset($update['edited_message'])) {
30153019
return self::EDITED_MESSAGE;
30163020
}
3017-
if (isset($update['message']['reply_to_message'])) {
3018-
return self::REPLY;
3019-
}
30203021
if (isset($update['message']['text'])) {
30213022
return self::MESSAGE;
30223023
}
@@ -3035,12 +3036,18 @@ public function getUpdateType()
30353036
if (isset($update['message']['contact'])) {
30363037
return self::CONTACT;
30373038
}
3038-
if (isset($update['message']['document'])) {
3039-
return self::DOCUMENT;
3040-
}
30413039
if (isset($update['message']['location'])) {
30423040
return self::LOCATION;
30433041
}
3042+
if (isset($update['message']['reply_to_message'])) {
3043+
return self::REPLY;
3044+
}
3045+
if (isset($update['message']['animation'])) {
3046+
return self::ANIMATION;
3047+
}
3048+
if (isset($update['message']['document'])) {
3049+
return self::DOCUMENT;
3050+
}
30443051
if (isset($update['channel_post'])) {
30453052
return self::CHANNEL_POST;
30463053
}
@@ -3062,9 +3069,9 @@ private function sendAPIRequest($url, array $content, $post = true)
30623069
curl_setopt($ch, CURLOPT_POST, 1);
30633070
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
30643071
}
3065-
echo "inside curl if";
3072+
// echo "inside curl if";
30663073
if (!empty($this->proxy)) {
3067-
echo "inside proxy if";
3074+
// echo "inside proxy if";
30683075
if (array_key_exists("type", $this->proxy)) {
30693076
curl_setopt($ch, CURLOPT_PROXYTYPE, $this->proxy["type"]);
30703077
}
@@ -3074,12 +3081,12 @@ private function sendAPIRequest($url, array $content, $post = true)
30743081
}
30753082

30763083
if (array_key_exists("url", $this->proxy)) {
3077-
echo "Proxy Url";
3084+
// echo "Proxy Url";
30783085
curl_setopt($ch, CURLOPT_PROXY, $this->proxy["url"]);
30793086
}
30803087

30813088
if (array_key_exists("port", $this->proxy)) {
3082-
echo "Proxy port";
3089+
// echo "Proxy port";
30833090
curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy["port"]);
30843091
}
30853092

0 commit comments

Comments
 (0)