r-everse/telegram-bundle

此包已被弃用且不再维护。未建议替换包。

Telegram SDK 的 Symfony 集成

安装: 514

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

v0.1.0 2020-06-19 15:42 UTC

This package is auto-updated.

Last update: 2021-08-26 17:38:16 UTC


README

此包已弃用并将很快被移除。我们建议直接使用 irazasyed/telegram-bot-sdk

Telegram Bundle

Symfony 对 Telegram SDK 的集成。

Latest Stable Version Total Downloads Latest Unstable Version License

安装

步骤 1: 下载 Bundle

您可以使用 Composer 安装此 Bundle

composer require r-everse/telegram-bundle:^0.1

步骤 2: 启用 Bundle

然后,通过将其添加到项目中的 app/AppKernel.php 文件中注册的 Bundle 列表中来启用 Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Telegram\TelegramBundle\TelegramBundle(),
        ];

        // ...
    }

    // ...
}

配置

将其添加到 app/config/config.yml

telegram:
    token: 'YOUR BOT TOKEN HERE'
    chats: 
        my_chat_alias: -0000000 

将其添加到 app/config/config_dev.yml

parameters:
    // ...
    telegram.chat.class: Telegram\TelegramBundle\Service\NullChat
    // ...

使用方法

$this->getContainer()->get('telegram.chat.my_chat_alias')->sendMessage('Hello world!');