Skip to content

Commit 9a596c9

Browse files
authored
Merge DEV (#2)
* Create codeql.yml * Update codeql.yml * update: 添加米游币获取 1.优化部分输入判断逻辑 2.添加米游币数量获取 3.添加判断米游币数量 * Update codeql.yml
1 parent 9f1e404 commit 9a596c9

File tree

8 files changed

+137
-19
lines changed

8 files changed

+137
-19
lines changed

.github/workflows/codeql.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
- dev
19+
pull_request:
20+
# The branches below must be a subset of the branches above
21+
branches:
22+
- main
23+
- dev
24+
25+
jobs:
26+
analyze:
27+
name: Analyze
28+
runs-on: ubuntu-latest
29+
permissions:
30+
actions: read
31+
contents: read
32+
security-events: write
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
language: [ 'python' ]
38+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
39+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v3
44+
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v2
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
54+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55+
# queries: security-extended,security-and-quality
56+
57+
58+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
59+
# If this step fails, then you should remove it and run the build manually (see below)
60+
- name: Autobuild
61+
uses: github/codeql-action/autobuild@v2
62+
63+
# ℹ️ Command-line programs to run using the OS shell.
64+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65+
66+
# If the Autobuild fails above, remove it and uncomment the following three lines.
67+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68+
69+
# - run: |
70+
# echo "Run, Build Application using script"
71+
# ./location_of_script_within_repo/buildscript.sh
72+
73+
- name: Perform CodeQL Analysis
74+
uses: github/codeql-action/analyze@v2
75+
with:
76+
category: "/language:${{matrix.language}}"

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
# Mys-Exchange-Goods
2-
用于兑换米游社商品
1+
# 米游社商品兑换
2+
<div align="left">
3+
<a href="https://github.com/GOOD-AN/Mys-Exchange-Goods/releases/latest" target="_blank">
4+
<img alt="最新发行版" src="https://img.shields.io/github/v/release/GOOD-AN/Mys-Exchange-Goods?logo=python&style=for-the-badge">
5+
</a>
6+
<img alt="Python 版本要求" src="https://img.shields.io/badge/Python-3.6+-green.svg?longCache=true&style=for-the-badge">
7+
<img alt="GitHub CodeQL 代码检查" src="https://img.shields.io/github/workflow/status/GOOD-AN/Mys-Exchange-Goods/CodeQL?logo=github&style=for-the-badge">
8+
<img alt="开源协议" src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
9+
</div>
310

411
## 使用说明
512

6-
### 安装所需运行库
13+
### 第一步、安装所需运行库
714

815
`pip install -r requirements.txt`
916

10-
### 配置`config.ini`文件
17+
### 第二步、配置`config.ini`文件
1118

1219
*以下未标明手动填写的都可在程序内处理
1320

14-
[user_info]
21+
**[user_info]**
1522

1623
| 参数 | 说明 |
1724
|------------|--------------------------------------|
1825
| cookie | 用户`cookie`数据 |
1926
| uid | 用户游戏内UID, 填写为需要兑换的游戏商品对应的UID, 暂只支持一个 |
2027
| address_id | 用户收货地址ID |
2128

22-
[exchange_info]
29+
**[exchange_info]**
2330

2431
| 参数 | 说明 |
2532
|---------|-----------------------|
@@ -28,15 +35,15 @@
2835
| thread | 每个商品同时请求兑换的线程数, 需手动填写 |
2936
| retry | 请求时重试次数, 需手动填写 |
3037

31-
[check_network]
38+
**[check_network]**
3239

3340
| 参数 | 说明 |
3441
|---------------|----------------------------|
3542
| enable | 是否启用网络检查, 需手动填写 |
3643
| interval_time | 检查间隔, 单位 秒, 需手动填写 |
3744
| stop_time | 距开始兑换多长时间停止检查, 单位 秒, 需手动填写 |
3845

39-
[ntp]
46+
**[ntp]**
4047

4148
| 参数 | 说明 |
4249
|------------|-----------------|
@@ -69,10 +76,23 @@ enable = true
6976
ntp_server = ntp.aliyun.com
7077
```
7178

72-
### 运行`main.py`
79+
### 第三步、运行`main.py`
7380

7481
`python main.py`
7582

83+
## 致谢
84+
感谢 `Microsoft` 提供优秀的编辑器。
85+
86+
<a href="https://code.visualstudio.com/" target="_blank">
87+
<img alt="vscode" src="https://s3.bmp.ovh/imgs/2022/11/11/a21d853cbd99f164.png" width="150"/>
88+
</a>
89+
90+
感谢 `JetBrains` 提供优秀的IDE。
91+
92+
<a href="https://www.jetbrains.com/" target="_blank">
93+
<img alt="jetbrains" src="https://s3.bmp.ovh/imgs/2022/11/11/8f7309621f30a044.png" width="150"/>
94+
</a>
95+
7696
## 其他
7797

78-
本项目仅供学习使用,若出现任何问题,本项目及其发起人与参与者不承担任何责任。
98+
本项目仅供学习使用,请勿用于非法用途!若使用中出现任何问题,本项目及其发起人与参与者不承担任何责任。

config/config.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
name = Mys_Exch_Goods
33
env = local
44
branch = main
5-
version = 2.0.0
5+
version = 2.0.1
66

77
[user_info]
88
cookie =
99
uid =
1010
address_id =
11-
point =
1211

1312
[exchange_info]
1413
good_id =

get_info.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pyperclip
88
import requests
99

10-
from tools import write_config_file, update_cookie, get_gift_detail, check_game_roles, GAME_NAME, YS_SERVER
10+
from tools import write_config_file, update_cookie, get_gift_detail, check_game_roles, get_point, GAME_NAME, YS_SERVER
1111
import tools.global_var as gl
1212

1313

@@ -149,7 +149,7 @@ def get_address():
149149
address_id_in = input("请输入需要写入的地址序号(暂只支持一个): ")
150150
if address_id_in == "":
151151
re_input = input("未输入地址序号, 是否重新输入(默认为Y)?(y/n): ")
152-
elif not address_id_in.isdigit() or address_id < int(address_id_in) < 0:
152+
elif not address_id_in.isdigit() or address_id < int(address_id_in) or int(address_id_in) <= 0:
153153
re_input = input("地址序号输入错误, 是否重新输入(默认为Y)?(y/n): ")
154154
else:
155155
break
@@ -203,7 +203,7 @@ def get_game_uid():
203203
game_uid_in = input("请输入需要写入的游戏UID序号(暂只支持一个): ")
204204
if game_uid_in == "":
205205
re_input = input("未输入游戏UID序号, 是否重新输入(默认为Y)?(y/n): ")
206-
elif not game_uid_in.isdigit() or game_uid_id < int(game_uid_in) < 0:
206+
elif not game_uid_in.isdigit() or game_uid_id < int(game_uid_in) or int(game_uid_in) <= 0:
207207
re_input = input("游戏UID序号输入错误, 是否重新输入(默认为Y)?(y/n): ")
208208
else:
209209
break
@@ -274,6 +274,7 @@ def get_gift_list():
274274
"Cookie": gl.MI_COOKIE,
275275
}
276276
gift_id_list = []
277+
gift_point_list = []
277278
gift_num = 1
278279
while True:
279280
gift_list_req = requests.get(gift_list_url,
@@ -309,6 +310,7 @@ def get_gift_list():
309310
print(f"本月限购: {gift_data['account_cycle_limit']} 个")
310311
gift_num += 1
311312
gift_id_list.append(gift_data['goods_id'])
313+
gift_point_list.append(gift_data['price'])
312314
if gift_list['total'] > gift_list_params['page'] * gift_list_params['page_size']:
313315
gift_list_params['page'] += 1
314316
else:
@@ -319,9 +321,17 @@ def get_gift_list():
319321
gift_id_in = set(input("请输入需要抢购的商品序号,以空格分开(请注意现有米游币是否足够): ").split(' '))
320322
if '' not in gift_id_in:
321323
gift_id_write = ''
324+
gift_point = 0
322325
for gift_id in gift_id_in:
323326
if gift_id.isdigit() and 0 < int(gift_id) < gift_num:
324327
gift_id_write += gift_id_list[int(gift_id) - 1] + ','
328+
gift_point += gift_point_list[int(gift_id) - 1]
329+
user_point = get_point()
330+
if user_point and user_point < gift_point:
331+
print(f"当前米游币不足,当前米游币: {user_point},所需米游币: {gift_point}")
332+
choice = input("是否继续选择商品, 取消将返回上级菜单(默认为继续Y/N): ")
333+
if choice in ('n', 'N'):
334+
return True
325335
if gl.INI_CONFIG.get('exchange_info', 'good_id'):
326336
while True:
327337
print("检测到已存在商品id,需要的操作是\n1.追加\n2.替换\n3.删除\n4.取消")
@@ -369,7 +379,8 @@ def info_main():
369379
2. 查询收货地址
370380
3. 查询绑定游戏UID
371381
4. 查询商品ID
372-
5. 更新Cookie
382+
5. 查询米游币
383+
6. 更新Cookie
373384
0. 返回主菜单""")
374385
select_function = input("请输入选择功能的序号: ")
375386
os.system(gl.CLEAR_TYPE)
@@ -382,6 +393,11 @@ def info_main():
382393
elif select_function == "4":
383394
get_gift_list()
384395
elif select_function == "5":
396+
now_point = get_point()
397+
if now_point:
398+
print(f"当前米游币: {now_point}")
399+
input("按回车键继续")
400+
elif select_function == "6":
385401
update_cookie()
386402
elif select_function == "0":
387403
return

tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
初始化
33
"""
44
from .com_tool import check_plat, load_config, get_cookie_str, write_config_file, check_update, get_time, md5_encode
5-
from .mi_tool import update_cookie, check_cookie, get_gift_detail, check_game_roles, GAME_NAME, YS_SERVER
5+
from .mi_tool import update_cookie, check_cookie, get_gift_detail, check_game_roles, get_point, GAME_NAME, YS_SERVER

tools/com_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import tools.global_var as gl
1515

16-
MAIN_VERSION = '2.0.0'
16+
MAIN_VERSION = '2.0.1'
1717
CHECK_UPDATE_URL_LIST = [
1818
'https://cdn.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',
1919
'https://fastly.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',

tools/mi_tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def get_point():
104104
需要stoken与stuid
105105
"""
106106
try:
107+
if get_cookie_str("stoken") == "" or get_cookie_str("stuid") == "":
108+
return False
107109
point_url = gl.BBS_URL + '/apihub/sapi/getUserMissionsState'
108110
point_headers = {
109111
'Cookie': gl.MI_COOKIE,
@@ -118,7 +120,7 @@ def get_point():
118120
print(f"获取米游币数量失败, 原因为{point_req['message']}")
119121
input("按回车键继续")
120122
return False
121-
return point_req['data']['total_points'], point_req['data']['can_get_points']
123+
return point_req['data']['total_points']
122124
except Exception as err:
123125
print(f"运行出错, 错误为: {err}, 错误行数为: {err.__traceback__.tb_lineno}")
124126
input("按回车键继续")

update_log.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
"version": "2.0.0",
2727
"update_time": "2022-11-10",
2828
"update_content": ["1.项目目录重构", "2.优化部分功能逻辑"]
29+
},
30+
{
31+
"version": "2.0.1",
32+
"update_time": "2022-11-11",
33+
"update_content": ["1.修复部分输入判断逻辑", "2.添加当前米游币数量判断"]
2934
}
3035
]
3136
}

0 commit comments

Comments
 (0)