aboutsummaryrefslogtreecommitdiff
path: root/modules/location.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-28 23:16:05 +0100
committerGravatar jesopo2019-06-28 23:16:05 +0100
commitae9d099a41b703ce875cf8746a94b6995bbaedfb (patch)
treec389ae3b967c43055a1c671b8cebf04db4e8f8b6 /modules/location.py
parentmessage arg for HTTPWrongContentTypeException/HTTPParsingException (diff)
signature
Refactor set/channelset/serverset/botset in to 'utils.Setting' objects
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={