Allow international dice notation support to annna dice support. - annna - Annna the nice friendly bot.
(HTM) git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
---
(DIR) commit 082001360c20fe94cdc9ab9235ccc4a3279a4a9c
(DIR) parent ae2032f1795a3c25dbf1c5f64390f54dc4d2e2ae
(HTM) Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Sun, 25 Aug 2024 20:27:27 +0200
Allow international dice notation support to annna dice support.
Diffstat:
M annna-message-common | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/annna-message-common b/annna-message-common
@@ -1064,8 +1064,18 @@ case "${text}" in
;;
esac
;;
-"${ircuser}, please roll a dice for me.")
- annna-say -s "${server}" -c "${channel}" "$((($RANDOM % 6) + 1))"
+"${ircuser}, please roll "*" for me.")
+ q="${text#* roll }"
+ q="${q%for*}"
+
+ # https://en.wikipedia.org/wiki/Dice_notation
+ # six-sided dice one time
+ [ -z "${q}" ] && q="d6"
+ [ "${q}" = "a dice " ] && q="d6"
+ [ "${q}" = "dice " ] && q="d6"
+
+ dicescore="$(dice "${q}")"
+ annna-say -s "${server}" -c "${channel}" "${dicescore}"
;;
"${ircuser}, please tell me your favourite flower.")
annna-say -s "${server}" -c "${channel}" "My favourite flower is the beer flower."