-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKegStrings.py
62 lines (39 loc) · 1.08 KB
/
KegStrings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Object strings
''' There are four types of object strings:
- (N)ew Object
- (C)onvert Type
- (M)ethod
- (P)ython code
This are in the form of
`@[Letter]|[Information];`
`N` object strings can create:
- Stacks (`@N|[]`, `@N|[1, 2, 3];`)
- Strings (`@N|"";`)
- Files (`@N|file(addr);`)
- Websocket Instances (`@N|https://addr;")
- Other objects (`@N|obj`)
`C` object strings can:
- Convert one type to another
- Actually, that's it
- `@C|t;` t = type to convert
`M` object strings can:
- Call functions of the objects on the stack
`P` object strings can:
- Run raw python
'''
def obj_str_extract(string):
import re
pobj = re.compile(r"`@(?P<type>[NCMP])\|(?P<data>.+);`")
mobj = pobj.match(string)
if mobj:
str_type, obj_data = mobj.groups()
if str_type == "N": #New Object
return eval(obj_data)
if str_type == "C":
return obj_data
if str_type == "P":
exec(obj_data)
else:
return string
if __name__ == "__main__":
print(obj_str_extract("`09;`"))