Skip to content

Commit d11cf3a

Browse files
authored
Actualize to 7.4 (#474)
* Actualized Types: Chat User Added missed Types: ArrayOfReactionType MessageOriginChannel ReactionType ReactionTypeCustomEmoji ReactionTypeEmoji Added some tests * Actualized Types * Actualized Types * Actualized Types * Actualized Types * rm tracker * rm tracker * upd Chat classes * php cs-fixer * upd MessageOriginChannel * fix BotApiTest * added types to User
1 parent fcc0241 commit d11cf3a

File tree

140 files changed

+13145
-2431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+13145
-2431
lines changed

.github/workflows/tests.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ jobs:
1313
os:
1414
- ubuntu-latest
1515
php:
16-
- "5.5"
17-
- "5.6"
18-
- "7.0"
19-
- "7.1"
20-
- "7.2"
21-
- "7.3"
22-
- "7.4"
23-
- "8.0"
2416
- "8.1"
2517
- "8.2"
2618
steps:

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php" : ">=5.5.0",
21+
"php" : ">=8.1",
2222
"ext-curl": "*",
2323
"ext-json": "*"
2424
},

psalm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="2"
4-
phpVersion="5.5"
4+
phpVersion="8.1"
55
findUnusedBaselineEntry="false"
66
findUnusedCode="false"
77
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

src/BotApi.php

+1-81
Original file line numberDiff line numberDiff line change
@@ -167,42 +167,18 @@ class BotApi
167167
*/
168168
private $fileEndpoint;
169169

170-
/**
171-
* @deprecated
172-
*
173-
* Botan tracker
174-
*
175-
* @var Botan|null
176-
*/
177-
protected $tracker;
178-
179-
/**
180-
* @deprecated
181-
*
182-
* list of event ids
183-
*
184-
* @var array
185-
*/
186-
protected $trackedEvents = [];
187-
188170
/**
189171
* @param string $token Telegram Bot API token
190-
* @param string|null $trackerToken Yandex AppMetrica application api_key
191172
* @param HttpClientInterface|null $httpClient
192173
* @param string|null $endpoint
193174
*/
194-
public function __construct($token, $trackerToken = null, HttpClientInterface $httpClient = null, $endpoint = null)
175+
public function __construct($token, HttpClientInterface $httpClient = null, $endpoint = null)
195176
{
196177
$this->token = $token;
197178
$this->endpoint = ($endpoint ?: self::URL_PREFIX) . $token;
198179
$this->fileEndpoint = $endpoint ? null : (self::FILE_URL_PREFIX . $token);
199180

200181
$this->httpClient = $httpClient ?: new CurlHttpClient();
201-
202-
if ($trackerToken) {
203-
@trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED);
204-
$this->tracker = new Botan($trackerToken);
205-
}
206182
}
207183

208184
/**
@@ -643,12 +619,6 @@ public function getUpdates($offset = 0, $limit = 100, $timeout = 0)
643619
'timeout' => $timeout,
644620
]));
645621

646-
if ($this->tracker instanceof Botan) {
647-
foreach ($updates as $update) {
648-
$this->trackUpdate($update);
649-
}
650-
}
651-
652622
return $updates;
653623
}
654624

@@ -1804,56 +1774,6 @@ public function deleteMessage($chatId, $messageId)
18041774
]);
18051775
}
18061776

1807-
/**
1808-
* @deprecated
1809-
*
1810-
* @param Update $update
1811-
* @param string $eventName
1812-
*
1813-
* @throws Exception
1814-
*
1815-
* @return void
1816-
*/
1817-
public function trackUpdate(Update $update, $eventName = 'Message')
1818-
{
1819-
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED);
1820-
1821-
if (!in_array($update->getUpdateId(), $this->trackedEvents)) {
1822-
$message = $update->getMessage();
1823-
if (!$message) {
1824-
return;
1825-
}
1826-
$this->trackedEvents[] = $update->getUpdateId();
1827-
1828-
$this->track($message, $eventName);
1829-
1830-
if (count($this->trackedEvents) > self::MAX_TRACKED_EVENTS) {
1831-
$this->trackedEvents = array_slice($this->trackedEvents, (int) round(self::MAX_TRACKED_EVENTS / 4));
1832-
}
1833-
}
1834-
}
1835-
1836-
/**
1837-
* @deprecated
1838-
*
1839-
* Wrapper for tracker
1840-
*
1841-
* @param Message $message
1842-
* @param string $eventName
1843-
*
1844-
* @throws Exception
1845-
*
1846-
* @return void
1847-
*/
1848-
public function track(Message $message, $eventName = 'Message')
1849-
{
1850-
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED);
1851-
1852-
if ($this->tracker instanceof Botan) {
1853-
$this->tracker->track($message, $eventName);
1854-
}
1855-
}
1856-
18571777
/**
18581778
* Use this method to send invoices. On success, the sent Message is returned.
18591779
*

src/Botan.php

-95
This file was deleted.

src/Client.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ class Client
4040
* Client constructor
4141
*
4242
* @param string $token Telegram Bot API token
43-
* @param string|null $trackerToken Yandex AppMetrica application api_key
4443
* @param HttpClientInterface|null $httpClient
4544
* @param string|null $endpoint
4645
*/
47-
public function __construct($token, $trackerToken = null, HttpClientInterface $httpClient = null, $endpoint = null)
46+
public function __construct($token, HttpClientInterface $httpClient = null, $endpoint = null)
4847
{
49-
if ($trackerToken) {
50-
@trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED);
51-
}
52-
$this->api = new BotApi($token, $trackerToken, $httpClient, $endpoint);
53-
$this->events = new EventCollection($trackerToken);
48+
$this->api = new BotApi($token, $httpClient, $endpoint);
49+
$this->events = new EventCollection();
5450
}
5551

5652
/**

src/Events/EventCollection.php

+1-28
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace TelegramBot\Api\Events;
44

55
use Closure;
6-
use ReflectionFunction;
7-
use TelegramBot\Api\Botan;
86
use TelegramBot\Api\Types\Update;
97

108
class EventCollection
@@ -14,28 +12,7 @@ class EventCollection
1412
*
1513
* @var array
1614
*/
17-
protected $events;
18-
19-
/**
20-
* Botan tracker
21-
*
22-
* @var \TelegramBot\Api\Botan|null
23-
*/
24-
protected $tracker;
25-
26-
/**
27-
* EventCollection constructor.
28-
*
29-
* @param string $trackerToken
30-
*/
31-
public function __construct($trackerToken = null)
32-
{
33-
$this->events = [];
34-
if ($trackerToken) {
35-
@trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED);
36-
$this->tracker = new Botan($trackerToken);
37-
}
38-
}
15+
protected $events = [];
3916

4017
/**
4118
* Add new event to collection
@@ -62,10 +39,6 @@ public function handle(Update $update)
6239
/* @var \TelegramBot\Api\Events\Event $event */
6340
if ($event->executeChecker($update) === true) {
6441
if ($event->executeAction($update) === false) {
65-
if ($this->tracker && ($message = $update->getMessage())) {
66-
$checker = new ReflectionFunction($event->getChecker());
67-
$this->tracker->track($message, $checker->getStaticVariables()['name']);
68-
}
6942
break;
7043
}
7144
}

0 commit comments

Comments
 (0)