modules: add send_dice

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-07 18:00:25 +01:00
parent 52d1ac5618
commit eee5458232

View File

@ -6,7 +6,7 @@
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
# shellcheck disable=SC1117 # shellcheck disable=SC1117
#### $$VERSION$$ v1.45-dev-3-g429c230 #### $$VERSION$$ v1.45-dev-4-g52d1ac5
# will be automatically sourced from bashbot # will be automatically sourced from bashbot
@ -310,12 +310,31 @@ send_file(){
return 0 return 0
} }
# $1 typing upload_photo record_video upload_video record_audio upload_audio upload_document find_location # $1 chat $2 typing upload_photo record_video upload_video record_audio upload_audio upload_document find_location
send_action() { send_action() {
[ -z "$2" ] && return [ -z "$2" ] && return
sendJson "$1" '"action": "'"$2"'"' "${URL}/sendChatAction" & sendJson "$1" '"action": "'"$2"'"' "${URL}/sendChatAction" &
} }
# $1 chat $2 emoji “🎲”, “🎯”, “🏀”, “⚽”, “🎰"
# code: \u201c\ud83c\udfb2\u201d \u201c\ud83c\udfaf\u201d \u201c\ud83c\udfc0\u201d \u201c\u26bd\u201d \u201c\ud83c\udfb0\u201d
# text: ":game_die:" "game" ":dart:" "dart" ":basketball:" "basket" ":soccer:" "soccer" :slot_machine:" "slot"
# $3 reply_to_id
send_dice() {
local emoji reply
[ -n "$3" ] && reply=',"reply_to_message_id":'"$3"
case "$2" in # must be single character
*🎲*|*game*) emoji='\u201c\ud83c\udfb2\u201d' ;;
*🎯*|*dart*) emoji='\u201c\ud83c\udfaf\u201d' ;;
*🏀*|*basket*) emoji='\u201c\ud83c\udfc0\u201d' ;;
*⚽*|*soccer*) emoji='\u201c\u26bd\u201d' ;;
*🎰*|*slot*) emoji='\u201c\ud83c\udfb0\u201d' ;;
*) # default emoji "🎲"
emoji='\u201c\ud83c\udfb2\u201d' ;;
esac
sendJson "$1" '"emoji": "'"${emoji}"'"'"${reply}" "${URL}/sendChatAction" &
}
# $1 CHAT $2 lat $3 long # $1 CHAT $2 lat $3 long
send_location() { send_location() {
[ -z "$3" ] && return [ -z "$3" ] && return