zafarjonovich/yii-telegram-notification

此软件包最新版本(0.0.0.1)没有可用的许可信息。

Yii Telegram 通知

0.0.0.1 2022-01-16 16:38 UTC

This package is auto-updated.

Last update: 2024-09-16 20:57:43 UTC


README

Assalomu aleykum. 这些组件可以帮助您通过您的 Yii 应用程序上的 Telegram 机器人向 Telegram 聊天发送消息通知。

安装

安装此扩展的首选方式是通过 Composer

运行以下命令之一:

composer require zafarjonovich/yii-telegram-notification

或添加

"zafarjonovich/yii-telegram-notification": "*"

到您的 composer.json 文件的 require 部分。

配置

将此组件添加到您的 app/config.php 文件中。

<?php

$config = [
 ...
 'components' => [
 ...
	  'telegramNotification' => [
            'class' => \zafarjonovich\YiiTelegramNotification\YiiTelegramNotificationComponent::class,
            'bot_token' => 'BOT_TOKEN_HERE'
        ],

];

?>

使用方法

<?php

// Sending text message

\Yii::$app->telegramNotification->send('chat_id',[
    'text' => "Hello world"
]);

// Sending photo message, this example text will be comment of photo

\Yii::$app->telegramNotification->send('chat_id',[
    'photo' => "PHOTO_URL",
    'text' => "Hello world",
]);


// Sending video message, this example text will be comment of video

\Yii::$app->telegramNotification->send('chat_id',[
    'video' => "VIDEO_URL",
    'text' => "Hello world",
]);

// Send message multiple chats

\Yii::$app->telegramNotification->multipleSend(['chat_id1','chat_id2'],[
    'text' => "Hello world"
]);


?>