Add feh and viu

This commit is contained in:
HonusBot 2021-05-15 23:39:10 +02:00
parent be9fe9d051
commit 02ad99f4fa
1 changed files with 19 additions and 11 deletions

View File

@ -3,22 +3,30 @@
command="$1"
shift
args="$@"
display_command="| display -title \"HonusBot CLI\" -quiet"
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 feh)" ]; then
display_command="| feh"
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 [ -x "$(command -v viu)" ]; then
display_command="> /tmp/temp-honus.bin; viu /tmp/temp-honus.bin"
download_url_to_stdin=true
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
if [ download_url_to_stdin = true ]; then
display_command="| xargs --max-args=1 --no-run-if-empty curl -s --location ${display_command}"
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" ${display_command}
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}"