diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3dd943d..f8b7f34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,8 @@ on: env: # auto merge from y1ndan/genshin-impact-helper, default: false ALLOW_MERGE: 'false' + RUN_ENV: 'prod' + TZ: 'Asia/Shanghai' jobs: build: diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..291a53d --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +__pycache__ + +# Installer logs +pip-log.txt + +# Unit tmp / coverage reports +.coverage +.tox +nosetests.xml +.pytest_cache + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# temp file +.DS_Store +*.pkl + +# venv +.venv/ + +# Cookiecutter +output/ + +# vscode +.vscode + +# notebooks +notebooks/ + +# idea +.idea diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..530716d --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +genshin-impact-helper diff --git a/README.md b/README.md index 37e3a7f..5bd7c33 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,49 @@ Error: Process completed with exit code 255. +## 🔨开发 + +如果需要重构或增加额外功能参考以下数据 + +```python +roles = Roles(cookie).get_roles() +roles = { + 'retcode': 0, + 'message': 'OK', + 'data': { + 'list': [ + { + 'game_biz': 'hk4e_cn', + 'region': 'cn_gf01', + 'game_uid': '111111111', + 'nickname': '酸柚子', + 'level': 48, + 'is_chosen': False, + 'region_name': '天空岛', + 'is_official': True + } + ] + } +} +``` +```python +infos = Sign(cookie).get_info() +infos = [ + { + 'retcode': 0, + 'message': 'OK', + 'data': { + 'total_sign_day': 5, + 'today': '2021-01-05', + 'is_sign': True, + 'first_bind': False, + 'is_sub': False, + 'month_first': False + } + } +] + +``` ## 🔔订阅 若开启订阅推送,无论成功与否,都会收到微信通知。 diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..e5b2abb --- /dev/null +++ b/settings.py @@ -0,0 +1,46 @@ +# settings +import logging + +import os + +__all__ = ['log', 'CONFIG'] + +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s %(levelname)s %(message)s', + datefmt='%Y-%m-%dT%H:%M:%S') + + +log = logger = logging + + +class _Config: + ACT_ID = 'e202009291139501' + APP_VERSION = '2.3.0' + REFERER_URL = 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?' \ + 'bbs_auth_required={}&act_id={}&utm_source={}&utm_medium={}&' \ + 'utm_campaign={}'.format('true', ACT_ID, 'bbs', 'mys', 'icon') + AWARD_URL = 'https://api-takumi.mihoyo.com/event/bbs_sign_reward/home?act_id={}'.format(ACT_ID) + ROLE_URL = 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz={}'.format('hk4e_cn') + INFO_URL = 'https://api-takumi.mihoyo.com/event/bbs_sign_reward/info?region={}&act_id={}&uid={}' + SIGN_URL = 'https://api-takumi.mihoyo.com/event/bbs_sign_reward/sign' + USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) ' \ + 'miHoYoBBS/{}'.format(APP_VERSION) + + +class ProductionConfig(_Config): + LOG_LEVEL = logging.INFO + + +class DevelopmentConfig(_Config): + LOG_LEVEL = logging.DEBUG + + +RUN_ENV = os.environ.get('RUN_ENV', 'dev') +if RUN_ENV == 'dev': + CONFIG = DevelopmentConfig() +else: + CONFIG = ProductionConfig() + +log.basicConfig(level=CONFIG.LOG_LEVEL) +