Add 4c command
This commit is contained in:
24
konata.sh
24
konata.sh
@@ -10,7 +10,7 @@ printf "Content-Type: text/plain\n\n"
|
|||||||
input=$(cat /dev/stdin)
|
input=$(cat /dev/stdin)
|
||||||
msg=$(jq -r '.message.text' <<< $input)
|
msg=$(jq -r '.message.text' <<< $input)
|
||||||
cmd=$(cut -d" " -f1 <<< $msg)
|
cmd=$(cut -d" " -f1 <<< $msg)
|
||||||
args=$(cut -d" " -f2- <<< $msg)
|
args=($(cut -d" " -f2- <<< $msg))
|
||||||
chat=$(jq -r '.message.chat.id' <<< $input)
|
chat=$(jq -r '.message.chat.id' <<< $input)
|
||||||
user=$(jq -r '.message.from.username' <<< $input)
|
user=$(jq -r '.message.from.username' <<< $input)
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ repo(){
|
|||||||
mp3(){
|
mp3(){
|
||||||
admin
|
admin
|
||||||
tmp="/tmp/mp3"
|
tmp="/tmp/mp3"
|
||||||
[ -d $tmp ] && mkdir $tmp
|
[ ! -d $tmp ] && mkdir $tmp
|
||||||
sendmsg "Downloading, this might take a while..."
|
sendmsg "Downloading, this might take a while..."
|
||||||
youtube-dl -f 140 --max-filesize 50M -o "$tmp/%(title)s.%(ext)s" "$args"
|
youtube-dl -f 140 --max-filesize 50M -o "$tmp/%(title)s.%(ext)s" "$args"
|
||||||
rm $tmp/*.part
|
rm $tmp/*.part
|
||||||
@@ -163,6 +163,25 @@ term(){
|
|||||||
\`$(echo $args | bash - 2>&1)\`"
|
\`$(echo $args | bash - 2>&1)\`"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4c(){
|
||||||
|
admin
|
||||||
|
tmp="/tmp/4chan"
|
||||||
|
json="$tmp/${args[0]}.json"
|
||||||
|
[ ! -d $tmp ] && mkdir $tmp
|
||||||
|
[ ! -f $json ] && wget -O $json https://a.4cdn.org/${args[0]}/threads.json
|
||||||
|
thread=$(jq -r '.[].threads[].no' < $json | shuf | head -n1)
|
||||||
|
img=$(curl https://a.4cdn.org/${args[0]}/thread/$thread.json | jq -r '.posts[].tim' | shuf | head -n1)
|
||||||
|
url="https://i.4cdn.org/${args[0]}/$img"
|
||||||
|
sendlog "JSON: $json
|
||||||
|
Temp: $tmp
|
||||||
|
Thread: $thread
|
||||||
|
IMG: $img
|
||||||
|
URL: [JPG]($url.jpg) [PNG]($url.png)"
|
||||||
|
# TODO: Try to determine from JSON output whether image is PNG or JPG.
|
||||||
|
sendpic "$url.jpg"
|
||||||
|
sendpic "$url.png"
|
||||||
|
}
|
||||||
|
|
||||||
fail(){
|
fail(){
|
||||||
debug "User @$user tried to execute $cmd and was rejected."
|
debug "User @$user tried to execute $cmd and was rejected."
|
||||||
sendmsg "Sorry, you are not allowed to use this command!"
|
sendmsg "Sorry, you are not allowed to use this command!"
|
||||||
@@ -203,6 +222,7 @@ case "$cmd" in
|
|||||||
/mp3@$bot*) mp3 ;;
|
/mp3@$bot*) mp3 ;;
|
||||||
/stat@$bot) stat ;;
|
/stat@$bot) stat ;;
|
||||||
/term@$bot*) term ;;
|
/term@$bot*) term ;;
|
||||||
|
/4c*) 4c ;;
|
||||||
# Notes and such
|
# Notes and such
|
||||||
!anyone*) anyone ;;
|
!anyone*) anyone ;;
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user