URI: 
       Add the dice script. - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit ee1b69d6dd4d8a0e757f47167dd7d0b51494058d
   DIR parent 504821792ad1bf34607dc43d01bef05d8f62a40e
  HTML Author: Annna Robert-Houdin <annna@bitreich.org>
       Date:   Sat, 20 Dec 2025 21:35:25 +0100
       
       Add the dice script.
       
       Diffstat:
         A dice                                |      44 +++++++++++++++++++++++++++++++
       
       1 file changed, 44 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/dice b/dice
       @@ -0,0 +1,44 @@
       +#!/usr/bin/env python
       +# coding=utf-8
       +
       +import os
       +import sys
       +import getopt
       +import xdice as dice
       +
       +def usage(app):
       +        app = os.path.basename(app)
       +        print("usage: %s [-h] [dice_notation]" % (app), file=sys.stderr)
       +        sys.exit(1)
       +
       +def main(args):
       +        try:
       +                opts, largs = getopt.getopt(args[1:], "h")
       +        except getopt.GetoptError as err:
       +                print(str(err))
       +                usage(args[0])
       +
       +        for o, a in opts:
       +                if o == "-h":
       +                        usage(args[0])
       +                else:
       +                        assert False, "unhandled option"
       +
       +        # six-sided dice once
       +        if len(largs) < 1:
       +                diceroll = "d6"
       +        else:
       +                diceroll = largs[0]
       +
       +        try:
       +                score = dice.roll(diceroll)
       +        except:
       +                print("Invalid pattern.")
       +        else:
       +                print("%s [%s]" % (score, score.format(verbose=True)))
       +
       +        return 0
       +
       +if __name__ == "__main__":
       +        sys.exit(main(sys.argv))
       +