33 lines
1.3 KiB
Bash
Executable File
33 lines
1.3 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
command="$1"
|
|
shift
|
|
args="$@"
|
|
picture_download_command="cat"
|
|
picture_save_to_temp_command="cat"
|
|
display_command_pipe="display -title \"HonusBot CLI\" -quiet"
|
|
display_command_after="true"
|
|
download_url_to_stdin=true
|
|
|
|
if [ -x "$(command -v viu)" ]; then
|
|
echo "Found viu"
|
|
picture_save_to_temp_command="tee /tmp/temp-honus.bin"
|
|
display_command_pipe="cat > /dev/null"
|
|
display_command_after="viu /tmp/temp-honus.bin"
|
|
download_url_to_stdin=true
|
|
elif [ -x "$(command -v feh)" ]; then
|
|
echo "Found feh"
|
|
display_command_pipe="feh"
|
|
display_command_after="true"
|
|
download_url_to_stdin=false
|
|
fi
|
|
|
|
if [ download_url_to_stdin ]; then
|
|
echo "Must download url content"
|
|
picture_download_command="xargs --max-args=1 --no-run-if-empty curl -s --location"
|
|
fi
|
|
|
|
curl -s --location --request POST 'https://api.ignuranza.net/remote-command-api/command' --header 'Content-Type: application/json' --header 'User-Agent: RcAPI/1.2' --data-raw "{\"botName\": \"AstralNetworkHonusBot\", \"botPassword\": \"KixdujXD37898ZSy893\", \"command\": \"${command}\", \"replyToUserId\": 0, \"senderUserId\": 1237252783, \"chatId\": 1237252783, \"queryText\": \"$args\", \"rawSingleArgument\": false}" | jq -r ".imageUrl" | eval "${picture_download_command}" | eval "${picture_save_to_temp_command}" | eval "${display_command_pipe}"
|
|
|
|
eval "${display_command_after}"
|