Introduction
Introduction Statistics Contact Development Disclaimer Help
zombie - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
zombie (2538B)
---
1 #!/usr/bin/env python
2 # coding=utf-8
3 #
4 # Copy me if you can.
5 # by 20h
6 #
7 # Idea from: https://github.com/DanPlayz0/Chucky/blob/main/assets/zombie…
8
9 import os
10 import sys
11 import getopt
12
13 zombiemapping = {
14 "Ar": "a",
15 "AA": "b",
16 "Ab": "c",
17 "RA": "d",
18 "bb": "e",
19 "BA": "f",
20 "ll": "g",
21 "bG": "h",
22 "Gn": "i",
23 "GA": "j",
24 "GG": "k",
25 "nh": "l",
26 "hh": "m",
27 "MM": "n",
28 "hr": "o",
29 "hA": "p",
30 "hb": "q",
31 "rr": "r",
32 "hG": "s",
33 "Gg": "t",
34 "GM": "u",
35 "nr": "v",
36 "Mr": "w",
37 "Gl": "x",
38 "nn": "y",
39 "KA": "z",
40 "aR": "A",
41 "aa": "B",
42 "aB": "C",
43 "rA": "D",
44 "BB": "E",
45 "ba": "F",
46 "LL": "G",
47 "Bg": "H",
48 "gN": "I",
49 "ga": "J",
50 "gg": "K",
51 "NH": "L",
52 "HH": "M",
53 "mm": "N",
54 "HR": "O",
55 "Ha": "P",
56 "HB": "Q",
57 "RR": "R",
58 "Hq": "S",
59 "gG": "T",
60 "gm": "U",
61 "NR": "V",
62 "mR": "W",
63 "gL": "X",
64 "NN": "Y",
65 "ka": "Z"
66 }
67
68 humanmapping = {
69 "a": "Ar",
70 "b": "AA",
71 "c": "Ab",
72 "d": "RA",
73 "e": "bb",
74 "f": "BA",
75 "g": "ll",
76 "h": "bG",
77 "i": "Gn",
78 "j": "GA",
79 "k": "GG",
80 "l": "nh",
81 "m": "hh",
82 "n": "MM",
83 "o": "hr",
84 "p": "hA",
85 "q": "hb",
86 "r": "rr",
87 "s": "hG",
88 "t": "Gg",
89 "u": "GM",
90 "v": "nr",
91 "w": "Mr",
92 "x": "Gl",
93 "y": "nn",
94 "z": "KA",
95 "A": "aR",
96 "B": "aa",
97 "C": "aB",
98 "D": "ra",
99 "E": "BB",
100 "F": "ba",
101 "G": "LL",
102 "H": "Bg",
103 "I": "gN",
104 "J": "ga",
105 "K": "gg",
106 "L": "NH",
107 "M": "HH",
108 "N": "mm",
109 "O": "HR",
110 "P": "Ha",
111 "Q": "HB",
112 "R": "RR",
113 "S": "Hg",
114 "T": "gG",
115 "U": "gm",
116 "V": "NR",
117 "W": "mR",
118 "X": "gL",
119 "Y": "NN",
120 "Z": "ka"
121 }
122
123 def human2zombie(s):
124 r = ""
125 for c in s:
126 try:
127 r += humanmapping[c]
128 except KeyError:
129 r += c
130 return r
131
132 def zombie2human(s):
133 r = ""
134 while 1:
135 c = s[:2]
136 s = s[2:]
137 try:
138 r += zombiemapping[c]
139 except KeyError:
140 r += c
141 if len(s) == 0:
142 break
143 return r
144
145 def usage(app):
146 app = os.path.basename(app)
147 print("usage: %s [-h] [-e|-d]" % (app), file=sys.stderr)
148 sys.exit(1)
149
150 def main(args):
151 try:
152 opts, largs = getopt.getopt(args[1:], "hed")
153 except getopt.GetoptError as err:
154 print(str(err))
155 usage(args[0])
156
157 dodecode=0
158 doencode=0
159
160 for o, a in opts:
161 if o == "-h":
162 usage(args[0])
163 elif o == "-d":
164 dodecode=1
165 elif o == "-e":
166 doencode=1
167 else:
168 assert False, "unhandled option"
169
170 ins = sys.stdin.read()
171 rs = None
172 words = ins.split(" ")
173 if doencode:
174 rs = " ".join([human2zombie(w) for w in words])
175 if dodecode:
176 rs = " ".join([zombie2human(w) for w in words])
177 if rs != None:
178 print("%s" % (rs), end='')
179 else:
180 usage(args[0])
181
182 return 0
183
184 if __name__ == "__main__":
185 sys.exit(main(sys.argv))
186
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.