From 343d7a377a256af35c2d06a76973c53cc14ff064 Mon Sep 17 00:00:00 2001 From: Geoff Whittington Date: Mon, 22 Aug 2022 00:36:53 -0400 Subject: [PATCH] simplify --- plugins.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins.py b/plugins.py index 51077c7..2d3e2ea 100644 --- a/plugins.py +++ b/plugins.py @@ -156,16 +156,19 @@ class WebhookPlugin(Plugin): def do_action(self, packet): if type(packet) is not dict: - self.logger.warning("Packet is not dict") - return packet + try: + packet = json.loads(packet) + except: + self.logger.warning("Packet is not dict") + return packet if "active" in self.config and not self.config["active"]: return packet - if "position" not in packet["decoded"]: + if 'body' not in self.config: + self.logger.warning("Missing config: body") return packet - import json import requests position = packet["decoded"]["position"] if "position" in packet["decoded"] else None