rezident/self-documented-telegram-bot-sdk

自文档化的Telegram机器人SDK

6.6.0 2023-03-22 05:09 UTC

This package is auto-updated.

Last update: 2024-09-22 08:18:35 UTC


README

这是一个用PHP编写的简单Telegram机器人SDK。

用法

获取机器人更新

use Rezident\SelfDocumentedTelegramBotSdk\components\Executor;
use Rezident\SelfDocumentedTelegramBotSdk\methods\GettingUpdates\GetUpdatesMethod;

$executor = new Executor('8360528562:Eim2eitahSh3ohshi7zee2Hoh2gaewee6eV');
$updates = GetUpdatesMethod::new()->exec($executor);

foreach ($updates as $update) {
    echo $update->getMessage()->getText();
}

发送消息

use Rezident\SelfDocumentedTelegramBotSdk\components\Executor;
use Rezident\SelfDocumentedTelegramBotSdk\methods\GettingUpdates\GetUpdatesMethod;

$executor = new Executor('8360528562:Eim2eitahSh3ohshi7zee2Hoh2gaewee6eV');
$sentMessage = SendMessageMethod::new(8376498, 'Hello my dear friend!')->exec($executor);
...