mateodioev / tgbot
用于与Telegram机器人API方法交互的库
v4.6.2
2024-09-16 01:24 UTC
Requires
- php: >=8.2
- ext-curl: *
- ext-fileinfo: *
- amphp/amp: ^3.0
- amphp/byte-stream: ^2.1
- amphp/file: ^3.0
- amphp/http-client: ^v5.0
- mateodioev/request: ^2.0
- mateodioev/utils: ^1.1
- vlucas/phpdotenv: ^5.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.35
- mateodioev/php-easy-cli: *
- phpunit/phpunit: ^9.5
- dev-main
- v4.x-dev
- v4.6.2
- v4.6.1
- v4.6.0
- v4.5.0
- v4.4.5
- v4.4.4
- v4.4.3
- v4.4.2
- v4.4.1
- v4.4
- v4.3.6
- v4.3.5
- v4.3.4.1
- v4.3.4-beta
- v4.3.3
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.2
- v4.2.1
- v4.2.0-beta2
- v4.2.0-beta
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.0-beta3
- v4.0.0-beta2
- v4.0.0-beta1
- v4.0.0-beta
- v3.x-dev
- v3.6.0
- v3.5.12
- v3.5.11
- v3.5.6
- v3.5.5
- v3.5.4
- v3.5.3
- v3.5.2.1
- v3.5.2
- v3.5.1
- v3.5.0
- v3.4.3
- v3.4.2.1
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.1
- v3.3.0
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2
- v3.1
- v3.0.1
- v3.0
- v3.0-beta
- v2.0.1
- v2.0
- v1.2.2
- v1.2.1
- v1.2
- v1.1.2
- v1.1.1
- v1.1
- v1.0
- dev-v4-powerfull_constructors
This package is auto-updated.
Last update: 2024-09-16 01:26:43 UTC
README
安装
composer require mateodioev/tgbot
git clone https://github.com/Mateodioev/tgbot
第一步
require __DIR__ . 'path/to/vendor/autoload.php';
创建新的Api实例
use Mateodioev\Bots\Telegram\Api; $api = new Api($bot_token);
向Telegram API发送方法
use Mateodioev\Bots\Telegram\Types\Message; $message = $api->sendMessage('chat_id', 'Text', $others_params); var_dump($message->get()); var_dump($message instanceof Message::class);
启用异步模式
注意:此用法需要amphp/http-client
$api->setAsync(true);
创建新的Telegram类型
use Mateodioev\Bots\Telegram\Types\baseType; class MyCustomType extends baseType { protected array $fields = [ 'field1' => 'valueType', 'id' => 'integer', // only accept integer values 'user' => User::class, // only accept arrays or instances of the User class ]; }
创建新实例
// from array $customType = MyCustomType::createFromArray(['field1' => 'Type', 'id' => 1111, 'user' => $user]); // From stdClass $customType = MyCustomType::create((object) ['field1' => 'Type', 'id' => 1111, 'user' => $user]); // Create from constructor $customType = new MyCustomType(field1: 'Type', id: 1111, user: $user); // maybe this cause linter errors