Skip to content

Commit

Permalink
treehouses feedback based on discord ‍(fixes #2280) (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Mar 2, 2023
1 parent f750a7c commit 4278d5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions modules/feedback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 4278d5a

Please sign in to comment.