aboutsummaryrefslogtreecommitdiff
path: root/modules/location.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/location.py')
-rw-r--r--modules/location.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/location.py b/modules/location.py
index 3f1eef65..84dcd691 100644
--- a/modules/location.py
+++ b/modules/location.py
@@ -1,14 +1,21 @@
#--depends-on config
+import typing
from src import ModuleManager, utils
URL_OPENCAGE = "https://api.opencagedata.com/geocode/v1/json"
+class LocationSetting(utils.Setting):
+ _func = None
+ def parse(self, value: str) -> typing.Any:
+ return self._func(value)
+
class Module(ModuleManager.BaseModule):
def on_load(self):
- self.exports.add("set", {"setting": "location",
- "help": "Set your location", "validate": self._get_location,
- "example": "London, GB"})
+ setting = LocationSetting("location", "Set your location",
+ example="London, GB")
+ setting._func = self._get_location
+ self.exports.add("set", setting)
def _get_location(self, s):
page = utils.http.request(URL_OPENCAGE, get_params={