From caf439e0bbeb081877be28b1ab8b7e202cf97e86 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Nov 2020 06:59:23 +0000 Subject: [PATCH 01/15] added read command --- README.md | 2 +- _treehouses | 1 + modules/help.sh | 2 +- modules/message.sh | 44 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f02b3a77b..a3fc1802c 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ resolution sets the screen resolution system [cpu|ram|disk|volt|temperature] display real system informations message gitter sets api/channel info in config file and sends/recieves message - slack sets api/channel info in config file and sends message + slack sets api/channel info in config file and sends/receives messages shutdown [now|in|force] shutdown the system ``` diff --git a/_treehouses b/_treehouses index 1a948d03b..db2b0f7f0 100644 --- a/_treehouses +++ b/_treehouses @@ -237,6 +237,7 @@ treehouses message gitter read treehouses message gitter mark treehouses message slack apitoken treehouses message slack send +treehouses message slack read treehouses networkmode treehouses networkmode info treehouses ntp internet diff --git a/modules/help.sh b/modules/help.sh index de68c2dbc..eceaebde1 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -142,7 +142,7 @@ resolution sets the screen resolution system [cpu|ram|disk|volt|temperature] display real system informations message gitter sets api/channel info in config file and sends/recieves message - slack sets api/channel info in config file and sends message + slack sets api/channel info in config file and sends/receives messages shutdown [now|in|force] shutdown the system EOF echo "$helpdefault" diff --git a/modules/message.sh b/modules/message.sh index ec16c20a4..24bad7a77 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -232,7 +232,7 @@ function message { echo "" echo "To get an authorized access token" echo "Navigate to https://api.slack.com/apps and create an APP. Provide a name for the APP and select the \"Development Slack Workspace (eg : Open Learning Exchange)\" from the drop down list" - echo "Go to \"OAuth & Permission\" under \"features \" and select the scope under \"User Token Scopes\" and add \"chat:write\" for the APP from the drop down list" + echo "Go to \"OAuth & Permission\" under \"features \" and select the scope under \"User Token Scopes\" and add \"chat:write\". \"channel:read\"and for the APP from the drop down list" echo "Then install APP to the workspace and click the allow button to give permissions in the redirected link and then you will get the \"OAuth access token\"" echo "Run $BASENAME message slack apitoken " fi @@ -257,6 +257,45 @@ function message { log_comment_and_exit1 "Error:You do not have an authorized access token" "To get access token, run $BASENAME message slack apitoken" fi ;; + read) + if check_apitoken slack; then + if [[ $3 == "" ]]; then + log_comment_and_exit1 "ERROR: Group information is missing" "usage: $BASENAME message slack read " + fi + channel=$3 + channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) + #last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') + #echo "$last_read" + last_read=1603741036.001400 + history=$(curl -s -F token=$access_token -F unreads=true -F channel=$channel https://slack.com/api/conversations.history) + time=($(echo $history | python -m json.tool | jq '.messages[].ts' | tr -d '"')) + unread_time=() + for i in "${time[@]}"; do + if [[ $last_read == $i ]]; then + break + else + unread_time+=($i) + fi + done + unread_time=($(printf '%s\n' "${unread_time[@]}" | tac | tr '\n' ' ')) + for i in "${unread_time[@]}"; do + msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) + msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') + msg_length=$(echo ${msg_info} | jq '.messages[].text | length') + userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') + name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) + name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') + time_info=$(date -d @$i) + date=$(echo ${time_info} | cut -d " " -f1-3) + year=$(echo ${time_info} | cut -d " " -f6) + send_time=$(echo ${time_info} | cut -d " " -f4) + echo "Date: $date $year" + echo "Time: $send_time" + echo "From: $name" + echo "Message: $msg" + done + fi + ;; *) log_help_and_exit1 "Error: This command does not exist" message esac @@ -303,4 +342,7 @@ function message_help { echo " $BASENAME message slack send \"channel_name or channel ID\" \"Hi, you are very awesome\"" echo " Sends a message to a slack channel using channel name, eg, channel: #channel_name" echo + echo " $BASENAME message slack read \"channel ID\"" + echo " Reads messages from a slack channel using channelID" + echo } From 1822b83e079dc040290049986eade60f4843fe00 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 13 Nov 2020 18:52:14 +0000 Subject: [PATCH 02/15] changes updated --- modules/message.sh | 58 ++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index 24bad7a77..316caba0a 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -1,5 +1,6 @@ function message { chats="$1" + last_read=1603741036.001400 function check_apitoken { channelname=$1 access_token=$(config | grep "$channelname" | cut -d "=" -f2) @@ -262,38 +263,51 @@ function message { if [[ $3 == "" ]]; then log_comment_and_exit1 "ERROR: Group information is missing" "usage: $BASENAME message slack read " fi + function check_channel { + channel_list=$(curl -s -F token=$access_token https://slack.com/api/conversations.list) + channel_list=($(echo $channel_list | python -m json.tool | jq '.channels[].id' | tr -d '"')) + for i in ${channel_list[@]}; do + if [ $i == $1 ]; then + return 0 + else + log_comment_and_exit1 "ERROR: invalid channel id" + fi + done + } channel=$3 + check_channel $3 channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) - #last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') - #echo "$last_read" - last_read=1603741036.001400 - history=$(curl -s -F token=$access_token -F unreads=true -F channel=$channel https://slack.com/api/conversations.history) - time=($(echo $history | python -m json.tool | jq '.messages[].ts' | tr -d '"')) + last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') + channel_history=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.history) + time=($(echo $channel_history | python -m json.tool | jq '.messages[].ts' 2> /dev/null | tr -d '"')) unread_time=() for i in "${time[@]}"; do - if [[ $last_read == $i ]]; then + if [ $last_read == $i ]; then break else unread_time+=($i) fi done unread_time=($(printf '%s\n' "${unread_time[@]}" | tac | tr '\n' ' ')) - for i in "${unread_time[@]}"; do - msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) - msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') - msg_length=$(echo ${msg_info} | jq '.messages[].text | length') - userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') - name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) - name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') - time_info=$(date -d @$i) - date=$(echo ${time_info} | cut -d " " -f1-3) - year=$(echo ${time_info} | cut -d " " -f6) - send_time=$(echo ${time_info} | cut -d " " -f4) - echo "Date: $date $year" - echo "Time: $send_time" - echo "From: $name" - echo "Message: $msg" - done + if [ ${#unread_time[@]} -eq 0 ]; then + echo "You have no unread messages at the moment" + else + for i in "${unread_time[@]}"; do + msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) + msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') + userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') + name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) + name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') + time_info=$(date -d @$i) + date=$(echo ${time_info} | cut -d " " -f1-3) + year=$(echo ${time_info} | cut -d " " -f6) + send_time=$(echo ${time_info} | cut -d " " -f4) + echo "Date: $date $year" + echo "Time: $send_time" + echo "From: $name" + echo "Message: $msg" + done + fi fi ;; *) From 45998e9fc6b1b85f02cd014598bfacf8098fc388 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 14 Nov 2020 08:47:55 +0400 Subject: [PATCH 03/15] 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 316caba0a..5c520076c 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -266,7 +266,7 @@ function message { function check_channel { channel_list=$(curl -s -F token=$access_token https://slack.com/api/conversations.list) channel_list=($(echo $channel_list | python -m json.tool | jq '.channels[].id' | tr -d '"')) - for i in ${channel_list[@]}; do + for i in "${channel_list[@]}"; do if [ $i == $1 ]; then return 0 else From e8e5ce5f28f9302483c86d2c7a95a639067f4731 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 14 Nov 2020 09:03:19 +0400 Subject: [PATCH 04/15] Update message.sh --- modules/message.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index 5c520076c..f431891bc 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -259,6 +259,7 @@ function message { fi ;; read) + channel=$3 if check_apitoken slack; then if [[ $3 == "" ]]; then log_comment_and_exit1 "ERROR: Group information is missing" "usage: $BASENAME message slack read " @@ -273,8 +274,7 @@ function message { log_comment_and_exit1 "ERROR: invalid channel id" fi done - } - channel=$3 + } check_channel $3 channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') From a60d67ce8ae2844ea38ce22a83f4bc050fa97734 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 14 Nov 2020 05:07:36 +0000 Subject: [PATCH 05/15] removed spaces --- modules/message.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index f431891bc..53b87c781 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -246,7 +246,6 @@ function message { fi shift; shift; shift; message=$* - echo "$message" message_response=$(curl -s -X POST -H 'Authorization: Bearer '$access_token'' -H 'Content-type: application/json' --data "{\"channel\":\"$channel\",\"text\":\"$message\"}" https://slack.com/api/chat.postMessage) message_response=$(echo $message_response | python -m json.tool | jq '.ok' | tr -d '"') if [[ $message_response == "true" ]]; then @@ -274,7 +273,7 @@ function message { log_comment_and_exit1 "ERROR: invalid channel id" fi done - } + } check_channel $3 channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') From fc18210256bd68afa4786f924e3c2bb61286bf48 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 14 Nov 2020 06:39:01 +0000 Subject: [PATCH 06/15] bug fixed --- modules/message.sh | 84 ++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/modules/message.sh b/modules/message.sh index 53b87c781..196389ed1 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -233,7 +233,7 @@ function message { echo "" echo "To get an authorized access token" echo "Navigate to https://api.slack.com/apps and create an APP. Provide a name for the APP and select the \"Development Slack Workspace (eg : Open Learning Exchange)\" from the drop down list" - echo "Go to \"OAuth & Permission\" under \"features \" and select the scope under \"User Token Scopes\" and add \"chat:write\". \"channel:read\"and for the APP from the drop down list" + echo "Go to \"OAuth & Permission\" under \"features \" and select the scope under \"User Token Scopes\" and add \"chat:write\", \"channel:read\", \"channel:history\" and \"group:read\" for the APP from the drop down list" echo "Then install APP to the workspace and click the allow button to give permissions in the redirected link and then you will get the \"OAuth access token\"" echo "Run $BASENAME message slack apitoken " fi @@ -259,53 +259,55 @@ function message { ;; read) channel=$3 + function check_channel { + channel_list=$(curl -s -F token=$access_token https://slack.com/api/conversations.list) + channel_list=($(echo $channel_list | python -m json.tool | jq '.channels[].id' | tr -d '"')) + for i in "${channel_list[@]}"; do + if [[ $i == $1 ]]; then + return 0 + break + fi + done + return 1 + } if check_apitoken slack; then - if [[ $3 == "" ]]; then + if [[ $channel == "" ]]; then log_comment_and_exit1 "ERROR: Group information is missing" "usage: $BASENAME message slack read " - fi - function check_channel { - channel_list=$(curl -s -F token=$access_token https://slack.com/api/conversations.list) - channel_list=($(echo $channel_list | python -m json.tool | jq '.channels[].id' | tr -d '"')) - for i in "${channel_list[@]}"; do - if [ $i == $1 ]; then - return 0 + elif ! check_channel $channel; then + log_and_exit1 "invalid channel ID" + else + channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) + last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') + channel_history=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.history) + time=($(echo $channel_history | python -m json.tool | jq '.messages[].ts' 2> /dev/null | tr -d '"')) + unread_time=() + for i in "${time[@]}"; do + if [ $last_read == $i ]; then + break else - log_comment_and_exit1 "ERROR: invalid channel id" + unread_time+=($i) fi done - } - check_channel $3 - channel_info=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.info) - last_read=$(echo $channel_info | python -m json.tool | jq '.channel.last_read' | tr -d '"') - channel_history=$(curl -s -F token=$access_token -F channel=$channel https://slack.com/api/conversations.history) - time=($(echo $channel_history | python -m json.tool | jq '.messages[].ts' 2> /dev/null | tr -d '"')) - unread_time=() - for i in "${time[@]}"; do - if [ $last_read == $i ]; then - break + unread_time=($(printf '%s\n' "${unread_time[@]}" | tac | tr '\n' ' ')) + if [ ${#unread_time[@]} -eq 0 ]; then + echo "You have no unread messages at the moment" else - unread_time+=($i) + for i in "${unread_time[@]}"; do + msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) + msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') + userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') + name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) + name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') + time_info=$(date -d @$i) + date=$(echo ${time_info} | cut -d " " -f1-3) + year=$(echo ${time_info} | cut -d " " -f6) + send_time=$(echo ${time_info} | cut -d " " -f4) + echo "Date: $date $year" + echo "Time: $send_time" + echo "From: $name" + echo "Message: $msg" + done fi - done - unread_time=($(printf '%s\n' "${unread_time[@]}" | tac | tr '\n' ' ')) - if [ ${#unread_time[@]} -eq 0 ]; then - echo "You have no unread messages at the moment" - else - for i in "${unread_time[@]}"; do - msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) - msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') - userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') - name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) - name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') - time_info=$(date -d @$i) - date=$(echo ${time_info} | cut -d " " -f1-3) - year=$(echo ${time_info} | cut -d " " -f6) - send_time=$(echo ${time_info} | cut -d " " -f4) - echo "Date: $date $year" - echo "Time: $send_time" - echo "From: $name" - echo "Message: $msg" - done fi fi ;; From a25be2ed2a542fb8cbeeef74ddc4ec6a33c5b176 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 14 Nov 2020 10:42:27 +0400 Subject: [PATCH 07/15] 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 196389ed1..60852dd37 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -263,7 +263,7 @@ function message { channel_list=$(curl -s -F token=$access_token https://slack.com/api/conversations.list) channel_list=($(echo $channel_list | python -m json.tool | jq '.channels[].id' | tr -d '"')) for i in "${channel_list[@]}"; do - if [[ $i == $1 ]]; then + if [ $i == $1 ]; then return 0 break fi From c7c6eb01e313c540940a0be3e54c685ac4870502 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Sat, 14 Nov 2020 12:16:56 +0400 Subject: [PATCH 08/15] Update message.sh --- modules/message.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/message.sh b/modules/message.sh index 60852dd37..9f3575b53 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -298,6 +298,7 @@ function message { userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') + curl -s -F token=$access_token -F channel=$channel -F ts=$i https://slack.com/api/conversations.mark > "$LOGFILE" time_info=$(date -d @$i) date=$(echo ${time_info} | cut -d " " -f1-3) year=$(echo ${time_info} | cut -d " " -f6) From 782237509344566fc1b6843a9bb5964ca6327754 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Nov 2020 17:19:04 +0000 Subject: [PATCH 09/15] updated --- modules/message.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 9f3575b53..9d1113d72 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -297,7 +297,7 @@ function message { msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) - name=$(echo $name_info | python -m json.tool | jq '.user.real_name' | tr -d '"') + name=$(echo $name_info | python -m json.tool | jq '.user.profile.real_name' | tr -d '"') curl -s -F token=$access_token -F channel=$channel -F ts=$i https://slack.com/api/conversations.mark > "$LOGFILE" time_info=$(date -d @$i) date=$(echo ${time_info} | cut -d " " -f1-3) From addb4ed808779bdc50f3393bbe141805aee40b51 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Nov 2020 05:12:34 +0000 Subject: [PATCH 10/15] scopes changed --- modules/message.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 9d1113d72..cb15f690f 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -233,7 +233,7 @@ function message { echo "" echo "To get an authorized access token" echo "Navigate to https://api.slack.com/apps and create an APP. Provide a name for the APP and select the \"Development Slack Workspace (eg : Open Learning Exchange)\" from the drop down list" - echo "Go to \"OAuth & Permission\" under \"features \" and select the scope under \"User Token Scopes\" and add \"chat:write\", \"channel:read\", \"channel:history\" and \"group:read\" for the APP from the drop down list" + echo "Go to \"OAuth & Permission\", select the scope from \"User Token Scopes\" and add \"chat:write\", \"channel:read\", \"channel:history\", \"group:read\" and \"users.read\" for the APP from the drop down list" echo "Then install APP to the workspace and click the allow button to give permissions in the redirected link and then you will get the \"OAuth access token\"" echo "Run $BASENAME message slack apitoken " fi From 8df188b77a8391e824276801b293bcb4c414584c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Nov 2020 05:47:26 +0000 Subject: [PATCH 11/15] updated --- modules/message.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 3d6869be7..95ada4163 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -308,7 +308,6 @@ function message { userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) name=$(echo $name_info | python -m json.tool | jq '.user.profile.real_name' | tr -d '"') - curl -s -F token=$access_token -F channel=$channel -F ts=$i https://slack.com/api/conversations.mark > "$LOGFILE" time_info=$(date -d @$i) date=$(echo ${time_info} | cut -d " " -f1-3) year=$(echo ${time_info} | cut -d " " -f6) From 858b3b9983c26bd51b89aa8741bf143e74bad059 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Nov 2020 06:02:37 +0000 Subject: [PATCH 12/15] updated --- README.md | 3 ++- modules/help.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index abf00d769..c6b189d37 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,8 @@ resolution sets the screen resolution system [cpu|ram|disk|volt|temperature] display real system informations message gitter sets api/channel info in config file and sends/recieves message - slack sets api/channel info in config file and sends message + slack sets api/channel info in config file, shows channels and sends message + read new messages shutdown [now|in|force] shutdown the system ``` diff --git a/modules/help.sh b/modules/help.sh index 4f0d5af66..b0132801a 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -142,7 +142,8 @@ resolution sets the screen resolution system [cpu|ram|disk|volt|temperature] display real system informations message gitter sets api/channel info in config file and sends/recieves message - slack sets api/channel info in config file and sends message + slack sets api/channel info in config file, shows channels and sends message + read new messages shutdown [now|in|force] shutdown the system EOF echo "$helpdefault" From db4afdf82b73b5be870eb52e401533bda755ba95 Mon Sep 17 00:00:00 2001 From: Neethu-Mohan Date: Thu, 19 Nov 2020 10:07:45 +0400 Subject: [PATCH 13/15] Update help.sh --- modules/help.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/help.sh b/modules/help.sh index b0132801a..171936c40 100644 --- a/modules/help.sh +++ b/modules/help.sh @@ -143,7 +143,7 @@ system [cpu|ram|disk|volt|temperature] display real system informations message gitter sets api/channel info in config file and sends/recieves message slack sets api/channel info in config file, shows channels and sends message - read new messages + reads new messages shutdown [now|in|force] shutdown the system EOF echo "$helpdefault" From d9b95806f67cbb3b83ec8ff53ff939a02518fffa Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Nov 2020 06:55:31 +0000 Subject: [PATCH 14/15] added mark function also --- modules/message.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/message.sh b/modules/message.sh index 95ada4163..9fb3e014c 100644 --- a/modules/message.sh +++ b/modules/message.sh @@ -1,6 +1,5 @@ function message { chats="$1" - last_read=1603741036.001400 function check_apitoken { channelname=$1_apitoken access_token=$(config | grep "$channelname" | cut -d "=" -f2) @@ -304,10 +303,12 @@ function message { else for i in "${unread_time[@]}"; do msg_info=$(curl -s -F token=$access_token -F channel=$channel -F latest=$i -F limit=1 -F inclusive=true https://slack.com/api/conversations.history) + curl -s -F token=$access_token -F channel=$channel -F ts=$i https://slack.com/api/conversations.mark > "$LOGFILE" msg=$(echo $msg_info | python -m json.tool | jq '.messages[].text' | tr -d '"') userid=$(echo $msg_info | python -m json.tool | jq '.messages[].user' | tr -d '"') name_info=$(curl -s -F token=$access_token -F user=$userid -F latest=$i https://slack.com/api/users.info) name=$(echo $name_info | python -m json.tool | jq '.user.profile.real_name' | tr -d '"') + curl -s -F token=$access_token -F channel=$channel -F ts=$i https://slack.com/api/conversations.mark > "$LOGFILE" time_info=$(date -d @$i) date=$(echo ${time_info} | cut -d " " -f1-3) year=$(echo ${time_info} | cut -d " " -f6) From a018e701fd9c6ca171db26da8a734a66458e8a58 Mon Sep 17 00:00:00 2001 From: dogi Date: Thu, 19 Nov 2020 02:58:40 -0500 Subject: [PATCH 15/15] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b0e0e72f1..5b41c48f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.24.83", + "version": "1.24.84", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",