Add hook system
+ Formatting
This commit is contained in:
parent
36dff3d99a
commit
5360b128e0
7 changed files with 350 additions and 206 deletions
9
customiwmserver/hooks/__init__.py
Normal file
9
customiwmserver/hooks/__init__.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
# from . import *
|
||||
|
||||
import pkgutil
|
||||
|
||||
__path__ = pkgutil.extend_path(__path__, __name__)
|
||||
for imp, module, ispackage in pkgutil.walk_packages(
|
||||
path=__path__, prefix=__name__ + "."
|
||||
):
|
||||
__import__(module)
|
18
customiwmserver/hooks/webhook.py
Normal file
18
customiwmserver/hooks/webhook.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Example module.
|
||||
#
|
||||
|
||||
from .. import hook_system
|
||||
|
||||
hook = hook_system.hook
|
||||
|
||||
|
||||
@hook.add_hook
|
||||
class Login:
|
||||
# Different hook types are executed at different places.
|
||||
# In this case, the hook is executed when a user logs in.
|
||||
# Check the documentation for more hook types.
|
||||
hook_type = "player_login"
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
print("LOGIN HOOK:", args, kwargs)
|
Loading…
Add table
Add a link
Reference in a new issue