aboutsummaryrefslogtreecommitdiff
path: root/modules/rest_api.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-12 18:07:23 +0100
committerGravatar jesopo2018-10-12 18:07:23 +0100
commit819f4e0680dc8225355924e87bc71938605b98f7 (patch)
tree435f17eccda20a1723f51330ee0403668c76afcd /modules/rest_api.py
parentAdd TimersContext, to be able to purge timers when modules are unloaded (diff)
signature
Pass context-wrapped timers to each module, add ModuleManager.BaseModule.on_load
Diffstat (limited to 'modules/rest_api.py')
-rw-r--r--modules/rest_api.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/rest_api.py b/modules/rest_api.py
index bfee0d6f..b8b3077a 100644
--- a/modules/rest_api.py
+++ b/modules/rest_api.py
@@ -3,7 +3,7 @@
import http.server, json, ssl, threading, uuid, urllib.parse
import flask
-from src import utils
+from src import ModuleManager, utils
_bot = None
_events = None
@@ -72,17 +72,15 @@ class Handler(http.server.BaseHTTPRequestHandler):
@utils.export("botset", {"setting": "rest-api",
"help": "Enable/disable REST API",
"validate": utils.bool_or_none})
-class Module(object):
- def __init__(self, bot, events, exports):
- self.bot = bot
+class Module(ModuleManager.BaseModule):
+ def on_load(self):
global _bot
- _bot = bot
+ _bot = self.bot
- self.events = events
global _events
- _events = events
+ _events = self.events
- if bot.get_setting("rest-api", False):
+ if self.bot.get_setting("rest-api", False):
self.httpd = http.server.HTTPServer(("", 5000), Handler)
self.httpd.socket = ssl.wrap_socket(self.httpd.socket,
keyfile=self.bot.config["tls-api-key"],