Skip to content

Commit 3fc7d8c

Browse files
committed
update fake_puppet
1 parent a07d552 commit 3fc7d8c

File tree

2 files changed

+230
-3
lines changed

2 files changed

+230
-3
lines changed

src/wechaty/config.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def cache_dir(self) -> str:
100100
Returns:
101101
str: the path of cache dir
102102
"""
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
104106

105107
@property
106108
def ui_dir(self) -> str:
@@ -129,6 +131,46 @@ def get_environment_variable(
129131
if name not in os.environ:
130132
return default_value
131133
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
132174

133175
# export const CHATIE_OFFICIAL_ACCOUNT_ID = 'gh_051c89260e5d'
134176
# chatie_official_account_id = 'gh_051c89260e5d'

0 commit comments

Comments
 (0)