From 51a52e2b0e54031cce5876f54d1d48c268b5441c Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 26 Sep 2018 18:27:17 +0100 Subject: Switch to using @Utils.hook and docstrings for event hooks --- modules/upc.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules/upc.py') diff --git a/modules/upc.py b/modules/upc.py index 0e47801f..8da063f5 100644 --- a/modules/upc.py +++ b/modules/upc.py @@ -1,16 +1,15 @@ -from src import Utils +from src import ModuleManager, Utils UPCITEMDB_URL = "https://api.upcitemdb.com/prod/trial/lookup" -class Module(object): +class Module(ModuleManager.BaseModule): _name = "UPC" - def __init__(self, bot, events, exports): - self.bot = bot - events.on("received.command").on("upc", "ean", "gtin").hook( - self.upc, min_args=1, usage="", - help="Look up a product by UPC or EAN") + @Utils.hook("received.command.upc|ean|gtin", min_args=1, usage="") def upc(self, event): + """ + Look up a product by UPC, EAN or GTIN + """ arg_len = len(event["args_split"][0]) if not arg_len == 12 and not arg_len == 13: event["stderr"].write("Invalid UPC/EAN provided") -- cgit v1.3.1-10-gc9f91