kodeops/laravel-telegram-wrapper
Composer 安装命令:
composer require kodeops/laravel-telegram-wrapper
包简介
Laravel Telegram API wrapper.
README 文档
README
_ _ _____ ______ _______ _____ _____ _______
|____/ | | | \ |______ | | |_____] |______
| \_ |_____| |_____/ |______ |_____| | ______|
Laravel Telegram API Wrapper
This package is a wrapper for the Telegram API.
Install composer dependency
$ composer require kodeops/laravel-telegram-wrapper
Setup logging
Add a new channel in logging.php config file:
'telegram' => [
'driver' => 'single',
'path' => storage_path('logs/telegram.log'),
'level' => 'info',
],
Add environment settings
These would be used by default, additionally you can pass the credentials when instantiating the object.
TELEGRAM_DEBUG=false
TELEGRAM_BOT_TOKEN=<token>
TELEGRAM_CHAT_ID=<chat_id>
Usage
Send a new message
use kodeops\LaravelTelegramWrapper\Telegram;
return (new Telegram())
->withMarkdown($markdown)
->sendMessage();
You can also specify the credentials (bot_token and chat_id) when instantiating the object.
use kodeops\LaravelTelegramWrapper\Telegram;
return (new Telegram($bot_token))
->chat($chat_id)
->withMarkdownImage($image)
->withKeyboard($keyboard)
->withMarkdown($markdown)
->sendMessage();
This produces a message with the image on top and uses the image for notification highlight.
use kodeops\LaravelTelegramWrapper\Telegram;
$keyboard = [
'inline_keyboard' => [
[
[
'text' => 'Text Button',
'url' => 'https://tannhauser-gate.xyz',
],
]
]
];
$markdown = 'A simple *markdown* text';
$image = 'https://iibusiness.s3.eu-central-1.amazonaws.com/tannhauser/favicon.jpg';
return (new Telegram())
->withKeyboard($keyboard)
->withMarkdownCaption($markdown)
->sendPhoto($image);
Options for sending messages:
-
disableWebPagePreview(): Disables link previews for links in this message -
withKeyboard($keyboard): Sets the keyboard for a message -
withMarkdown($markdown): Sets the markdown text -
withMarkdownImage($image): Sets an image to the message using markdown -
withMarkdownCaption($markdown): Sets a markdown text as a caption (useful in combination withsendPhoto($image))
Utils
-
setMyCommands($commands): set bot commands -
setWebhook($url): set webhooks url More info on webhooks -
getWebhookInfo(): get webhooks info
Additional features
In general you can use setParam($key, $value) method to add parameters to the request.
kodeops/laravel-telegram-wrapper 适用场景与选型建议
kodeops/laravel-telegram-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 735 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「laravel」 「telegram」 「kodeops」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kodeops/laravel-telegram-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kodeops/laravel-telegram-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kodeops/laravel-telegram-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Laravel 5.6 Monolog custom telegram channel
PHP Wrapper for Telegram Bot API
Plugin for YOURLS. Default tools to use in some laemmi plugins
Alfabank REST API integration
Telegram bot integration with laravel
统计信息
- 总下载量: 735
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-08