Update webhooktool.php

This commit is contained in:
Namhyeon Go 2019-05-25 16:18:25 +09:00 committed by GitHub
parent 2559c9097a
commit c85de7f257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,10 +10,11 @@
* * `Slack` is trademark of Slack Technologies Inc. * * `Slack` is trademark of Slack Technologies Inc.
*/ */
if(check_function_exists("send_web_hook")) { 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, "");
$username = get_value_in_array("username", $options, "ReasonableFramework Bot");
switch($networkid) { switch($networkid) {
case "nateon": case "nateon":
@ -34,6 +35,7 @@ if(check_function_exists("send_web_hook")) {
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")) { if(loadHelper("webpagetool")) {
$response = get_web_json($request_url, "jsondata", array( $response = get_web_json($request_url, "jsondata", array(
"headers" => array( "headers" => array(
@ -41,7 +43,7 @@ if(check_function_exists("send_web_hook")) {
), ),
"data" => array( "data" => array(
"content" => $message, "content" => $message,
"username" => get_value_in_array("username", $options, "anonymous"), "username" => $username,
), ),
)); ));
} }
@ -56,7 +58,7 @@ if(check_function_exists("send_web_hook")) {
), ),
"data" => array( "data" => array(
"channel" => sprintf("#%s", get_value_in_array("channel", $options, "general")), "channel" => sprintf("#%s", get_value_in_array("channel", $options, "general")),
"username" => get_value_in_array("username", $options, "anonymous"), "username" => $username,
"text" => $message, "text" => $message,
"icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")), "icon_emoji" => sprintf(":%s:", get_value_in_array("emoji", $options, "ghost")),
), ),