forked from cyberkitsune/PSO2Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.py
More file actions
83 lines (60 loc) · 1.72 KB
/
Copy pathplugins.py
File metadata and controls
83 lines (60 loc) · 1.72 KB
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
packetFunctions = {}
commands = {}
rawPacketFunctions = []
onStart = []
onConnection = []
onConnectionLoss = []
onQueryConnection = []
onClientRemove = []
onInitialConnection = []
onStop = []
class PacketHook(object):
def __init__(self, packet_type, packet_subtype):
self.pktType = packet_type
self.pktSubtype = packet_subtype
def __call__(self, f):
global packetFunctions
if (self.pktType, self.pktSubtype) not in packetFunctions:
packetFunctions[(self.pktType, self.pktSubtype)] = []
packetFunctions[(self.pktType, self.pktSubtype)].append(f)
class CommandHook(object):
"""docstring for commandHook"""
def __init__(self, command, help_text=None, admin_only=False):
self.command = command
self.help_text = help_text
self.admin_only = admin_only
def __call__(self, command_class):
global commands
commands[self.command] = [command_class, self.help_text, self.admin_only]
def on_start_hook(f):
global onStart
onStart.append(f)
return f
def on_stop_hook(f):
global onStop
onStop.append(f)
return f
def on_query_connection_hook(f):
global onQueryConnection
onQueryConnection.append(f)
return f
def on_connection_hook(f):
global onConnection
onConnection.append(f)
return f
def on_connection_lost_hook(f):
global onConnectionLoss
onConnectionLoss.append(f)
return f
def on_client_remove_hook(f):
global onClientRemove
onClientRemove.append(f)
return f
def on_initial_connect_hook(f):
global onInitialConnection
onInitialConnection.append(f)
return f
def raw_packet_hook(f):
global rawPacketFunctions
rawPacketFunctions.append(f)
return f