]> git.aero2k.de Git - urlbot-v3.git/commitdiff
fix bug
authorThorsten <mail@aero2k.de>
Sat, 7 Sep 2024 12:19:02 +0000 (14:19 +0200)
committerThorsten <mail@aero2k.de>
Sat, 7 Sep 2024 12:19:02 +0000 (14:19 +0200)
src/distbot/plugins/votepoll.py

index 06852d25a4c38f8e3d16581c1eacf4b04cfe9373..3ee0a1ff60545693701030f22c69fcbef99ebef2 100644 (file)
@@ -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())