Make /4c available to all users
This commit is contained in:
parent
f8f2db52d3
commit
6b0053233b
34
konata.sh
34
konata.sh
@ -68,12 +68,12 @@ help(){
|
|||||||
- /id - Get the current chat's ID.
|
- /id - Get the current chat's ID.
|
||||||
- /ud \[term\] - Get a definition from Urban Dictionary.
|
- /ud \[term\] - Get a definition from Urban Dictionary.
|
||||||
- /konata - Get one of my selfies :3
|
- /konata - Get one of my selfies :3
|
||||||
|
- /4c [board] - Get a random image from 4chan.
|
||||||
- /repo - Get my source code.
|
- /repo - Get my source code.
|
||||||
Admin only commands:
|
Admin only commands:
|
||||||
- /mp3 \[link\] - Download an mp3 file from YouTube.
|
- /mp3 \[link\] - Download an mp3 file from YouTube.
|
||||||
- /stat - Uptime, memory, storage stats.
|
- /stat - Uptime, memory, storage stats.
|
||||||
- /term - Execute a command on the system.
|
- /term - Execute a command on the system.
|
||||||
- /4c - Get a random image from 4chan.
|
|
||||||
|
|
||||||
And a lot more to come!"
|
And a lot more to come!"
|
||||||
}
|
}
|
||||||
@ -128,6 +128,21 @@ konata(){
|
|||||||
sendmsg "This picture appears to be NSFW! Here's the [sauce]($file)."
|
sendmsg "This picture appears to be NSFW! Here's the [sauce]($file)."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4c(){
|
||||||
|
tmp="/tmp/4chan"
|
||||||
|
json="$tmp/${args[0]}.json"
|
||||||
|
[ ! -d $tmp ] && mkdir $tmp
|
||||||
|
[ $(find $json -mmin +60) ] && rm $json
|
||||||
|
[ ! -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"
|
||||||
|
# TODO: Try to determine from JSON output whether image is PNG or JPG.
|
||||||
|
sendpic "$url.jpg"
|
||||||
|
sendpic "$url.png"
|
||||||
|
}
|
||||||
|
|
||||||
repo(){
|
repo(){
|
||||||
sendmsg "You can find my source code [here](https://git.ghnou.su/ghnou/konata)."
|
sendmsg "You can find my source code [here](https://git.ghnou.su/ghnou/konata)."
|
||||||
}
|
}
|
||||||
@ -165,21 +180,6 @@ 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
|
|
||||||
[ $(find $json -mmin +60) ] && rm $json
|
|
||||||
[ ! -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"
|
|
||||||
# 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!"
|
||||||
@ -215,12 +215,12 @@ case "$cmd" in
|
|||||||
/id@$bot) id ;;
|
/id@$bot) id ;;
|
||||||
/ud@$bot*) ud ;;
|
/ud@$bot*) ud ;;
|
||||||
/konata@$bot*) konata ;;
|
/konata@$bot*) konata ;;
|
||||||
|
/4c@$bot*) 4c ;;
|
||||||
/repo@$bot) repo ;;
|
/repo@$bot) repo ;;
|
||||||
# Administrative
|
# Administrative
|
||||||
/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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user