@@ -100,7 +100,9 @@ def cache_dir(self) -> str:
100
100
Returns:
101
101
str: the path of cache dir
102
102
"""
103
- return os .environ .get ("CACHE_DIR" , '.wechaty' )
103
+ path = os .environ .get ("CACHE_DIR" , '.wechaty' )
104
+ os .makedirs (path , exist_ok = True )
105
+ return path
104
106
105
107
@property
106
108
def ui_dir (self ) -> str :
@@ -129,6 +131,46 @@ def get_environment_variable(
129
131
if name not in os .environ :
130
132
return default_value
131
133
return os .environ [name ]
134
+
135
+ def cache_rooms (self ) -> bool :
136
+ """whether cache all of payloads of rooms
137
+
138
+ Returns:
139
+ bool: whether cache the paylaod of rooms
140
+ """
141
+ return os .environ .get ('CACHE_ROOMS' , True )
142
+
143
+ def cache_room_path (self ) -> str :
144
+ """get the room pickle path"""
145
+ env_key = "CACHE_CONTACTS_PATH"
146
+ if env_key in os .environ :
147
+ return os .environ [env_key ]
148
+
149
+ default_path = os .path .join (
150
+ self .cache_dir ,
151
+ "contact_payloads.pkl"
152
+ )
153
+ return default_path
154
+
155
+ def cache_contacts (self ) -> bool :
156
+ """whether cache all of payloads of contact
157
+
158
+ Returns:
159
+ bool: whether cache the paylaod of contact
160
+ """
161
+ return os .environ .get ('CACHE_ROOMS' , True )
162
+
163
+ def cache_contact_path (self ) -> str :
164
+ """get the contact pickle path"""
165
+ env_key = "CACHE_CONTACTS_PATH"
166
+ if env_key in os .environ :
167
+ return os .environ [env_key ]
168
+
169
+ default_path = os .path .join (
170
+ self .cache_dir ,
171
+ "contact_payloads.pkl"
172
+ )
173
+ return default_path
132
174
133
175
# export const CHATIE_OFFICIAL_ACCOUNT_ID = 'gh_051c89260e5d'
134
176
# chatie_official_account_id = 'gh_051c89260e5d'
0 commit comments