From 8ff0b626a212ec6ca56d7a9c36eb12e4f2b079be Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sat, 31 Oct 2015 17:40:23 +0100 Subject: [PATCH] Update help of module using keywords --- modules/framalink.py | 12 ++++++++---- modules/suivi.py | 22 +++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/modules/framalink.py b/modules/framalink.py index 9e2af2f..6e65ccd 100644 --- a/modules/framalink.py +++ b/modules/framalink.py @@ -109,10 +109,14 @@ def parseresponse(msg): # MODULE INTERFACE #################################################### @hook("cmd_hook", "framalink", - help="Reduce any given URL", - help_usage={None: "Reduce the last URL said on the channel", - "[@provider=framalink] URL [URL ...]": "Reduce the given " - "URL(s) using the specified shortner"}) + help="Reduce any long URL", + help_usage={ + None: "Reduce the last URL said on the channel", + "URL [URL ...]": "Reduce the given URL(s)" + }, + keywords={ + "provider=SMTH": "Change the service provider used (by default: %s) among %s" % (DEFAULT_PROVIDER, ", ".join(PROVIDERS.keys())) + }) def cmd_reduceurl(msg): minify = list() diff --git a/modules/suivi.py b/modules/suivi.py index c2fd645..a0964ac 100644 --- a/modules/suivi.py +++ b/modules/suivi.py @@ -1,3 +1,7 @@ +"""Postal tracking module""" + +# PYTHON STUFF ############################################ + import urllib.request import urllib.parse from bs4 import BeautifulSoup @@ -8,11 +12,9 @@ from nemubot.exception import IMException from nemubot.tools.web import getURLContent from more import Response -nemubotversion = 4.0 # POSTAGE SERVICE PARSERS ############################################ - def get_tnt_info(track_id): data = getURLContent('www.tnt.fr/public/suivi_colis/recherche/' 'visubontransport.do?bonTransport=%s' % track_id) @@ -101,7 +103,6 @@ def get_laposte_info(laposte_id): # TRACKING HANDLERS ################################################### - def handle_tnt(tracknum): info = get_tnt_info(tracknum) if info: @@ -141,23 +142,26 @@ def handle_coliprive(tracknum): if info: return ("Colis Privé: \x02%s\x0F : \x02%s\x0F." % (tracknum, info)) + TRACKING_HANDLERS = { 'laposte': handle_laposte, 'colissimo': handle_colissimo, 'chronopost': handle_chronopost, 'coliprive': handle_coliprive, - 'tnt': handle_tnt + 'tnt': handle_tnt, } # HOOKS ############################################################## - @hook("cmd_hook", "track", - help="Track postage", - help_usage={"[@tracker] TRACKING_ID [TRACKING_ID ...]": "Track the " - "specified postage IDs using the specified tracking service " - "or all of them."}) + help="Track postage delivery", + help_usage={ + "TRACKING_ID [...]": "Track the specified postage IDs on various tracking services." + }, + keywords={ + "tracker=TRK": "Precise the tracker (default: all) among: " + ', '.join(TRACKING_HANDLERS) + }) def get_tracking_info(msg): if not len(msg.args): raise IMException("Renseignez un identifiant d'envoi.")