Update help of module using keywords

This commit is contained in:
nemunaire 2015-10-31 17:40:23 +01:00
parent 979f1d0c55
commit 8ff0b626a2
2 changed files with 21 additions and 13 deletions

View File

@ -109,10 +109,14 @@ def parseresponse(msg):
# MODULE INTERFACE #################################################### # MODULE INTERFACE ####################################################
@hook("cmd_hook", "framalink", @hook("cmd_hook", "framalink",
help="Reduce any given URL", help="Reduce any long URL",
help_usage={None: "Reduce the last URL said on the channel", help_usage={
"[@provider=framalink] URL [URL ...]": "Reduce the given " None: "Reduce the last URL said on the channel",
"URL(s) using the specified shortner"}) "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): def cmd_reduceurl(msg):
minify = list() minify = list()

View File

@ -1,3 +1,7 @@
"""Postal tracking module"""
# PYTHON STUFF ############################################
import urllib.request import urllib.request
import urllib.parse import urllib.parse
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@ -8,11 +12,9 @@ from nemubot.exception import IMException
from nemubot.tools.web import getURLContent from nemubot.tools.web import getURLContent
from more import Response from more import Response
nemubotversion = 4.0
# POSTAGE SERVICE PARSERS ############################################ # POSTAGE SERVICE PARSERS ############################################
def get_tnt_info(track_id): def get_tnt_info(track_id):
data = getURLContent('www.tnt.fr/public/suivi_colis/recherche/' data = getURLContent('www.tnt.fr/public/suivi_colis/recherche/'
'visubontransport.do?bonTransport=%s' % track_id) 'visubontransport.do?bonTransport=%s' % track_id)
@ -101,7 +103,6 @@ def get_laposte_info(laposte_id):
# TRACKING HANDLERS ################################################### # TRACKING HANDLERS ###################################################
def handle_tnt(tracknum): def handle_tnt(tracknum):
info = get_tnt_info(tracknum) info = get_tnt_info(tracknum)
if info: if info:
@ -141,23 +142,26 @@ def handle_coliprive(tracknum):
if info: if info:
return ("Colis Privé: \x02%s\x0F : \x02%s\x0F." % (tracknum, info)) return ("Colis Privé: \x02%s\x0F : \x02%s\x0F." % (tracknum, info))
TRACKING_HANDLERS = { TRACKING_HANDLERS = {
'laposte': handle_laposte, 'laposte': handle_laposte,
'colissimo': handle_colissimo, 'colissimo': handle_colissimo,
'chronopost': handle_chronopost, 'chronopost': handle_chronopost,
'coliprive': handle_coliprive, 'coliprive': handle_coliprive,
'tnt': handle_tnt 'tnt': handle_tnt,
} }
# HOOKS ############################################################## # HOOKS ##############################################################
@hook("cmd_hook", "track", @hook("cmd_hook", "track",
help="Track postage", help="Track postage delivery",
help_usage={"[@tracker] TRACKING_ID [TRACKING_ID ...]": "Track the " help_usage={
"specified postage IDs using the specified tracking service " "TRACKING_ID [...]": "Track the specified postage IDs on various tracking services."
"or all of them."}) },
keywords={
"tracker=TRK": "Precise the tracker (default: all) among: " + ', '.join(TRACKING_HANDLERS)
})
def get_tracking_info(msg): def get_tracking_info(msg):
if not len(msg.args): if not len(msg.args):
raise IMException("Renseignez un identifiant d'envoi.") raise IMException("Renseignez un identifiant d'envoi.")