Introduction
Introduction Statistics Contact Development Disclaimer Help
Add ghost support to annna. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 4b4fe8d6ccb2428b60fe492d06065f126c97bc8c
parent 708589d9a8cd100e0145e0a69a6a7f1f99b4b82f
Author: Annna Robert-Houdin <[email protected]>
Date: Thu, 31 Oct 2024 19:46:22 +0100
Add ghost support to annna.
Diffstat:
M annna-message-common | 16 +++++++++++++---
A ghost | 84 +++++++++++++++++++++++++++++…
2 files changed, 97 insertions(+), 3 deletions(-)
---
diff --git a/annna-message-common b/annna-message-common
@@ -624,14 +624,24 @@ case "${text}" in
suri="$(printf "%s\n" "${word}" | bitreich-speak)"
annna-say -s "${server}" -c "${channel}" "${suri}"
;;
+"${ircuser}, please zombie say "*)
+ word="$(printf "%s\n" "${text}" | cut -c 26- | sed 's,\t, ,g')"
+ suri="$(printf "%s\n" "${word}" | zombie -e | bitreich-speak)"
+ annna-say -s "${server}" -c "${channel}" "${suri}"
+ ;;
"${ircuser}, please zombie "*)
word="$(printf "%s\n" "${text}" | cut -c 22- | sed 's,\t, ,g')"
suri="$(printf "%s\n" "${word}" | zombie -e)"
annna-say -s "${server}" -c "${channel}" "${suri}"
;;
-"${ircuser}, please zombie say "*)
- word="$(printf "%s\n" "${text}" | cut -c 26- | sed 's,\t, ,g')"
- suri="$(printf "%s\n" "${word}" | zombie -e | bitreich-speak)"
+"${ircuser}, please ghost say "*)
+ word="$(printf "%s\n" "${text}" | cut -c 25- | sed 's,\t, ,g')"
+ suri="$(printf "%s\n" "${word}" | ghost -e | bitreich-speak)"
+ annna-say -s "${server}" -c "${channel}" "${suri}"
+ ;;
+"${ircuser}, please ghost "*)
+ word="$(printf "%s\n" "${text}" | cut -c 21- | sed 's,\t, ,g')"
+ suri="$(printf "%s\n" "${word}" | ghost -e)"
annna-say -s "${server}" -c "${channel}" "${suri}"
;;
"${ircuser}, what can I cook with "*)
diff --git a/ghost b/ghost
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# coding=utf-8
+#
+# Copy me if you can.
+# by 20h
+#
+# Idea from: https://github.com/xdpirate/ghost-translator/blob/main/ghost-tran…
+
+import os
+import sys
+import getopt
+
+def human2ghost(s):
+ r = ""
+ for c in s:
+ binc = bin(ord(c)^96)[2:]
+ for j in binc:
+ if j == "1":
+ r += "O"
+ else:
+ r += "o"
+ r += " "
+ return r
+
+def ghost2human(s):
+ r = ""
+ if len(s) == 0:
+ return r
+
+ for c in s.split(" "):
+ if len(c) == 0:
+ continue
+ b = ""
+ for j in c:
+ if j == "O":
+ b += "1"
+ elif j == "o":
+ b += "0"
+ r += str(chr(int(b, 2)^96))
+ return r
+
+def usage(app):
+ app = os.path.basename(app)
+ print("usage: %s [-h] [-e|-d]" % (app), file=sys.stderr)
+ sys.exit(1)
+
+def main(args):
+ try:
+ opts, largs = getopt.getopt(args[1:], "hed")
+ except getopt.GetoptError as err:
+ print(str(err))
+ usage(args[0])
+
+ dodecode=0
+ doencode=0
+
+ for o, a in opts:
+ if o == "-h":
+ usage(args[0])
+ elif o == "-d":
+ dodecode=1
+ elif o == "-e":
+ doencode=1
+ else:
+ assert False, "unhandled option"
+
+ ins = sys.stdin.read()
+ rs = None
+ if doencode:
+ words = ins.split(" ")
+ rs = " ".join([human2ghost(w) for w in words])
+ if dodecode:
+ words = ins.split(" ")
+ rs = " ".join([ghost2human(w) for w in words])
+ if rs != None:
+ print("%s" % (rs), end='')
+ else:
+ usage(args[0])
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
+
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.