r-everse / telegram-bundle
此包已被弃用且不再维护。未建议替换包。
Telegram SDK 的 Symfony 集成
v0.1.0
2020-06-19 15:42 UTC
Requires
- php: ^7.1
- irazasyed/telegram-bot-sdk: ^2.0
- symfony/config: ^3.4
- symfony/console: ^3.4
- symfony/dependency-injection: ^3.4
- symfony/http-kernel: ^3.4
This package is auto-updated.
Last update: 2021-08-26 17:38:16 UTC
README
此包已弃用并将很快被移除。我们建议直接使用 irazasyed/telegram-bot-sdk。
Telegram Bundle
Symfony 对 Telegram SDK 的集成。
安装
步骤 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!');