Add dance moves generator to annna. - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit 2c92636c06626c950c4b4f45fdf8eca00cab9afc | |
parent e81fdcd6c0b1cf7df00202ab6b37fd4a7cc3b2a1 | |
Author: Annna Robert-Houdin <[email protected]> | |
Date: Tue, 8 Jun 2021 14:30:31 +0200 | |
Add dance moves generator to annna. | |
Diffstat: | |
M annna-message-common | 8 ++------ | |
A dance-moves-gen | 46 +++++++++++++++++++++++++++++… | |
2 files changed, 48 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/annna-message-common b/annna-message-common | |
@@ -635,12 +635,8 @@ case "${text}" in | |
annna-say -c "${channel}" "${user}, for humanity!" | |
;; | |
"${botname}, please dance."|"\o/") | |
- if [ $(($RANDOM % 2)) -gt 0 ]; | |
- then | |
- annna-say -c "${channel}" ',o/ o/_ _\o _o_ \o\' | |
- else | |
- annna-say -c "${channel}" '\o7 -o7 _o7 .o7 \o. \o_ \o- \o7' | |
- fi | |
+ dancemoves="$(dance-moves-gen)" | |
+ annna-say -c "${channel}" "${dancemoves}" | |
;; | |
"${botname}, please dance with me.") | |
if [ $(($RANDOM % 2)) -gt 0 ]; | |
diff --git a/dance-moves-gen b/dance-moves-gen | |
@@ -0,0 +1,46 @@ | |
+#!/usr/bin/env python | |
+# coding=utf-8 | |
+ | |
+import os | |
+import sys | |
+import getopt | |
+import random | |
+ | |
+def usage(app): | |
+ app = os.path.basename(app) | |
+ print("usage: %s [-h] [-n moves]" % (app), file=sys.stderr) | |
+ sys.exit(1) | |
+ | |
+def main(args): | |
+ moves = ["\o/", "\o_", "_o_", "_o/", "~o/", "\o~", "~o~", | |
+ "-o/", "\o-", "-o-", "\o.", ".o/", ".o.", | |
+ "\o7", "_o7", "-o7", ".o7", "~o7"] | |
+ try: | |
+ opts, largs = getopt.getopt(args[1:], "h") | |
+ except getopt.GetoptError as err: | |
+ print(str(err)) | |
+ usage(args[0]) | |
+ | |
+ nmoves = 8 | |
+ | |
+ for o, a in opts: | |
+ if o == "-h": | |
+ usage(args[0]) | |
+ elif o == "-n": | |
+ nmoves = int(a) | |
+ else: | |
+ assert False, "unhandled option" | |
+ | |
+ ostr = "" | |
+ for i in range(nmoves): | |
+ if len(ostr) > 0: | |
+ ostr += " " | |
+ ostr += random.choice(moves) | |
+ | |
+ print("%s" % (ostr)) | |
+ | |
+ return 0 | |
+ | |
+if __name__ == "__main__": | |
+ sys.exit(main(sys.argv)) | |
+ |