-
Notifications
You must be signed in to change notification settings - Fork 1
/
hook.py
46 lines (33 loc) · 916 Bytes
/
hook.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
class hook:
functions = {}
def add(event, func):
"""add
Args:
event (str): streaming event type. (view docs)
func (funct): Function to call on events entered in event
Returns:
bool: True
"""
hook.functions[event] = func
return True
def remove(event):
"""remove
Args:
event (str): streaming event type. (view docs)
Returns:
bool: True
"""
hook.functions[event] = None
return True
def reload(event):
"""reload
Internally, it just executes remove and add.
Args:
event (str): streaming event type. (view docs)
Returns:
bool: True
"""
func = hook.functions[event]
hook.remove(event)
hook.add(event, func)
return True