Merge branch 'feature/rpc_alert' into 'master'
Feature/rpc alert See merge request composer/php-alert-client!3
This commit is contained in:
commit
3d7d02f353
|
@ -253,3 +253,60 @@ function bot_notify($name, $content)
|
|||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对单个或多个用户发送报警或通知图片,多个用户id使用 | 隔开
|
||||
*
|
||||
* @param $media_id
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
function user_image_alert ($username, $media_id)
|
||||
{
|
||||
if (env('APP_ENV') == 'local') {
|
||||
return true;
|
||||
}
|
||||
$base_client = new \JsonRpc\Client(RPC_CONFIG);
|
||||
$client = $base_client->endpoint('auth');
|
||||
|
||||
$username = explode('|', $username);
|
||||
try {
|
||||
$res = $client->call('notify.image', [
|
||||
['user' => $username],
|
||||
$media_id,
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对企业微信群发送报警图片(需先创建
|
||||
*
|
||||
* @param $chat
|
||||
* @param $media_id
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
|
||||
function chat_image_alert ($chat, $media_id)
|
||||
{
|
||||
if (env('APP_ENV') == 'local') {
|
||||
return true;
|
||||
}
|
||||
$base_client = new \JsonRpc\Client(RPC_CONFIG);
|
||||
$client = $base_client->endpoint('auth');
|
||||
|
||||
try {
|
||||
$resp = $client->call('notify.image', [
|
||||
['chat' => $chat],
|
||||
$media_id,
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
Loading…
Reference in New Issue
Block a user