From: Thorsten Date: Sat, 7 Sep 2024 12:19:02 +0000 (+0200) Subject: fix bug X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=385da926b4144ea3b05ef6eac16b23a6c8858f09;p=urlbot-v3.git fix bug --- diff --git a/src/distbot/plugins/votepoll.py b/src/distbot/plugins/votepoll.py index 06852d2..3ee0a1f 100644 --- a/src/distbot/plugins/votepoll.py +++ b/src/distbot/plugins/votepoll.py @@ -154,10 +154,11 @@ class VotePoll(Worker): if active_key: return self.get_poll(active_key) - def get_poll(self, key: str): + def get_poll(self, key: str) -> Poll | None: poll_bin = self.db.get(key.encode()) - poll = json.loads(poll_bin.decode("utf-8")) - return Poll.from_json(poll) + if poll_bin: + poll = json.loads(poll_bin.decode("utf-8")) + return Poll.from_json(poll) def persist(self, poll: Poll): self.db.put(poll.key.encode(), poll.to_json().encode())