Compare commits

..

No commits in common. "main" and "v0.5" have entirely different histories.
main ... v0.5

3 changed files with 2304 additions and 301 deletions

View File

@ -13,5 +13,11 @@
}, },
"require": { "require": {
"paidian/json-rpc": "~1.1" "paidian/json-rpc": "~1.1"
},
"repositories": {
"php-json-rpc": {
"type": "vcs",
"url": "git@git.int.haowumc.com:composer/php-json-rpc.git"
}
} }
} }

2077
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,220 +1,226 @@
<?php <?php
define('RPC_CONFIG', [ //define('RPC_CONFIG', [
'app' => env('APP_NAME'), // 'app' => env('APP_NAME'),
'client' => [ // 'client' => [
'auth' => [ // 'auth' => [
'base_uri' => 'http://auth.in.haowumc.com', // 'base_uri' => 'http://auth.in.haowumc.com',
], // ],
], // ],
]); //]);
//
/** ///**
* 对企业微信群发送报警信息(需先创建 // * 对企业微信群发送报警信息(需先创建
* // *
* @param $chat // * @param $chat
* @param $text // * @param $text
* // *
* @return mixed|null // * @return mixed|null
*/ // */
//
function chat_text_alert ($chat, $text) //function chat_text_alert ($chat, $text)
{ //{
if (env('APP_ENV') == 'local') { // if (env('APP_ENV') == 'local') {
return true; // return true;
} // }
$base_client = new \JsonRpc\Client(RPC_CONFIG); // $base_client = new \JsonRpc\Client(RPC_CONFIG);
$client = $base_client->endpoint('auth'); // $client = $base_client->endpoint('auth');
//
try { // try {
$resp = $client->call('notify.text', [ // $resp = $client->call('notify.text', [
['chat' => $chat], // ['chat' => $chat],
$text, // $text,
]); // ]);
} catch (Exception $ex) { // } catch (Exception $ex) {
return null; // var_dump($ex->getMessage());
} // return null;
// }
return $resp; //
} // return $resp;
//}
/** //
* 对单个或多个用户发送报警或通知信息多个用户id使用 | 隔开 ///**
* // * 对单个或多个用户发送报警或通知信息多个用户id使用 | 隔开
* @param $text // *
* // * @param $text
* @return mixed|null // *
*/ // * @return mixed|null
function user_text_alert ($username, $text) // */
{ //function user_text_alert ($username, $text)
if (env('APP_ENV') == 'local') { //{
return true; // if (env('APP_ENV') == 'local') {
} // return true;
$base_client = new \JsonRpc\Client(RPC_CONFIG); // }
$client = $base_client->endpoint('auth'); // $base_client = new \JsonRpc\Client(RPC_CONFIG);
// $client = $base_client->endpoint('auth');
$username = explode('|', $username); //
try { // $username = explode('|', $username);
$res = $client->call('notify.text', [ // try {
['user' => $username], // $res = $client->call('notify.text', [
$text, // ['user' => $username],
]); // $text,
} catch (Exception $ex) { // ]);
return null; // } catch (Exception $ex) {
} // var_dump($ex->getMessage());
// return null;
return $res; // }
} //
// return $res;
/** //}
* 对微信群发送文本卡片 //
* ///**
* @param $chat // * 对微信群发送文本卡片
* @param $title // *
* @param $desc // * @param $chat
* @param $button // * @param $title
* @param $url // * @param $desc
* // * @param $button
* @return mixed|null // * @param $url
*/ // *
function chat_card_alert ($chat, $title, $desc, $button, $url) // * @return mixed|null
{ // */
if (env('APP_ENV') == 'local') { //function chat_card_alert ($chat, $title, $desc, $button, $url)
return true; //{
} // if (env('APP_ENV') == 'local') {
// return true;
$base_client = new \JsonRpc\Client(RPC_CONFIG); // }
$client = $base_client->endpoint('auth'); //
// $base_client = new \JsonRpc\Client(RPC_CONFIG);
try { // $client = $base_client->endpoint('auth');
$resp = $client->call('notify.card', [ //
['chat' => $chat], // try {
$title, // $resp = $client->call('notify.card', [
$desc, // ['chat' => $chat],
$button, // $title,
$url, // $desc,
]); // $button,
} catch (Exception $ex) { // $url,
return null; // ]);
} // } catch (Exception $ex) {
// var_dump($ex->getMessage());
return $resp; // return null;
} // }
//
/** // return $resp;
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开 //}
* //
* @param $username ///**
* @param $title // * 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $desc // *
* @param $button // * @param $username
* @param $url // * @param $title
* // * @param $desc
* @return mixed|null // * @param $button
*/ // * @param $url
function user_card_alert ($username, $title, $desc, $button, $url) // *
{ // * @return mixed|null
if (env('APP_ENV') == 'local') { // */
return true; //function user_card_alert ($username, $title, $desc, $button, $url)
} //{
// if (env('APP_ENV') == 'local') {
$base_client = new \JsonRpc\Client(RPC_CONFIG); // return true;
$client = $base_client->endpoint('auth'); // }
//
$username = explode('|', $username); // $base_client = new \JsonRpc\Client(RPC_CONFIG);
try { // $client = $base_client->endpoint('auth');
$resp = $client->call('notify.card', [ //
['user' => $username], // $username = explode('|', $username);
$title, // try {
$desc, // $resp = $client->call('notify.card', [
$button, // ['user' => $username],
$url, // $title,
]); // $desc,
} catch (Exception $ex) { // $button,
return null; // $url,
} // ]);
// } catch (Exception $ex) {
return $resp; // var_dump($ex->getMessage());
} // return null;
// }
/** //
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开 // return $resp;
* //}
* @param $username //
* @param $appid //小程序的appid ///**
* @param $title //标题 // * 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $page //小程序页面路径 // *
* @param $desc //描述 // * @param $username
* @param $items //消息内容键值对最多允许10个item // * @param $appid //小程序的appid
* @param $emphasisFirstItem //是否放大第一个content_item // * @param $title //标题
* // * @param $page //小程序页面路径
* @return mixed|null // * @param $desc //描述
*/ // * @param $items //消息内容键值对最多允许10个item
function user_mp_alert ($username, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) // * @param $emphasisFirstItem //是否放大第一个content_item
{ // *
if (env('APP_ENV') == 'local') { // * @return mixed|null
return true; // */
} //function user_mp_alert ($username, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null)
//{
$base_client = new \JsonRpc\Client(RPC_CONFIG); // if (env('APP_ENV') == 'local') {
$client = $base_client->endpoint('auth'); // return true;
// }
$username = explode('|', $username); //
try { // $base_client = new \JsonRpc\Client(RPC_CONFIG);
$resp = $client->call('notify.mp', [ // $client = $base_client->endpoint('auth');
['user' => $username], //
$appid, // $username = explode('|', $username);
$title, // try {
$page, // $resp = $client->call('notify.mp', [
$desc, // ['user' => $username],
$items, // $appid,
$emphasisFirstItem // $title,
]); // $page,
} catch (Exception $ex) { // $desc,
return null; // $items,
} // $emphasisFirstItem
// ]);
return $resp; // } catch (Exception $ex) {
} // var_dump($ex->getMessage());
// return null;
/** // }
* 对单个或多个用户发送文本卡片多个用户id使用 | 隔开 //
* // return $resp;
* @param $username //}
* @param $appid //小程序的appid //
* @param $title //标题 ///**
* @param $page //小程序页面路径 // * 对单个或多个用户发送文本卡片多个用户id使用 | 隔开
* @param $desc //描述 // *
* @param $items //消息内容键值对最多允许10个item // * @param $username
* @param $emphasisFirstItem //是否放大第一个content_item // * @param $appid //小程序的appid
* // * @param $title //标题
* @return mixed|null // * @param $page //小程序页面路径
*/ // * @param $desc //描述
function tag_mp_alert ($tag, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) // * @param $items //消息内容键值对最多允许10个item
{ // * @param $emphasisFirstItem //是否放大第一个content_item
if (env('APP_ENV') == 'local') { // *
return true; // * @return mixed|null
} // */
//function tag_mp_alert ($tag, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null)
$base_client = new \JsonRpc\Client(RPC_CONFIG); //{
$client = $base_client->endpoint('auth'); // if (env('APP_ENV') == 'local') {
// return true;
try { // }
$resp = $client->call('notify.mp', [ //
['tag' => $tag], // $base_client = new \JsonRpc\Client(RPC_CONFIG);
$appid, // $client = $base_client->endpoint('auth');
$title, //
$page, // try {
$desc, // $resp = $client->call('notify.mp', [
$items, // ['tag' => $tag],
$emphasisFirstItem // $appid,
]); // $title,
} catch (Exception $ex) { // $page,
return null; // $desc,
} // $items,
// $emphasisFirstItem
return $resp; // ]);
} // } catch (Exception $ex) {
// var_dump($ex->getMessage());
// return null;
// }
//
// return $resp;
//}
/** /**
@ -253,89 +259,3 @@ function bot_notify($name, $content)
return []; 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;
}