]> git.somenet.org - pub/jan/mattermost-bot.git/blob - core/AbstractWSHandler.py
requirements.txt
[pub/jan/mattermost-bot.git] / core / AbstractWSHandler.py
1 # Mattermost Bot.
2 #  Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 #  published under MIT-License
4
5
6 class AbstractWSHandler():
7     NAME = None
8     bot = None
9
10
11     def __init__(self):
12         pass
13
14
15     # should be overridden by the user
16     def on_register_ws_evtype(self, evtype):
17         pass
18
19     # can/should be overridden by the user
20     def on_shutdown(self):
21         """Consider to override. Handles the shutdown-procedure."""
22         return
23
24     # can/should be overridden by the user
25     def on_SIGUSR1(self, sigusr1_cnt):
26         """Consider to override. Handles the SIGUSR1-signal."""
27         return
28
29     # should be overridden by the user
30     def on_WS_EVENT(self, data):
31         return False
32
33     # should be overridden by the user
34     # manual command authentication needed!
35     def on_POST_interactive(self, request, data):
36         return
37
38     def _on_register_ws_evtype(self, bot, evtype):
39         self.bot = bot
40         self.on_register_ws_evtype(evtype)
41
42     def _on_shutdown(self):
43         self.on_shutdown()
44
45     def _on_SIGUSR1(self, sigusr1_cnt):
46         self.on_SIGUSR1(sigusr1_cnt)