-
Notifications
You must be signed in to change notification settings - Fork 1
/
functionmapper.py
113 lines (94 loc) · 4.02 KB
/
functionmapper.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import commands
import namedtuple
CommandArgs = namedtuple.namedtuple('CommandArgs', 'name tokens full actor')
commandFunctions = {}
commandFunctions["configure"] = commands.configure
commandFunctions["config"] = commands.configure
commandFunctions["alias"] = commands.alias
commandFunctions["unalias"] = commands.alias
commandFunctions["aliases"] = commands.alias
commandFunctions["say"] = commands.say
commandFunctions["whisper"] = commands.whisper
commandFunctions["yell"] = commands.yell
commandFunctions["shout"] = commands.yell
commandFunctions["scream"] = commands.yell
commandFunctions["language"] = commands.language
commandFunctions["languages"] = commands.language
commandFunctions["logout"] = commands.logout
commandFunctions["help"] = commands.help
commandFunctions["who"] = commands.who
commandFunctions["pm"] = commands.pm
commandFunctions["emote"] = commands.emote
commandFunctions["ooc"] = commands.ooc
commandFunctions["roll"] = commands.roll
commandFunctions["hroll"] = commands.roll
commandFunctions["droll"] = commands.roll
commandFunctions["display"] = commands.display
commandFunctions["mask"] = commands.mask
commandFunctions["unmask"] = commands.mask
commandFunctions["status"] = commands.status
commandFunctions["glance"] = commands.glance
commandFunctions["colors"] = commands.colors
commandFunctions["paint"] = commands.paint
commandFunctions["sculpt"] = commands.sculpt
commandFunctions["brush"] = commands.brush
commandFunctions["wipe"] = commands.wipe
commandFunctions["look"] = commands.look
commandFunctions["tally"] = commands.tally
commandFunctions["tallies"] = commands.tally
commandFunctions["bag"] = commands.bag
commandFunctions["bags"] = commands.bag
commandFunctions["save"] = commands.save
commandFunctions["desc"] = commands.description
commandFunctions["description"] = commands.description
commandFunctions["exa"] = commands.examine
commandFunctions["examine"] = commands.examine
commandFunctions["hastepaste"] = commands.docshare
commandFunctions["docshare"] = commands.docshare
commandFunctions["zap"] = commands.zap
commandFunctions["init"] = commands.initiative
commandFunctions["initiative"] = commands.initiative
commandFunctions["tick"] = commands.initiative
commandFunctions["fudge"] = commands.fudge
def shorthandHandler(args):
if len(args.tokens) < 1:
return args
if len(args.full) < 2:
return args
if args.name[0] in (';'):
new_name = "emote"
new_tokens = ["emote", ";", args.tokens[0][1:]] + args.tokens[1:]
new_full = "emote ; " + args.full[1:]
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
elif args.name[0] == "'":
new_name = "say"
new_tokens = ["say", args.tokens[0][1:]] + args.tokens[1:]
new_full = "say " + args.full[1:]
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
elif args.name[0] == "*":
new_name = "ooc"
new_tokens = ["ooc", args.tokens[0][1:]] + args.tokens[1:]
new_full = "ooc " + args.full[1:]
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
elif args.name[0] == "#":
new_name = "roll"
new_tokens = ["roll", '1d' + args.tokens[0][1:]]
new_full = "roll 1d" + args.tokens[0][1:]
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
elif args.name[0] == "$":
new_name = "mask"
new_tokens = ["mask", args.tokens[0][1:]] + args.tokens[1:]
new_full = "mask " + args.full[1:]
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
elif "@" in args.name:
new_name = "display"
new_tokens = ["display"] + args.tokens
new_full = "display " + args.full
newargs = CommandArgs(name=new_name, tokens=new_tokens, full=new_full, actor=args.actor)
return newargs
return args