Skip to content

Commit de1f8de

Browse files
committed
update wechaty
1 parent a3982e1 commit de1f8de

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/wechaty/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import re
2323
from typing import (
2424
Optional,
25+
Any
2526
)
2627

2728
from wechaty_puppet import (
@@ -113,7 +114,17 @@ def ui_dir(self) -> str:
113114
'ui'
114115
)
115116
return os.environ.get("UI_DIR", default_ui_dir)
117+
118+
def get_environment_variable(self, name: str, default_value: Optional[Any] = None):
119+
"""get environment variable
116120
121+
Args:
122+
name (str): the name of environment
123+
default_value (Optional[Any], optional): default Value. Defaults to None.
124+
"""
125+
if name not in os.environ:
126+
return default_value
127+
return os.environ[name]
117128

118129
# export const CHATIE_OFFICIAL_ACCOUNT_ID = 'gh_051c89260e5d'
119130
# chatie_official_account_id = 'gh_051c89260e5d'

src/wechaty/utils/data_util.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
Any,
2727
)
2828
from collections import UserDict
29+
from wechaty.config import config
2930

3031

3132
class WechatySetting(UserDict):
@@ -83,3 +84,30 @@ def __setitem__(self, key: str, value: Any) -> None:
8384
def to_dict(self) -> dict:
8485
"""return the dict data"""
8586
return self.read_setting()
87+
88+
89+
# class QCloudSetting(WechatySetting):
90+
# """Tencent Cloud Object Storaging"""
91+
# def __init__(self, setting_file: str):
92+
# super().__init__(setting_file)
93+
94+
# from qcloud_cos import CosConfig
95+
# from qcloud_cos import CosS3Client
96+
97+
# secret_id = config.get_environment_variable("q_secret_id")
98+
# secret_key = config.get_environment_variable("q_secret_key")
99+
# region = config.get_environment_variable("q_secret_region")
100+
# self.bucket_name = config.get_environment_variable("bucket_name")
101+
# self.bucket_path_prefix: str = config.get_environment_variable("bucket_prefix", "")
102+
103+
# cos_config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
104+
# self.client = CosS3Client(cos_config)
105+
106+
# def read_setting(self) -> dict:
107+
# """read setting from q-cloud
108+
109+
# Returns:
110+
# dict: the object of setting
111+
# """
112+
# remote_path = os.path.join(self.bucket_path_prefix, self.setting_file)
113+
# self.client

0 commit comments

Comments
 (0)