丛林湾/telegram-bot-platform

此包已被废弃且不再维护。没有建议的替代包。

PHP库用于Telegram机器人平台

1.2 2018-01-20 21:55 UTC

This package is not auto-updated.

Last update: 2024-01-08 21:28:14 UTC


README

Telegram Bot Platform Logo

Telegram机器人平台

Travis CI Scrutinizer CI Codecov

这是用于Telegram机器人平台的PHP库。
您可以通过文档来与库一起工作。

安装

推荐的安装方式是通过Composer

composer require jungle-bay/telegram-bot-platform

使用示例

<?php

require_once __DIR__ . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('vendor', 'autoload.php'));

$request = file_get_contents('php://input');                                // Request body. (JSON-serialized Update object)

$tbp = new \TelegramBotPlatform\TelegramBotPlatform(array(
    'token'    => '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',              // Your token bot.
    'storage'  => $adapter,                                                 // This adapter for Scrapbook library to store user sessions. See the complete adapters: https://github.com/matthiasmullie/scrapbook#adapters
    'payload'  => null,                                                     // This payload will be passed for third parameter to command. (optional)
    'mappings' => array(
        'default'       => \MyBot\Commands\DefaultCmd::class,               // This command will work by default if no command is found or user session. (optional)
        'inline_query'  => \MyBot\Commands\FeedbackInlineQueryCmd::class,   // This command will work with inline queries. (optional)
        'commands'      => array(                                           // This is the list of registered commands for the bot. (optional)
            'help' => \MyBot\Commands\HelpCmd::class,
            'user' => \MyBot\Commands\UserCmd::class
        )
    )
), $request);

$tbp->run();

文档

请在此查看完整文档。

注意

为了方便开发,您可以使用Telegram Bot CLI

许可证

此软件包在MIT许可证下。请在此查看完整的许可证。