ltdsh/telegram-bot-sender
最新稳定版本:0.2.2
Composer 安装命令:
composer require ltdsh/telegram-bot-sender
包简介
Simple class for sendinf messages with telegram bot
README 文档
README
Small symfony bundle to send messages via telegram bot
Installation on existing symfony project
composer require ltdsh/telegram-bot-sender
Add bundle to config/bundles.php:
<?php
return [
...
ltdsh\TelegramBotSender\TelegramBotSender::class => ['all' => true],
...
];
Configure composer.json in autoload configuration part:
...
"autoload": {
"psr-4": {
...
"ltdsh\\TelegramBotSender\\": "vendor/ltdsh/telegram-bot-sender/src/"
...
}
},
...
If you want to use bundle as a service, add those lines to config/services.yaml:
services:
...
ltdsh\TelegramBotSender\TelegramBotSender:
class: ltdsh\TelegramBotSender\TelegramBotSender
...
Example(assuming you already have a telegram bot and tg chat with this bot):
class ExampleService
{
public function __construct(
private string $telegramBotToken,
private TelegramBotSender $telegramBotSender
)
{
}
public function sendMessage(): string
{
return $this->telegramBotSender
->sendSimpleMessage(
$this->telegramBotToken,
-123,
"test message"
);
}
}
By the way in this example you also need to configure telegramBotToken variable in services.yaml
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-16