From 069570e4edbdeba91a97da36de8b63d52b29997c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 7 Feb 2021 18:57:15 +0100 Subject: [PATCH] bin: add send_dice.sh --- bin/any_command.sh | 2 +- bin/send_dice.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ modules/sendMessage.sh | 6 +++++- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 bin/send_dice.sh diff --git a/bin/any_command.sh b/bin/any_command.sh index fe8f3e7..2b62f19 100755 --- a/bin/any_command.sh +++ b/bin/any_command.sh @@ -21,7 +21,7 @@ USAGE='any_command.sh [-h|--help] [--force|--reference] bot_command args ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 30.01.2021 10:24 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-7-ga9ed559 #=============================================================================== #### diff --git a/bin/send_dice.sh b/bin/send_dice.sh new file mode 100755 index 0000000..d5406e5 --- /dev/null +++ b/bin/send_dice.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# shellcheck disable=SC1090,SC2034 +#=============================================================================== +# +# FILE: bin/send_dice.sh +# +USAGE='send_dice.sh [-h|--help] "CHAT[ID]" "emoji" [debug]' +# +# DESCRIPTION: send an animated emoji (dice) to given chat +# +# OPTIONS: CHAT[ID] - ID number of CHAT or BOTADMIN to send to yourself +# emoji - must be one of: “🎲”, “🎯”, “🏀”, “⚽”, or “🎰” +# ":text: ":game_die:" ":dart:" ":basketball:" ":soccer:" :slot_machine:" +# +# -h - display short help +# --help - this help +# +# Set BASHBOT_HOME to your installation directory +# +# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/ +# AUTHOR: KayM (gnadelwartz), kay@rrr.de +# CREATED: 07.02.2021 18:45 +# +#### $$VERSION$$ v1.45-dev-7-ga9ed559 +#=============================================================================== + +#### +# parse args +SEND="send_dice" + +# set bashbot environment +source "${0%/*}/bashbot_env.inc.sh" "${3:-debug}" # $5 debug +print_help "$1" + +#### +# ready, do stuff here ----- +if [ "$1" == "BOTADMIN" ]; then + CHAT="${BOT_ADMIN}" +else + CHAT="$1" +fi + +# send message in selected format +"${SEND}" "${CHAT}" "$2" + +# output send message result +print_result diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 3a24c20..9994bfc 100644 --- a/modules/sendMessage.sh +++ b/modules/sendMessage.sh @@ -6,7 +6,7 @@ # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # # shellcheck disable=SC1117 -#### $$VERSION$$ v1.45-dev-6-g2f6f3bd +#### $$VERSION$$ v1.45-dev-7-ga9ed559 # will be automatically sourced from bashbot @@ -333,6 +333,10 @@ send_dice() { emoji='\ud83c\udfb2' ;; esac sendJson "$1" '"emoji": "'"${emoji}"'"'"${reply}" "${URL}/sendDice" + if [ "${BOTSENT[OK]}" = "true" ]; then + BOTSENT[DICE]="${UPD["result,dice,emoji"]}" + BOTSENT[RESULT]="${UPD["result,dice,value"]}" + fi } # $1 CHAT $2 lat $3 long