ltdsh/telegram-bot-sender 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-16