Merge pull request #70 from y1ndan/dev

Dev
This commit is contained in:
y1ndan 2021-01-01 13:12:51 +08:00 committed by GitHub
commit 6df7a3fbda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 21 deletions

View File

@ -6,13 +6,13 @@ on:
workflow_dispatch: workflow_dispatch:
env: env:
# 是否允许从y1ndan/genshin-impact-helper同步代码 # auto merge from y1ndan/genshin-impact-helper, default: false
ALLOW_MERGE: 'false' ALLOW_MERGE: 'false'
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' # if: github.ref == 'refs/heads/master'
steps: steps:
- name: Checkout master - name: Checkout master
@ -21,7 +21,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
ref: master ref: master
- name: Merge From y1ndan/genshin-impact-helper - name: Auto merge
if: ${{ env.ALLOW_MERGE != 'false' }} if: ${{ env.ALLOW_MERGE != 'false' }}
run: | run: |
git config --global user.name github-actions git config --global user.name github-actions
@ -37,6 +37,7 @@ jobs:
- name: Run sign - name: Run sign
run: | run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pip install -r requirements.txt
echo "${{ secrets.COOKIE }}" | tr '#' "\n" | sed 's/$/&#${{ secrets.SCKEY }}/g' | xargs -I {} sh -c 'echo "{}" | python3 ./genshin.py' echo "${{ secrets.COOKIE }}" | tr '#' "\n" | sed 's/$/&#${{ secrets.SCKEY }}/g' | xargs -I {} sh -c 'echo "{}" | python3 ./genshin.py'

View File

@ -44,7 +44,7 @@ class ConfMeta(type):
@property @property
def app_version(self): def app_version(self):
return '2.1.0' return '2.3.0'
@property @property
def ua(self): def ua(self):
@ -127,14 +127,15 @@ class Sign(object):
self.__class__, type(__name__), type(cookie))) self.__class__, type(__name__), type(cookie)))
self._cookie = cookie self._cookie = cookie
# Provided by Steesha
def md5(self, text): def md5(self, text):
md5 = hashlib.md5() md5 = hashlib.md5()
md5.update(text.encode()) md5.update(text.encode())
return md5.hexdigest() return md5.hexdigest()
def get_DS(self): def get_DS(self):
n = self.md5(Conf.app_version) # n = self.md5(2.1.0) # v2.1.0 @Steesha
# n = 'cx2y9z9a29tfqvr1qsq6c7yz99b5jsqt' # v2.2.0 @Womsxd
n = 'h8w582wxwgqvahcdkpvdhbh2w9casgfl' # v2.3.0 web @povsister & @journey-ad
i = str(int(time.time())) i = str(int(time.time()))
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6)) r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
c = self.md5('salt=' + n + '&t='+ i + '&r=' + r) c = self.md5('salt=' + n + '&t='+ i + '&r=' + r)
@ -162,8 +163,8 @@ class Sign(object):
try: try:
rolesList = roles['data']['list'] rolesList = roles['data']['list']
except Exception as e: except Exception as e:
massage = roles['massage'] message = roles['message']
notify(sckey, '失败', massage) notify(sckey, '失败', message)
exit(-1) exit(-1)
else: else:
logging.info('当前账号绑定了 {} 个角色'.format(len(rolesList))) logging.info('当前账号绑定了 {} 个角色'.format(len(rolesList)))
@ -188,16 +189,16 @@ class Sign(object):
def run(self): def run(self):
logging.info('任务开始') logging.info('任务开始')
massageList = [] messageList = []
infoList = self.get_info() infoList = self.get_info()
for i in range(len(infoList)): for i in range(len(infoList)):
if infoList[i]['data']['is_sign'] is True: if infoList[i]['data']['is_sign'] is True:
#if infoList[i]['data']['is_sign'] is False: #if infoList[i]['data']['is_sign'] is False:
massage = '旅行者 {} 号,你已经签到过了'.format(i + 1) message = '旅行者 {} 号,你已经签到过了'.format(i + 1)
notify(sckey, '成功', massage) notify(sckey, '成功', message)
elif infoList[i]['data']['first_bind'] is True: elif infoList[i]['data']['first_bind'] is True:
massage = '旅行者 {} 号,请先前往米游社绑定账号'.format(i + 1) message = '旅行者 {} 号,请先前往米游社绑定账号'.format(i + 1)
notify(sckey, '失败', massage) notify(sckey, '失败', message)
exit(-1) exit(-1)
else: else:
today = infoList[i]['data']['today'] today = infoList[i]['data']['today']
@ -225,16 +226,16 @@ class Sign(object):
# -5003: already signed in # -5003: already signed in
if code == 0: if code == 0:
status = '成功' status = '成功'
massageList.append(self.massage().format(today, messageList.append(self.message().format(today,
self._regionNameList[i], uid, award['name'], award['cnt'], self._regionNameList[i], uid, award['name'], award['cnt'],
totalSignDay, jdict['massage'])) totalSignDay, jdict['message'], ''))
else: else:
status = '失败' status = '失败'
massageList = jdict messageList = jdict
return notify(sckey, status, massageList) return notify(sckey, status, messageList)
def massage(self): def message(self):
return ''' return '''
{:#^30} {:#^30}
🔅[{}]{} 🔅[{}]{}
@ -245,11 +246,11 @@ class Sign(object):
''' '''
def notify(sckey, status, massage): def notify(sckey, status, message):
if sckey.startswith('SC'): if sckey.startswith('SC'):
logging.info('准备推送通知...') logging.info('准备推送通知...')
url = 'https://sc.ftqq.com/{}.send'.format(sckey) url = 'https://sc.ftqq.com/{}.send'.format(sckey)
data = {'text': '原神签到小助手 签到{}'.format(status), 'desp': massage} data = {'text': '原神签到小助手 签到{}'.format(status), 'desp': message}
try: try:
jdict = json.loads( jdict = json.loads(
requests.Session().post(url, data = data).text) requests.Session().post(url, data = data).text)
@ -265,7 +266,7 @@ def notify(sckey, status, massage):
else: else:
logging.info('未配置SCKEY,正在跳过推送') logging.info('未配置SCKEY,正在跳过推送')
logging.info('签到{}: {}'.format(status, massage)) logging.info('签到{}: {}'.format(status, message))
return logging.info('任务结束') return logging.info('任务结束')