aboutsummaryrefslogtreecommitdiff
path: root/modules/upc.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-09-26 18:27:17 +0100
committerGravatar jesopo2018-09-26 18:27:17 +0100
commit51a52e2b0e54031cce5876f54d1d48c268b5441c (patch)
treea4c0e8e86c55aa701b06297d5b5a2ceebeaab60d /modules/upc.py
parentAlso use docstrings to check if a command has help available, allow one-string (diff)
Switch to using @Utils.hook and docstrings for event hooks
Diffstat (limited to 'modules/upc.py')
-rw-r--r--modules/upc.py13
1 files changed, 6 insertions, 7 deletions
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="<UPC|EAN>",
- help="Look up a product by UPC or EAN")
+ @Utils.hook("received.command.upc|ean|gtin", min_args=1, usage="<UPC|EAN>")
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")