From 67f81c8d2d3c219f462ad5f73db50922ed077661 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 31 Oct 2020 06:12:36 +0000 Subject: [PATCH 1/4] changed variable --- modules/message.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index ec16c20a41..210cb8490c 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -1,7 +1,7 @@ function message { chats="$1" function check_apitoken { - channelname=$1 + channelname=$1_apitoken access_token=$(config | grep "$channelname" | cut -d "=" -f2) if [[ $access_token == "" ]] || [[ $access_token == "null" ]]; then return 1 @@ -10,8 +10,8 @@ function message { fi } function get_apitoken { - channelname=$1 - access_token=$(config | grep "$channelname" | grep "token" | cut -d "=" -f2) + channelname=$1_apitoken + access_token=$(config | grep "$channelname_" | grep "token" | cut -d "=" -f2) echo "Your API access token is $access_token" return 0 } @@ -27,7 +27,7 @@ function message { done return 1 } - case "$chats" in + case "$chats" in gitter) case "$2" in apitoken) @@ -40,14 +40,15 @@ function message { else log_and_exit1 "Invalid URL" fi - conf_var_update "client_id" "$client_id" - conf_var_update "redirect_url" "$redirect_uri" + conf_var_update "gitter_clientid" "$client_id" + conf_var_update "gitter_redirecturl" "$redirect_uri" echo "Navigate to https://gitter.im/login/oauth/authorize?client_id=$client_id&response_type=code&redirect_uri=$redirect_uri" echo "Click 'Allow' and get the code at the end of the redirect link:" echo "Example:redirect link: http://www.localhost.com/?code=1234567890, code=1234567890" echo "run $BASENAME message gitter authorize <0auth Secret>" else echo "You do not have an authorized access token" + echo "" echo "To get an authorized access token" echo "Navigate to https://developer.gitter.im/apps and signin" echo "Create a new app and provide aplication name and a redirect url where you will be send after authorization" @@ -66,12 +67,12 @@ function message { else code=$3 client_key=$4 - conf_var_update "client_key" "$client_key" - client_id=$(config | grep "$client_id" | cut -d "=" -f2) - redirect_uri=$(config | grep "$redirect_url" | cut -d "=" -f2) + conf_var_update "gitter_clientkey" "$client_key" + client_id=$(config | grep "$gitter_clientid" | cut -d "=" -f2) + redirect_uri=$(config | grep "$gitter_redirecturl" | cut -d "=" -f2) api_info=$(curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" "https://gitter.im/login/oauth/token" -d '{"client_id": "'$client_id'", "client_secret": "'$client_key'", "code": "'$code'", "redirect_uri": "'$redirect_uri'", "grant_type": "authorization_code"}') token_info=$(echo $api_info | python -m json.tool | jq '.access_token' | tr -d '"') - conf_var_update "gitter_access_token" "$token_info" + conf_var_update "gitter_apitoken" "$token_info" echo "Your API access token is $token_info" fi ;; @@ -275,15 +276,15 @@ function message_help { echo echo "You must set your api key at least once every session before sending a message" echo - echo "Sends message to a chat service" + echo "Send message to a chat service" echo echo "Example:" echo echo " $BASENAME message gitter apitoken" - echo " check for API token for gitter" + echo " Checks for API token for gitter" echo echo " $BASENAME message gitter authorize \"1234567890\"" - echo " sets and saves API token" + echo " Sets and saves API token" echo echo " $BASENAME message gitter send treehouses/Lobby \"Hi, you are very awesome\"" echo " Sends a message to a gitter channel" From 2731be87991d2543f771a3dd089949ce84d915c3 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 31 Oct 2020 10:18:01 +0400 Subject: [PATCH 2/4] Update message.sh --- modules/message.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 210cb8490c..3804bdcefc 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -11,7 +11,7 @@ function message { } function get_apitoken { channelname=$1_apitoken - access_token=$(config | grep "$channelname_" | grep "token" | cut -d "=" -f2) + access_token=$(config | grep "$channelname" | grep "token" | cut -d "=" -f2) echo "Your API access token is $access_token" return 0 } From 3d828453d069a635db1ac3834ffed2b1a3e57522 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 31 Oct 2020 10:19:24 +0400 Subject: [PATCH 3/4] Update message.sh --- modules/message.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 3804bdcefc..1200a3acfc 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -281,7 +281,7 @@ function message_help { echo "Example:" echo echo " $BASENAME message gitter apitoken" - echo " Checks for API token for gitter" + echo " Check for API token for gitter" echo echo " $BASENAME message gitter authorize \"1234567890\"" echo " Sets and saves API token" From 09faa64d5041a12b96b9dfd88e1a493eb2be0df3 Mon Sep 17 00:00:00 2001 From: dogi Date: Sat, 7 Nov 2020 00:18:24 -0500 Subject: [PATCH 4/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62b52cd4ee..cd642a74c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.24.81", + "version": "1.24.82", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",