From 4278d5a2cbef86ff3cd9adf290639a01d5235e61 Mon Sep 17 00:00:00 2001 From: dogi Date: Thu, 2 Mar 2023 04:00:30 -0500 Subject: [PATCH] =?UTF-8?q?`treehouses=20feedback`=20based=20on=20discord?= =?UTF-8?q?=20=E2=80=8D(fixes=20#2280)=20(#2281)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli.sh | 9 +++++---- modules/feedback.sh | 8 +++++--- package.json | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cli.sh b/cli.sh index 590d69d26d..2cdffad705 100755 --- a/cli.sh +++ b/cli.sh @@ -12,15 +12,16 @@ WIFICOUNTRY="US" LOGFILE=/dev/null LOG=0 BLOCKER=0 -token="$(echo YWRmYWI1NmIyZjEwYjg1Zjk0ZGIyNWYxOGU1MWE0YjQ2NWRiZDY3MAo= | openssl enc -d -pbkdf2 -a -salt -pass 'pass:I&l_v^diS%%repo')" -channel="https://api.gitter.im/v1/rooms/5ba5af3cd73408ce4fa8fcfb/chatMessages" +chat="$(echo aHR0cHM6Ly9kaXNjb3JkLmNvbS9hcGkvd2ViaG9va3MvCg== | openssl enc -d -pbkdf2 -a -salt -pass 'pass:I&l_v^diS%%repo')" +hook="$(echo MTA3OTk4MTM3MjU2MDY1NDM3Ni9nekVDbURXNXRmWEV3ZFlEZ3RYdF9mcmxMWl9Nbmo1QTYtX01iQkdLWXV0OHdfMTlod3VqcGc1X21lMmlkdXdkdUZfbAo= | openssl enc -d -pbkdf2 -a -salt -pass 'pass:I&l_v^diS%%repo')" RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # set on ../templates/network/tor_report.sh -if [ ! -z "$gitter_channel" ]; then - channel="$gitter_channel" +if [ ! -z "$discord_channel" ]; then + chat="$discord_channel" + hook="" fi if [[ -f "$CONFIGFILE" ]]; then diff --git a/modules/feedback.sh b/modules/feedback.sh index 7b9397ce06..04d9578afb 100644 --- a/modules/feedback.sh +++ b/modules/feedback.sh @@ -8,12 +8,14 @@ function feedback { if [[ ! $ip_address =~ $ip6_regex ]] && [[ ! $ip_address =~ $ip4_regex ]]; then ip_address="invalid address" fi + message="${message//\`/}" + message="${message// /\\b}" if [ "$(detectrpi)" != "nonrpi" ]; then - body="{\"text\":\"\`$(hostname)\` \`$ip_address\` \`$(version)\` \`$(detectrpi)\` \`$(cat /boot/version.txt) \`:\\n$message\"}" + body="{\"content\":\"**$(hostname)**\b$ip_address\b$(version)\b$(detectrpi)\b$(cat /boot/version.txt)\n$message\"}" else - body="{\"text\":\"\`$(hostname)\` \`$ip_address\` \`$(version)\` \`$(detect | sed "s/ /\` \`/1")\`:\\n$message\"}" + body="{\"content\":\"**$(hostname)**\b$ip_address\b$(version)\b$(detect | sed "s/ /\\\b/1")\n$message\"}" fi - curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer $token" "$channel" -d "$body"> "$LOGFILE" + curl -s -X POST -H "Content-Type:application/json" "$chat$hook" -d $body> "$LOGFILE" echo "Thanks for the feedback!" else log_and_exit1 "No feedback was submitted." diff --git a/package.json b/package.json index 5c4c5d4b53..db2431c7b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.26.9", + "version": "1.26.10", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",