https://github.com/rustamwin/yii2-telegram
Yii2 MongoDB telegram bot api
https://github.com/rustamwin/yii2-telegram
telegram telegram-bot-api yii2
Last synced: about 2 months ago
JSON representation
Yii2 MongoDB telegram bot api
- Host: GitHub
- URL: https://github.com/rustamwin/yii2-telegram
- Owner: rustamwin
- License: gpl-3.0
- Created: 2017-09-26T10:31:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-26T11:57:29.000Z (over 8 years ago)
- Last Synced: 2025-06-16T23:04:11.073Z (about 1 year ago)
- Topics: telegram, telegram-bot-api, yii2
- Language: PHP
- Size: 138 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Telegram support Bot for Yii2**
[](https://packagist.org/packages/rustam95/yii2-telegram) [](https://packagist.org/packages/rustam95/yii2-telegram) [](https://packagist.org/packages/rustam95/yii2-telegram) [](https://packagist.org/packages/rustam95/yii2-telegram) [](https://packagist.org/packages/rustam95/yii2-telegram)
**Support chat for site based on Telegram bot**
The Bot logic based on [akalongman/php-telegram-bot](https://github.com/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](http://getcomposer.org/download/).
Run
composer require rustam95/yii2-telegram
add to your web config:
'modules' => [
//...
'telegram' => [
'class' => 'rustam95\telegram\Module',
'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
'BOT_NAME' => 'YourBotName_bot',
'hook_url' => 'https://yourhost.com/telegram/default/hook', // must be https!
'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' => 'rustam95\telegram\Module',
'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
'BOT_NAME' => 'YourBotName_bot',
]
],
go to https://yourhost.com/telegram/default/set-webhook
Now you can place where you want
echo \rustam95\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 should copy UserCommands dir from /vendor/modules/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.