Update webhooktool.php

This commit is contained in:
Namhyeon Go 2019-05-04 16:00:29 +09:00 committed by GitHub
parent 85a6808efc
commit d96d349d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,13 +5,13 @@
* @author Go Namhyeon <gnh1201@gmail.com> * @author Go Namhyeon <gnh1201@gmail.com>
* @brief WebhookTools * @brief WebhookTools
* @trademark * @trademark
* * `NateOn` is trademark of SK Communications Co Ltd, or SK planet Co Ltd, or other SK internet business * * `NateOn` is trademark of SK Communications Co Ltd., SK Planet Co Ltd., or other SK businesses.
* * `Discord' is trademark of Discord Inc. (Originally Hammer And Chisel) * * `Discord' is trademark of Discord Inc. (Originally Hammer And Chisel)
* * `Slack` is trademark of Slack Technologies Inc. * * `Slack` is trademark of Slack Technologies Inc.
*/ */
if(check_function_exists("send_web_hook")) {
function send_web_hook($message, $networkid, $options=array()) { function send_web_hook($message, $networkid, $options=array()) {
$response = false; $response = false;
$id = get_value_in_array("id", $options, ""); $id = get_value_in_array("id", $options, "");
@ -34,6 +34,7 @@ function send_web_hook($message, $networkid, $options=array()) {
case "discord": case "discord":
$request_url = sprintf("https://discordapp.com/api/webhooks/%s", $id); $request_url = sprintf("https://discordapp.com/api/webhooks/%s", $id);
if(loadHelper("webpagetool")) {
$response = get_web_json($request_url, "jsondata", array( $response = get_web_json($request_url, "jsondata", array(
"headers" => array( "headers" => array(
"Content-Type" => "application/json", "Content-Type" => "application/json",
@ -43,10 +44,12 @@ function send_web_hook($message, $networkid, $options=array()) {
"username" => get_value_in_array("username", $options, "anonymous"), "username" => get_value_in_array("username", $options, "anonymous"),
), ),
)); ));
}
break; break;
case "slack": case "slack":
$request_url = sprintf("https://hooks.slack.com/services/%s", $id); $request_url = sprintf("https://hooks.slack.com/services/%s", $id);
if(loadHelper("webpagetool")) {
$response = get_web_json($request_url, "jsondata", array( $response = get_web_json($request_url, "jsondata", array(
"headers" => array( "headers" => array(
"Content-Type" => "application/json", "Content-Type" => "application/json",
@ -58,8 +61,10 @@ function send_web_hook($message, $networkid, $options=array()) {
"icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")), "icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")),
), ),
)); ));
}
break; break;
} }
return $response; return $response;
}
} }