]> git.aero2k.de Git - urlbot-v3.git/commitdiff
fix stupid mistakes
authorThorsten <mail@aero2k.de>
Wed, 13 Dec 2023 16:44:08 +0000 (17:44 +0100)
committerThorsten <mail@aero2k.de>
Wed, 13 Dec 2023 16:44:08 +0000 (17:44 +0100)
distbot/plugins/didyouknow.py

index a9fdbfa109fdac506f977dcb07704fcb06d734e6..696948f588007922314df221eda2a1585a739fc1 100644 (file)
@@ -17,7 +17,7 @@ DB = [
 class DidYouKnow(Worker):
     binding_keys = [
         "#.wusstet.ihr.#",
-        "Hi.#"
+        "hi.#",
     ]
     description = "smart bot"
     usage = "wusstest ihr schon."
@@ -57,12 +57,13 @@ class DidYouKnow(Worker):
 
 
     def insert_fact(self, msg):
-        with open(self.dynamic_db, "w") as fd:
+        with open(self.dynamic_db, "r+") as fd:
             try:
                 db = json.load(fd)
             except Exception as e:
                 db = {"quotes": []}
             db["quotes"].append(msg["body"])
+            fd.seek(0)
             json.dump(db, fd, indent=2)