zafarjonovich / yii-telegram-action
Yii telegram queue
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/zafarjonovich/yii-telegram-action
Requires
- php: >=7.2
- ext-json: *
README
This component helps to run telegram actions with async
Installation
composer install zafarjonovich/yii-telegram-action
php yii migrate --migrationPath="@vendor/zafarjonovich/yii-telegram-action/src/migrations"
Working with component
use zafarjonovich\YiiTelegramAction\models\TelegramMessageAction; use \zafarjonovich\YiiTelegramAction\models\TelegramMessageActionChild; use zafarjonovich\YiiTelegramAction\base\ChildAction; use \zafarjonovich\YiiTelegramAction\base\Action; class SendNotification extends ChildAction { public function run(){ $children = $this->parent->action->getTelegramMessageActionChildren()->all(); $options = $this->parent->action->options; foreach ($children as $child) { \Yii::$app->telegram->sendMessage($child->chat_id,$options['text']); } } } $options = [ 'text' => 'Hello world' ]; $action = TelegramMessageAction::create('UniqueKey',SendNotification::class,$options); // id = 7 TelegramMessageActionChild::create($action->id,666000111); // For run action class SomeControllerAction extends \yii\base\Action { } $controllerAction = new SomeControllerAction(); $asyncAction = new Action($action,$controllerAction); $asyncAction->run();