Update webhooktool.php
This commit is contained in:
parent
85a6808efc
commit
d96d349d89
|
|
@ -5,61 +5,66 @@
|
||||||
* @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()) {
|
||||||
|
$response = false;
|
||||||
|
$id = get_value_in_array("id", $options, "");
|
||||||
|
|
||||||
function send_web_hook($message, $networkid, $options=array()) {
|
switch($networkid) {
|
||||||
$response = false;
|
case "nateon":
|
||||||
$id = get_value_in_array("id", $options, "");
|
$request_url = sprintf("https://teamroom.nate.com/api/webhook/%s", $id);
|
||||||
|
if(loadHelper("webpagetool")) {
|
||||||
|
$response = get_web_page($request_url, "post", array(
|
||||||
|
"headers" => array(
|
||||||
|
"Content-Type" => "application/x-www-form-urlencoded",
|
||||||
|
),
|
||||||
|
"data" => array(
|
||||||
|
"content" => urlencode($message),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
switch($networkid) {
|
|
||||||
case "nateon":
|
|
||||||
$request_url = sprintf("https://teamroom.nate.com/api/webhook/%s", $id);
|
|
||||||
if(loadHelper("webpagetool")) {
|
|
||||||
$response = get_web_page($request_url, "post", array(
|
|
||||||
"headers" => array(
|
|
||||||
"Content-Type" => "application/x-www-form-urlencoded",
|
|
||||||
),
|
|
||||||
"data" => array(
|
|
||||||
"content" => urlencode($message),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "discord":
|
break;
|
||||||
$request_url = sprintf("https://discordapp.com/api/webhooks/%s", $id);
|
|
||||||
$response = get_web_json($request_url, "jsondata", array(
|
case "discord":
|
||||||
"headers" => array(
|
$request_url = sprintf("https://discordapp.com/api/webhooks/%s", $id);
|
||||||
"Content-Type" => "application/json",
|
if(loadHelper("webpagetool")) {
|
||||||
),
|
$response = get_web_json($request_url, "jsondata", array(
|
||||||
"data" => array(
|
"headers" => array(
|
||||||
"content" => $message,
|
"Content-Type" => "application/json",
|
||||||
"username" => get_value_in_array("username", $options, "anonymous"),
|
),
|
||||||
),
|
"data" => array(
|
||||||
));
|
"content" => $message,
|
||||||
break;
|
"username" => get_value_in_array("username", $options, "anonymous"),
|
||||||
|
),
|
||||||
case "slack":
|
));
|
||||||
$request_url = sprintf("https://hooks.slack.com/services/%s", $id);
|
}
|
||||||
$response = get_web_json($request_url, "jsondata", array(
|
break;
|
||||||
"headers" => array(
|
|
||||||
"Content-Type" => "application/json",
|
case "slack":
|
||||||
),
|
$request_url = sprintf("https://hooks.slack.com/services/%s", $id);
|
||||||
"data" => array(
|
if(loadHelper("webpagetool")) {
|
||||||
"channel" => sprintf("#%s", get_value_in_array("channel", $options, "general")),
|
$response = get_web_json($request_url, "jsondata", array(
|
||||||
"username" => get_value_in_array("username", $options, "anonymous"),
|
"headers" => array(
|
||||||
"text" => $message,
|
"Content-Type" => "application/json",
|
||||||
"icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")),
|
),
|
||||||
),
|
"data" => array(
|
||||||
));
|
"channel" => sprintf("#%s", get_value_in_array("channel", $options, "general")),
|
||||||
break;
|
"username" => get_value_in_array("username", $options, "anonymous"),
|
||||||
|
"text" => $message,
|
||||||
|
"icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user