diff options
Diffstat (limited to 'util/shred')
-rwxr-xr-x | util/shred/FriendicaOAuth.sh | 20 | ||||
-rwxr-xr-x | util/shred/shred | 35 |
2 files changed, 40 insertions, 15 deletions
diff --git a/util/shred/FriendicaOAuth.sh b/util/shred/FriendicaOAuth.sh index 67f64b6eb..4055e44a9 100755 --- a/util/shred/FriendicaOAuth.sh +++ b/util/shred/FriendicaOAuth.sh @@ -162,7 +162,7 @@ FO_statuses_home_timeline () { $(OAuth_param 'screen_name' $screen_name) $(OAuth_param 'count' $count) ) -g + local auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'GET' "$F_STATUSES_HOME_TIMELINE.$format" ${params[@]}) convscreen=$(OAuth_PE "$screen_name"); @@ -171,3 +171,21 @@ g return $FO_rval } + +FO_command () { + local command="$1" + + local params=( + $(OAuth_param 'screen_name' $screen_name) + $(OAuth_param 'count' $count) + ) + + + local auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'GET' "${redmatrix_url}/api/${command}.json" ${params[@]}) + + convscreen=$(OAuth_PE "$screen_name"); + FO_ret=$(curl -s --get "${redmatrix_url}/api/${command}.json" --data "screen_name=${convscreen}&count=${count}" --header "${auth_header}") + FO_rval=$? + + return $FO_rval +} diff --git a/util/shred/shred b/util/shred/shred index 2e463ac6d..c46efa435 100755 --- a/util/shred/shred +++ b/util/shred/shred @@ -22,18 +22,6 @@ FCLI_RC="$HOME/.shred.rc" -# Source Config -[[ -f "$FCLI_RC" ]] && . "$FCLI_RC" || show_config_help 1 - -# Source FriendicaOAuth.sh -OAuth_sh=$(which FriendicaOAuth.sh) -(( $? != 0 )) && echo 'Unable to locate FriendicaOAuth.sh! Make sure it is in searching PATH.' && exit 1 -source "$OAuth_sh" - -# Source JSON.sh -JSON_sh=$(which JSON.sh) -(( $? != 0 )) && echo 'Unable to locate JSON.sh! Make sure it is in searching PATH.' && exit 1 -source "$JSON_sh" usage () { @@ -121,6 +109,21 @@ js () { load_config () { + # Source Config + [[ -f "$FCLI_RC" ]] && . "$FCLI_RC" || show_config_help 1 + + + # Source FriendicaOAuth.sh + OAuth_sh=$(which FriendicaOAuth.sh) + (( $? != 0 )) && echo 'Unable to locate FriendicaOAuth.sh! Make sure it is in searching PATH.' && exit 1 + source "$OAuth_sh" + + # Source JSON.sh + JSON_sh=$(which JSON.sh) + (( $? != 0 )) && echo 'Unable to locate JSON.sh! Make sure it is in searching PATH.' && exit 1 + source "$JSON_sh" + + [[ "$oauth_consumer_key" == "" ]] && show_config_help 1 [[ "$oauth_consumer_secret" == "" ]] && show_config_help 1 @@ -149,7 +152,7 @@ main () { fcli_in_reply_to_status_id= fcli_file= fcli_help_flag= - while getopts "c:s:r:f:h" name + while getopts "C:c:s:r:f:h" name do case $name in c) fcli_command="$OPTARG";; @@ -205,7 +208,11 @@ main () { return $FO_rval ;; *) - usage 1 + FO_command $fcli_command + JS_Parsed=$(echo "$FO_ret" | tokenize | parse) + echo "$JS_Parsed" + return $FO_rval + ;; esac return 0 |