Can now save and load posts.
This commit is contained in:
parent
8f898d7233
commit
7fe2645f58
|
@ -23,23 +23,34 @@ comments=".[] | $showcomment"
|
|||
get(){ curl -s "$baseurl$1?${*:3}" | jq "$2"; }
|
||||
getauth(){ get "$1" "$2" "auth=$TOKE&${*:3}"; }
|
||||
post(){ curl -s "$baseurl$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; }
|
||||
# I'm just gonna clone this thing rather than try to palm the -X PUT into post. I can fix it later.
|
||||
put(){ curl -sX PUT "$baseurl$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; }
|
||||
|
||||
#Utils
|
||||
getbody(){ a=$(cat); body=${a//\"/\\\"}; }
|
||||
|
||||
actions="notifs notifs2 comments freepost shitpost follow unfollow following deref whoami login"
|
||||
#Endpoints.
|
||||
#Lurkan
|
||||
notifs(){ getauth "user/replies" ".replies | $comments"; }
|
||||
notifs2(){ getauth "user/mention"; }
|
||||
following(){ getauth "post/list" ".posts | $comments" "type_=Subscribed"; }
|
||||
comments(){ getauth "post" "(.post_view | $showcomment), (.comments | reverse | $comments)" "id=$1"; }
|
||||
#Postan
|
||||
freepost(){ getbody; post "post" "{\"community_id\":$1,\"name\":\"$2\",\"body\":\"$body\"}"; }
|
||||
shitpost(){ getbody; postid=$1; parentid=$2; shift 2; post "comment" "{\"post_id\":$postid,\"parent_id\":$parentid,\"content\":\"$body\"}"; }
|
||||
shitpost(){ getbody; postid=$1; parentid=$2; post "comment" "{\"post_id\":$postid,\"parent_id\":$parentid,\"content\":\"$body\"}"; }
|
||||
#Post hoardan
|
||||
save(){ put "post/save" "{\"post_id\":$1,\"save\":true}"; }
|
||||
unsave(){ put "post/save" "{\"post_id\":$1,\"save\":false}"; }
|
||||
load(){ getauth "post/list" ".posts | $comments" "type_=All&saved_only=true"; }
|
||||
#Community hoardan
|
||||
follow(){ post "community/follow" "{\"community_id\":$1,\"follow\":true}"; }
|
||||
unfollow(){ post "community/follow" "{\"community_id\":$1,\"follow\":false}"; }
|
||||
following(){ getauth "post/list" ".posts | $comments" "type_=Subscribed"; }
|
||||
deref(){ getauth "resolve_object" "" "q=$*"; }
|
||||
#Account hoardan
|
||||
whoami(){ echo $INSTANCE $TOKE; }
|
||||
login(){ post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}"; }
|
||||
#Misc
|
||||
deref(){ getauth "resolve_object" "" "q=$*"; }
|
||||
|
||||
while getopts "a:h" o;do case "${o}" in
|
||||
a) INSTANCE=${insts[$OPTARG]}; TOKE=${tokes[$OPTARG]};;
|
||||
|
|
Loading…
Reference in New Issue
Block a user