Browse Source

Add cache to command object

Kirk Trombley 4 years ago
parent
commit
1ffeae3dfa
1 changed files with 4 additions and 0 deletions
  1. 4 0
      lib/rollbot/types.py

+ 4 - 0
lib/rollbot/types.py

@@ -47,6 +47,10 @@ class Command:
     name: str
     name: str
     args: str
     args: str
 
 
+    def __post_init__(self):
+        # cache is used by injectors to store results and avoid recomputation
+        self.cache = {}
+
     @staticmethod
     @staticmethod
     def from_text(text: str) -> Optional[Command]:
     def from_text(text: str) -> Optional[Command]:
         cleaned = text.lstrip()
         cleaned = text.lstrip()