From c9801ee2f7368976863f4178a07b62f0c4d23153 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Tue, 1 Dec 2015 00:49:09 +0100 Subject: [PATCH] [mapquest] Dusting + fill help --- modules/mapquest.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/mapquest.py b/modules/mapquest.py index 2c42ad7..55b87c0 100644 --- a/modules/mapquest.py +++ b/modules/mapquest.py @@ -1,7 +1,7 @@ -# coding=utf-8 - """Transform name location to GPS coordinates""" +# PYTHON STUFFS ####################################################### + import re from urllib.parse import quote @@ -9,12 +9,15 @@ from nemubot.exception import IMException from nemubot.hooks import hook from nemubot.tools import web -nemubotversion = 4.0 - from more import Response +# GLOBALS ############################################################# + URL_API = "http://open.mapquestapi.com/geocoding/v1/address?key=%s&location=%%s" + +# LOADING ############################################################# + def load(context): if not context.config or "apikey" not in context.config: raise ImportError("You need a MapQuest API key in order to use this " @@ -25,9 +28,7 @@ def load(context): URL_API = URL_API % context.config["apikey"].replace("%", "%%") -def help_full(): - return "!geocode /place/: get coordinate of /place/." - +# MODULE CORE ######################################################### def geocode(location): obj = web.getJSON(URL_API % quote(location)) @@ -43,7 +44,13 @@ def where(loc): "{adminArea1}".format(**loc)).strip() -@hook.command("geocode") +# MODULE INTERFACE #################################################### + +@hook.command("geocode", + help="Get GPS coordinates of a place", + help_usage={ + "PLACE": "Get GPS coordinates of PLACE" + }) def cmd_geocode(msg): if not len(msg.args): raise IMException("indicate a name")