MORE refactor
This commit is contained in:
parent
7a94bcd2bf
commit
c6a7ceb005
|
@ -1,9 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
source ./api.sh
|
||||
source ./commands.sh
|
||||
source ./commands/commands.sh
|
||||
source ./pretty.sh
|
||||
source ./creds.sh
|
||||
source ./utils.sh
|
||||
|
||||
while getopts "a:hv" o;do case "${o}" in
|
||||
a) INSTANCE=${insts[$OPTARG]}; TOKE=${tokes[$OPTARG]};;
|
||||
|
|
23
commands.sh
23
commands.sh
|
@ -1,23 +0,0 @@
|
|||
actions="notifs notifs2 comments freepost shitpost follow unfollow home deref whoami login"
|
||||
#Endpoints.
|
||||
#Lurkan
|
||||
notifs(){ getauth "user/replies" ".replies | reverse | $notifs"; }
|
||||
notifs2(){ getauth "user/mention" ".mentions | reverse | $notifs"; }
|
||||
following(){ echo "use <home> instead"; } # Maybe this will help.
|
||||
home(){ getauth "post/list" ".posts | $posts" "type_=Subscribed"; }
|
||||
comments(){ getauth "post" "(.post_view | $showpost), (.comments | reverse | $comments)" "id=$1"; }
|
||||
#Postan
|
||||
freepost(){ getbody; post "post" "{\"community_id\":$1,\"name\":\"${*:2}\",\"body\":\"$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 | .[] | $postsummary" "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}"; }
|
||||
#Account hoardan
|
||||
whoami(){ echo $INSTANCE $TOKE; }
|
||||
login(){ post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}"; }
|
||||
#Misc
|
||||
deref(){ getauth "resolve_object" "" "q=$*"; }
|
3
commands/accounts.sh
Normal file
3
commands/accounts.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#Account hoardan
|
||||
whoami(){ echo $INSTANCE $TOKE; }
|
||||
login(){ post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}"; }
|
8
commands/commands.sh
Normal file
8
commands/commands.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
actions="notifs notifs2 comments freepost shitpost follow unfollow home deref whoami login"
|
||||
#Endpoints in other files mostly.
|
||||
source commands/accounts.sh
|
||||
source commands/communities.sh
|
||||
source commands/lurking.sh
|
||||
source commands/posts.sh
|
||||
#Misc
|
||||
deref(){ getauth "resolve_object" "" "q=$*"; }
|
4
commands/communities.sh
Normal file
4
commands/communities.sh
Normal file
|
@ -0,0 +1,4 @@
|
|||
#Community hoardan
|
||||
follow(){ post "community/follow" "{\"community_id\":$1,\"follow\":true}"; }
|
||||
unfollow(){ post "community/follow" "{\"community_id\":$1,\"follow\":false}"; }
|
||||
following(){ echo "use <home> instead"; } # Maybe this will help.
|
5
commands/lurking.sh
Normal file
5
commands/lurking.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#Lurkan
|
||||
notifs(){ getauth "user/replies" ".replies | reverse | $notifs"; }
|
||||
notifs2(){ getauth "user/mention" ".mentions | reverse | $notifs"; }
|
||||
home(){ getauth "post/list" ".posts | $posts" "type_=Subscribed"; }
|
||||
comments(){ getauth "post" "(.post_view | $showpost), (.comments | reverse | $comments)" "id=$1"; }
|
7
commands/posts.sh
Normal file
7
commands/posts.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#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 | .[] | $postsummary" "type_=All&saved_only=true"; }
|
||||
#Postan
|
||||
freepost(){ getbody; post "post" "{\"community_id\":$1,\"name\":\"${*:2}\",\"body\":\"$body\"}"; }
|
||||
shitpost(){ getbody; postid=$1; parentid=$2; post "comment" "{\"post_id\":$postid,\"parent_id\":$parentid,\"content\":\"$body\"}"; }
|
Loading…
Reference in New Issue
Block a user