Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Telegram Bot API for PHP Change Log

## 0.9.4 under development
## 0.10.0 under development

- Chg #172: Rename package from `vjik/telegram-bot-api` to `phptg/bot-api` and change namespace
`Vjik\TelegramBot\Api` to `Phptg\BotApi` (@vjik)
- Enh #170: Improve `CurlTransport` performance by sharing data between cURL handles (@vjik)

## 0.9.3 October 22, 2025
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Telegram Bot API for PHP

[![Latest Stable Version](https://poser.pugx.org/vjik/telegram-bot-api/v)](https://packagist.org/packages/vjik/telegram-bot-api)
[![Total Downloads](https://poser.pugx.org/vjik/telegram-bot-api/downloads)](https://packagist.org/packages/vjik/telegram-bot-api)
[![Build status](https://github.com/vjik/telegram-bot-api/actions/workflows/build.yml/badge.svg)](https://github.com/vjik/telegram-bot-api/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/vjik/telegram-bot-api/badge.svg)](https://coveralls.io/github/vjik/telegram-bot-api)
[![Mutation score](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fvjik%2Ftelegram-bot-api%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/vjik/telegram-bot-api/master)
[![Static analysis](https://github.com/vjik/telegram-bot-api/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/vjik/telegram-bot-api/actions/workflows/static.yml?query=branch%3Amaster)
[![Latest Stable Version](https://poser.pugx.org/phptg/bot-api/v)](https://packagist.org/packages/phptg/bot-api)
[![Total Downloads](https://poser.pugx.org/phptg/bot-api/downloads)](https://packagist.org/packages/phptg/bot-api)
[![Build status](https://github.com/phptg/bot-api/actions/workflows/build.yml/badge.svg)](https://github.com/phptg/bot-api/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/phptg/bot-api/badge.svg)](https://coveralls.io/github/phptg/bot-api)
[![Mutation score](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fphptg%2Fbot-api%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/phptg/bot-api/master)
[![Static analysis](https://github.com/phptg/bot-api/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/phptg/bot-api/actions/workflows/static.yml?query=branch%3Amaster)

The package provides a simple and convenient way to interact with the Telegram Bot API.

Expand All @@ -20,15 +20,15 @@ The package provides a simple and convenient way to interact with the Telegram B
The package can be installed with [Composer](https://getcomposer.org/download/):

```shell
composer require vjik/telegram-bot-api
composer require phptg/bot-api
```

## General usage

To make requests to the Telegram Bot API, you need to create an instance of the `TelegramBotApi` class.

```php
use Vjik\TelegramBot\Api\TelegramBotApi;
use Phptg\BotApi\TelegramBotApi;

// API
$api = new TelegramBotApi(
Expand All @@ -41,7 +41,7 @@ Now you can use the `$api` instance to interact with the Telegram Bot API. Metho
the [Telegram Bot API documentation](https://core.telegram.org/bots/api). For example:

```php
use Vjik\TelegramBot\Api\Type\InputFile
use Phptg\BotApi\Type\InputFile

// Specify a URL for outgoing webhook
$api->setWebhook('https://example.com/webhook');
Expand All @@ -63,7 +63,7 @@ The result will be either a `FailResult` instance (occurring on an error) or an
(occurring on success). For example:

```php
// Result is an array of `Vjik\TelegramBot\Api\Update\Update` objects
// Result is an array of `Phptg\BotApi\Update\Update` objects
$updates = $api->getUpdates();
```

Expand All @@ -90,8 +90,8 @@ Use `TelegramBotApi::makeFileUrl()` method to make a URL for downloading a file

```php
/**
* @var \Vjik\TelegramBot\Api\TelegramBotApi $api
* @var \Vjik\TelegramBot\Api\Type\File $file
* @var \Phptg\BotApi\TelegramBotApi $api
* @var \Phptg\BotApi\Type\File $file
*/

// By `File` instance
Expand All @@ -108,8 +108,8 @@ server. For example:

```php
/**
* @var \Vjik\TelegramBot\Api\TelegramBotApi $api
* @var \Vjik\TelegramBot\Api\Type\File $file
* @var \Phptg\BotApi\TelegramBotApi $api
* @var \Phptg\BotApi\Type\File $file
*/

// Get file content by `File` instance
Expand Down Expand Up @@ -137,7 +137,7 @@ If you have any questions or problems with this package, use [author telegram ch

## License

The `vjik/telegram-bot-api` is free software. It is released under the terms of the BSD License.
The `phptg/bot-api` is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE.md) for more information.

## Credits
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vjik/telegram-bot-api",
"name": "phptg/bot-api",
"type": "library",
"description": "PHP library for working with Telegram API",
"keywords": [
Expand All @@ -9,8 +9,8 @@
],
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/vjik/telegram-bot-api/issues?state=open",
"source": "https://github.com/vjik/telegram-bot-api",
"issues": "https://github.com/phptg/bot-api/issues?state=open",
"source": "https://github.com/phptg/bot-api",
"chat": "https://t.me/predvoditelev_chat"
},
"authors": [
Expand Down Expand Up @@ -43,12 +43,12 @@
},
"autoload": {
"psr-4": {
"Vjik\\TelegramBot\\Api\\": "src"
"Phptg\\BotApi\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Vjik\\TelegramBot\\Api\\Tests\\": "tests"
"Phptg\\BotApi\\Tests\\": "tests"
}
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions docs/custom-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
You can make custom requests to API using the `call()` method and `CustomMethod` object:

```php
use Vjik\TelegramBot\Api\CustomMethod;
use Vjik\TelegramBot\Api\ParseResult\ValueProcessor\ObjectValue;
use Phptg\BotApi\CustomMethod;
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;

/**
* @var \Vjik\TelegramBot\Api\TelegramBotApi $api
* @var \Phptg\BotApi\TelegramBotApi $api
*/

$method = new CustomMethod(
Expand All @@ -17,6 +17,6 @@ $method = new CustomMethod(
httpMethod: HttpMethod::GET,
);

// Result is an object of `Vjik\TelegramBot\Api\Type\ChatFullInfo`
// Result is an object of `Phptg\BotApi\Type\ChatFullInfo`
$result = $api->call($method);
```
4 changes: 2 additions & 2 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pass logger to `TelegramBotApi` constructor:

```php
use Psr\Log\LoggerInterface;
use Vjik\TelegramBot\Api\TelegramBotApi;
use Phptg\BotApi\TelegramBotApi;

/**
* @var string $token
Expand All @@ -26,7 +26,7 @@ You can use logger on create `Update` object also:
```php
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Vjik\TelegramBot\Api\Type\Update\Update;
use Phptg\BotApi\Type\Update\Update;

/**
* @var ServerRequestInterface $request
Expand Down
14 changes: 7 additions & 7 deletions docs/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

By default `TelegramBotApi` uses cURL to make requests to the Telegram Bot API and download files from Telegram servers.
But you can use any other transport implementation that implements
the `Vjik\TelegramBot\Api\Transport\TransportInterface` interface.
the `Phptg\BotApi\Transport\TransportInterface` interface.

Out of the box, available three transport implementations: cURL, native and PSR.

Expand All @@ -15,8 +15,8 @@ since the cURL extension is included in most PHP installations.
General usage:

```php
use Vjik\TelegramBot\Api\TelegramBotApi;
use Vjik\TelegramBot\Api\Transport\CurlTransport;
use Phptg\BotApi\TelegramBotApi;
use Phptg\BotApi\Transport\CurlTransport;

// Telegram bot authentication token
$token = '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw';
Expand All @@ -38,8 +38,8 @@ the Telegram Bot API and not require any additional extensions.
General usage:

```php
use Vjik\TelegramBot\Api\TelegramBotApi;
use Vjik\TelegramBot\Api\Transport\NativeTransport;
use Phptg\BotApi\TelegramBotApi;
use Phptg\BotApi\Transport\NativeTransport;

// Telegram bot authentication token
$token = '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw';
Expand Down Expand Up @@ -77,8 +77,8 @@ use Http\Client\Curl\Client;
use HttpSoft\Message\RequestFactory;
use HttpSoft\Message\ResponseFactory;
use HttpSoft\Message\StreamFactory;
use Vjik\TelegramBot\Api\TelegramBotApi;
use Vjik\TelegramBot\Api\Transport\PsrTransport;
use Phptg\BotApi\TelegramBotApi;
use Phptg\BotApi\Transport\PsrTransport;

$streamFactory = new StreamFactory();
$responseFactory = new ResponseFactory();
Expand Down
38 changes: 19 additions & 19 deletions docs/webhook-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If `Update` created by `fromJson()` or `fromServerRequest()` method, you can get

```php
/**
* @var Vjik\TelegramBot\Api\Type\Update\Update $update
* @var Phptg\BotApi\Type\Update\Update $update
*/

/**
Expand Down Expand Up @@ -61,8 +61,8 @@ Creating `Update` object from the incoming webhook PSR-7 request:

```php
use Psr\Http\Message\ServerRequestInterface;
use Vjik\TelegramBot\Api\ParseResult\TelegramParseResultException;
use Vjik\TelegramBot\Api\Type\Update\Update;
use Phptg\BotApi\ParseResult\TelegramParseResultException;
use Phptg\BotApi\Type\Update\Update;

/**
* @var ServerRequestInterface $request
Expand All @@ -80,8 +80,8 @@ try {
Creating `Update` object from JSON string received from POST request body:

```php
use Vjik\TelegramBot\Api\Type\Update\Update;
use Vjik\TelegramBot\Api\ParseResult\TelegramParseResultException;
use Phptg\BotApi\Type\Update\Update;
use Phptg\BotApi\ParseResult\TelegramParseResultException;

/**
* @var string $jsonString
Expand All @@ -99,8 +99,8 @@ try {
If needed, you can create `Update` object manually via constructor:

```php
use Vjik\TelegramBot\Api\Type\Message;
use Vjik\TelegramBot\Api\Type\Update\Update;
use Phptg\BotApi\Type\Message;
use Phptg\BotApi\Type\Update\Update;

/**
* @var Message $message
Expand All @@ -124,8 +124,8 @@ make one Bot API request without waiting for a response from your server.
The `WebhookResponse` class represents a method as a response to a webhook. You can create it from any method object:

```php
use Vjik\TelegramBot\Api\Method\SendMessage;
use Vjik\TelegramBot\Api\WebhookResponse\WebhookResponse;
use Phptg\BotApi\Method\SendMessage;
use Phptg\BotApi\WebhookResponse\WebhookResponse;

$method = new SendMessage(chatId: 12345, text: 'Hello!');
$webhookResponse = new WebhookResponse($method);
Expand All @@ -144,9 +144,9 @@ The `PsrWebhookResponseFactory` creates PSR-7 compliant HTTP responses for webho
```php
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Vjik\TelegramBot\Api\Method\SendMessage;
use Vjik\TelegramBot\Api\WebhookResponse\PsrWebhookResponseFactory;
use Vjik\TelegramBot\Api\WebhookResponse\WebhookResponse;
use Phptg\BotApi\Method\SendMessage;
use Phptg\BotApi\WebhookResponse\PsrWebhookResponseFactory;
use Phptg\BotApi\WebhookResponse\WebhookResponse;

/**
* @var ResponseFactoryInterface $responseFactory
Expand Down Expand Up @@ -175,9 +175,9 @@ The factory automatically:
The `JsonWebhookResponseFactory` creates JSON strings for webhook responses:

```php
use Vjik\TelegramBot\Api\Method\SendMessage;
use Vjik\TelegramBot\Api\WebhookResponse\JsonWebhookResponseFactory;
use Vjik\TelegramBot\Api\WebhookResponse\WebhookResponse;
use Phptg\BotApi\Method\SendMessage;
use Phptg\BotApi\WebhookResponse\JsonWebhookResponseFactory;
use Phptg\BotApi\WebhookResponse\WebhookResponse;

$factory = new JsonWebhookResponseFactory();

Expand Down Expand Up @@ -205,10 +205,10 @@ If you try to create a webhook response with a method that uses `InputFile`, the
- `getData()` will throw `MethodNotSupportedException`.

```php
use Vjik\TelegramBot\Api\Method\SendPhoto;
use Vjik\TelegramBot\Api\Type\InputFile;
use Vjik\TelegramBot\Api\WebhookResponse\WebhookResponse;
use Vjik\TelegramBot\Api\WebhookResponse\MethodNotSupportedException;
use Phptg\BotApi\Method\SendPhoto;
use Phptg\BotApi\Type\InputFile;
use Phptg\BotApi\WebhookResponse\WebhookResponse;
use Phptg\BotApi\WebhookResponse\MethodNotSupportedException;

$method = new SendPhoto(
chatId: 12345,
Expand Down
12 changes: 6 additions & 6 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api;
namespace Phptg\BotApi;

use JsonException;
use Psr\Log\LoggerInterface;
use SensitiveParameter;
use Vjik\TelegramBot\Api\ParseResult\ResultFactory;
use Vjik\TelegramBot\Api\ParseResult\TelegramParseResultException;
use Vjik\TelegramBot\Api\Transport\ApiResponse;
use Vjik\TelegramBot\Api\Transport\TransportInterface;
use Vjik\TelegramBot\Api\Type\ResponseParameters;
use Phptg\BotApi\ParseResult\ResultFactory;
use Phptg\BotApi\ParseResult\TelegramParseResultException;
use Phptg\BotApi\Transport\ApiResponse;
use Phptg\BotApi\Transport\TransportInterface;
use Phptg\BotApi\Type\ResponseParameters;

use function array_key_exists;
use function is_array;
Expand Down
2 changes: 1 addition & 1 deletion src/Constant/ForumTopicIconColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Constant;
namespace Phptg\BotApi\Constant;

/**
* @api
Expand Down
2 changes: 1 addition & 1 deletion src/Constant/MessageEntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Constant;
namespace Phptg\BotApi\Constant;

/**
* @see https://core.telegram.org/bots/api#formatting-options
Expand Down
2 changes: 1 addition & 1 deletion src/Constant/ParseMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Constant;
namespace Phptg\BotApi\Constant;

/**
* @see https://core.telegram.org/bots/api#formatting-options
Expand Down
2 changes: 1 addition & 1 deletion src/Constant/Sticker/StickerFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Constant\Sticker;
namespace Phptg\BotApi\Constant\Sticker;

/**
* @api
Expand Down
2 changes: 1 addition & 1 deletion src/Constant/Sticker/StickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Constant\Sticker;
namespace Phptg\BotApi\Constant\Sticker;

/**
* @api
Expand Down
2 changes: 1 addition & 1 deletion src/Curl/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Curl;
namespace Phptg\BotApi\Curl;

use CurlHandle;
use CurlShareHandle;
Expand Down
2 changes: 1 addition & 1 deletion src/Curl/CurlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Vjik\TelegramBot\Api\Curl;
namespace Phptg\BotApi\Curl;

use RuntimeException;

Expand Down
Loading
Loading