onmotion/yii2-telegram
Composer 安装命令:
composer require onmotion/yii2-telegram
包简介
Support chat for site based on Telegram bot
README 文档
README
Support chat for site based on Telegram bot
The Bot logic based on akalongman/php-telegram-bot, so you can read Instructions by longman how to register Telegram Bot and etc.
Now only telegram webhook api support. You need SSL cert! Doesn't work on http!
Installation
The preferred way to install this extension is through composer.
Run
composer require onmotion/yii2-telegram
add to your web config:
'modules' => [
//...
'telegram' => [
'class' => 'onmotion\telegram\Module',
'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
'BOT_NAME' => 'YourBotName_bot',
'hook_url' => 'https://yourhost.com/telegram/default/hook', // must be https! (if not prettyUrl https://yourhost.com/index.php?r=telegram/default/hook)
'PASSPHRASE' => 'passphrase for login',
// 'db' => 'db2', //db file name from config dir
// 'userCommandsPath' => '@app/modules/telegram/UserCommands',
// 'timeBeforeResetChatHandler' => 60
]
//more...
]
and to console config:
'bootstrap' => [
//other bootstrap components...
'telegram'],
'modules' => [
//...
'telegram' => [
'class' => 'onmotion\telegram\Module',
'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
'BOT_NAME' => 'YourBotName_bot',
'hook_url' => 'https://yourhost.com/telegram/default/hook', // must be https! (if not prettyUrl https://yourhost.com/index.php?r=telegram/default/hook)
'PASSPHRASE' => 'passphrase for login',
]
],
run migrations:
php yii migrate --migrationPath=@vendor/onmotion/yii2-telegram/migrations #that add 4 tables in your DB
or add to your config file
'controllerMap' => [
...
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationNamespaces' => [
'onmotion\telegram\migrations',
],
],
...
],
and run
php yii migrate/up
go to https://yourhost.com/telegram/default/set-webhook (if not prettyUrl https://yourhost.com/index.php?r=telegram/default/set-webhook)
Now you can place where you want
echo \onmotion\telegram\Telegram::widget(); //that add chat button in the page
in bottom right corner you can see:
if you click it:
and server side:
If you want to limit the storage period of messages history, add to you crontab:
#leave 5 days (if empty - default = 7)
php yii telegram/messages/clean 5
Also you can use custom commands. To do this, you can copy UserCommands dir from /vendor/onmotion/yii2-telegram/Commands and add path to this in config, for example:
'userCommandsPath' => '@app/modules/telegram/UserCommands'
timeBeforeResetChatHandler - the number of minutes before chat handler will be killed (if he forgot do /leavedialog). Never kill if 0 or not setted.
onmotion/yii2-telegram 适用场景与选型建议
onmotion/yii2-telegram 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.38k 次下载、GitHub Stars 达 52, 最近一次更新时间为 2016 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「extension」 「chat」 「bot」 「yii2」 「telegram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onmotion/yii2-telegram 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onmotion/yii2-telegram 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onmotion/yii2-telegram 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
Client for the REST API plugin of the OpenFire Server
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 6.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 52
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-08


