From 6c089431b870da3f6ceaa7d733783773b3f26507 Mon Sep 17 00:00:00 2001 From: rjpadilla Date: Thu, 25 Mar 2021 07:10:15 +0300 Subject: [PATCH 1/2] wake me up I Cant Wake up SAVE ME --- modules/message.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/message.sh b/modules/message.sh index 62f742250c..4fd4bd22df 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -509,6 +509,45 @@ function message { echo "you have successfully authorized and your access token is $access_token " fi ;; + webhook) + webhook_url=$3 + declare -A discordVariables + discordVariables[botname]="jq .name" + discordVariables[webhookid]="jq .id" + discordVariables[webhooktoken]="jq .token" + discordVariables[server]="jq .guild_id" + discordVariables[channel]="jq .channel_id" + getinfo=$(curl -s -X GET "$webhook_url") + + #"$(echo "$getinfo" | ${discordVariables[$key]} )" + #"discord_${discordVariables[server]}_${discordVariables[channel]}_${key}" + + for key in "${!discordVariables[@]}"; do + if [ "$key" == "botname" ] ; then + discordVariables[$key]=$(echo "$getinfo" | ${discordVariables[$key]} ) + else + discordVariables[$key]=$(echo "$getinfo" | ${discordVariables[$key]} | sed 's/\"//g' ) + fi + done + + for key in "${!discordVariables[@]}"; do + config add "discord_${discordVariables[server]}_${discordVariables[channel]}_${key}" "${discordVariables[$key]}" + done + + echo "Your webhook url is $webhook_url" + ;; + send) + shift; shift; + message=$* + webhookid=$(config | grep "webhookid" | cut -d "=" -f2) + webhooktoken=$(config | grep "webhooktoken" | cut -d "=" -f2) + message_response=$(curl -s -X POST -H "Content-Type: application/json" -d "{\"content\": \"$message\"}" "https://discord.com/api/webhooks/${webhookid}/${webhooktoken}") + if $message_response ; then + echo "message successfully delivered to Discord" + else + log_comment_and_exit1 "ERROR: message not delivered" + fi + ;; *) log_help_and_exit1 "Error: This command does not exist" message esac From d0b09c61fd9c822d7f8befd3711f3d0baa1b7c1a Mon Sep 17 00:00:00 2001 From: rjpadilla Date: Thu, 25 Mar 2021 07:10:47 +0300 Subject: [PATCH 2/2] only dreams --- modules/message.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index 4fd4bd22df..a84faf2f19 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -519,9 +519,6 @@ function message { discordVariables[channel]="jq .channel_id" getinfo=$(curl -s -X GET "$webhook_url") - #"$(echo "$getinfo" | ${discordVariables[$key]} )" - #"discord_${discordVariables[server]}_${discordVariables[channel]}_${key}" - for key in "${!discordVariables[@]}"; do if [ "$key" == "botname" ] ; then discordVariables[$key]=$(echo "$getinfo" | ${discordVariables[$key]} )