Add /konachan command
This commit is contained in:
17
konata.sh
17
konata.sh
@@ -67,6 +67,7 @@ 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
|
||||||
|
- /konachan \[query\] - Get a picture from Konachan.
|
||||||
- /4c \[board\] - Get a random image from 4chan.
|
- /4c \[board\] - Get a random image from 4chan.
|
||||||
- /repo - Get my source code.
|
- /repo - Get my source code.
|
||||||
Admin only commands:
|
Admin only commands:
|
||||||
@@ -122,15 +123,24 @@ ud(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
konata(){
|
konata(){
|
||||||
data=$(curl -s "https://konachan.net/post.json?limit=1&page=1&tags=order:random%20izumi_konata")
|
args="izumi_konata"
|
||||||
|
konachan
|
||||||
|
}
|
||||||
|
|
||||||
|
konachan(){
|
||||||
|
query=$(sed "s/\ /_/g" <<< ${args[*]})
|
||||||
|
data=$(curl -s "https://konachan.net/post.json?limit=1&page=1&tags=order:random%20$query")
|
||||||
jpeg=$(jq -r '.[0].jpeg_url' <<< $data)
|
jpeg=$(jq -r '.[0].jpeg_url' <<< $data)
|
||||||
file=$(jq -r '.[0].file_url' <<< $data)
|
file=$(jq -r '.[0].file_url' <<< $data)
|
||||||
sfw=$(jq -r '.[0].rating' <<< $data)
|
sfw=$(jq -r '.[0].rating' <<< $data)
|
||||||
if [ $sfw == "s" ]
|
if [ $sfw == "s" ]
|
||||||
then
|
then
|
||||||
sendpic "$jpeg" "[sauce]($file)"
|
sendpic "$jpeg" "[sauce]($file)"
|
||||||
else
|
elif [ $sfw == "q" ] || [ $sfw == "x" ]
|
||||||
|
then
|
||||||
sendmsg "This picture appears to be NSFW! Here's the [sauce]($file)."
|
sendmsg "This picture appears to be NSFW! Here's the [sauce]($file)."
|
||||||
|
else
|
||||||
|
sendmsg "No data!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +151,7 @@ konata(){
|
|||||||
[ $(find $json -mmin +60) ] && rm $json
|
[ $(find $json -mmin +60) ] && rm $json
|
||||||
[ ! -f $json ] && wget -O $json https://a.4cdn.org/${args[0]}/threads.json
|
[ ! -f $json ] && wget -O $json https://a.4cdn.org/${args[0]}/threads.json
|
||||||
thread=$(jq -r '.[].threads[].no' < $json | shuf | head -n1)
|
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)
|
img=$(curl -s https://a.4cdn.org/${args[0]}/thread/$thread.json | jq -r '.posts[].tim' | shuf | head -n1)
|
||||||
url="https://i.4cdn.org/${args[0]}/$img"
|
url="https://i.4cdn.org/${args[0]}/$img"
|
||||||
# TODO: Try to determine from JSON output whether image is PNG or JPG.
|
# TODO: Try to determine from JSON output whether image is PNG or JPG.
|
||||||
sendpic "$url.jpg"
|
sendpic "$url.jpg"
|
||||||
@@ -220,6 +230,7 @@ case "$cmd" in
|
|||||||
/id@$bot) id ;;
|
/id@$bot) id ;;
|
||||||
/ud@$bot*) ud ;;
|
/ud@$bot*) ud ;;
|
||||||
/konata@$bot*) konata ;;
|
/konata@$bot*) konata ;;
|
||||||
|
/konachan@$bot*) konachan ;;
|
||||||
/4c@$bot*) 4c ;;
|
/4c@$bot*) 4c ;;
|
||||||
/repo@$bot) repo ;;
|
/repo@$bot) repo ;;
|
||||||
# Administrative
|
# Administrative
|
||||||
|
Reference in New Issue
Block a user