zafarjonovich / yii-telegram-action
There is no license information available for the latest version (0.0.0.5) of this package.
Yii telegram queue
0.0.0.5
2021-09-24 21:18 UTC
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();