Compare commits

...

10 Commits

Author SHA1 Message Date
董巍
d588a7d108 Merge branch 'feature/notify_file' into 'master'
发送文件消息

See merge request composer/php-alert-client!5
2019-07-15 10:41:21 +08:00
侯登峰
c02656e435 发送文件消息 2019-07-12 18:20:27 +08:00
董巍
4133ce2995 Merge branch 'feature/rpc_alert' into 'master'
alert 请求实体机器

See merge request composer/php-alert-client!4
2019-07-11 15:34:03 +08:00
lisida
eb92fe8e8b alert 请求实体机器 2019-07-11 15:33:19 +08:00
董巍
3d7d02f353 Merge branch 'feature/rpc_alert' into 'master'
Feature/rpc alert

See merge request composer/php-alert-client!3
2019-07-10 18:55:56 +08:00
lisida
f6ed2277fa Merge branch 'master' into feature/rpc_alert 2019-07-10 18:55:19 +08:00
lisida
1534831332 alert 2019-07-10 18:55:07 +08:00
董巍
029c02969b Merge branch 'feature/rpc_alert' into 'master'
地址

See merge request composer/php-alert-client!2
2019-07-10 18:37:54 +08:00
lisida
74f2959272 地址 2019-07-10 18:37:13 +08:00
dongwei
80655ac74d remove log 2019-07-03 14:28:47 +08:00

View File

@ -32,7 +32,6 @@ function chat_text_alert ($chat, $text)
$text,
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -61,7 +60,6 @@ function user_text_alert ($username, $text)
$text,
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -97,7 +95,6 @@ function chat_card_alert ($chat, $title, $desc, $button, $url)
$url,
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -134,7 +131,6 @@ function user_card_alert ($username, $title, $desc, $button, $url)
$url,
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -175,7 +171,6 @@ function user_mp_alert ($username, $appid, $title, $page = null, $desc = null, $
$emphasisFirstItem
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -215,7 +210,6 @@ function tag_mp_alert ($tag, $appid, $title, $page = null, $desc = null, $items
$emphasisFirstItem
]);
} catch (Exception $ex) {
app("log")->error("chat_notify_error", ['message' => $ex->getMessage()]);
return null;
}
@ -258,4 +252,90 @@ function bot_notify($name, $content)
} else {
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;
}
/**
* 对企业微信群发送报警文件(需先创建
*
* @param $chat
* @param $media_id
*
* @return mixed|null
*/
function chat_file_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.file', [
['chat' => $chat],
$media_id,
]);
} catch (Exception $ex) {
return null;
}
return $resp;
}