]> git.somenet.org - pub/jan/mattermost-bot.git/blob - core/AbstractWSHandler.py
[somebot] /inskription <mnr>
[pub/jan/mattermost-bot.git] / core / AbstractWSHandler.py
1 # Mattermost Bot.
2 #  Copyright (c) 2016-2021 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     # should be overridden by the user
15     def on_register_ws_evtype(self, evtype):
16         pass
17
18     # can/should be overridden by the user
19     def on_shutdown(self):
20         """Consider to override. Handles the shutdown-procedure."""
21         return
22
23     # can/should be overridden by the user
24     def on_SIGUSR1(self, sigusr1_cnt):
25         """Consider to override. Handles the SIGUSR1-signal."""
26         return
27
28     # should be overridden by the user
29     def on_WS_EVENT(self, data):
30         return False
31
32     # should be overridden by the user
33     # manual command authentication needed!
34     def on_POST_interactive(self, request, data):
35         return
36
37     def _on_register_ws_evtype(self, bot, evtype):
38         self.bot = bot
39         self.on_register_ws_evtype(evtype)
40
41     def _on_shutdown(self):
42         self.on_shutdown()
43
44     def _on_SIGUSR1(self, sigusr1_cnt):
45         self.on_SIGUSR1(sigusr1_cnt)