Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

合并DEV #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches:
- main
- dev
pull_request:
# The branches below must be a subset of the branches above
branches:
- main
- dev

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# 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
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# Mys-Exchange-Goods
用于兑换米游社商品
# 米游社商品兑换
<div align="left">
<a href="https://github.com/GOOD-AN/Mys-Exchange-Goods/releases/latest" target="_blank">
<img alt="最新发行版" src="https://img.shields.io/github/v/release/GOOD-AN/Mys-Exchange-Goods?logo=python&style=for-the-badge">
</a>
<img alt="Python 版本要求" src="https://img.shields.io/badge/Python-3.6+-green.svg?longCache=true&style=for-the-badge">
<img alt="GitHub CodeQL 代码检查" src="https://img.shields.io/github/workflow/status/GOOD-AN/Mys-Exchange-Goods/CodeQL?logo=github&style=for-the-badge">
<img alt="开源协议" src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
</div>

## 使用说明

### 安装所需运行库
### 第一步、安装所需运行库

`pip install -r requirements.txt`

### 配置`config.ini`文件
### 第二步、配置`config.ini`文件

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

[user_info]
**[user_info]**

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

[exchange_info]
**[exchange_info]**

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

[check_network]
**[check_network]**

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

[ntp]
**[ntp]**

| 参数 | 说明 |
|------------|-----------------|
Expand Down Expand Up @@ -69,10 +76,23 @@ enable = true
ntp_server = ntp.aliyun.com
```

### 运行`main.py`
### 第三步、运行`main.py`

`python main.py`

## 致谢
感谢 `Microsoft` 提供优秀的编辑器。

<a href="https://code.visualstudio.com/" target="_blank">
<img alt="vscode" src="https://s3.bmp.ovh/imgs/2022/11/11/a21d853cbd99f164.png" width="150"/>
</a>

感谢 `JetBrains` 提供优秀的IDE。

<a href="https://www.jetbrains.com/" target="_blank">
<img alt="jetbrains" src="https://s3.bmp.ovh/imgs/2022/11/11/8f7309621f30a044.png" width="150"/>
</a>

## 其他

本项目仅供学习使用,若出现任何问题,本项目及其发起人与参与者不承担任何责任。
本项目仅供学习使用,请勿用于非法用途!若使用中出现任何问题,本项目及其发起人与参与者不承担任何责任。
3 changes: 1 addition & 2 deletions config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
name = Mys_Exch_Goods
env = local
branch = main
version = 2.0.0
version = 2.0.1

[user_info]
cookie =
uid =
address_id =
point =

[exchange_info]
good_id =
Expand Down
24 changes: 20 additions & 4 deletions get_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pyperclip
import requests

from tools import write_config_file, update_cookie, get_gift_detail, check_game_roles, GAME_NAME, YS_SERVER
from tools import write_config_file, update_cookie, get_gift_detail, check_game_roles, get_point, GAME_NAME, YS_SERVER
import tools.global_var as gl


Expand Down Expand Up @@ -149,7 +149,7 @@ def get_address():
address_id_in = input("请输入需要写入的地址序号(暂只支持一个): ")
if address_id_in == "":
re_input = input("未输入地址序号, 是否重新输入(默认为Y)?(y/n): ")
elif not address_id_in.isdigit() or address_id < int(address_id_in) < 0:
elif not address_id_in.isdigit() or address_id < int(address_id_in) or int(address_id_in) <= 0:
re_input = input("地址序号输入错误, 是否重新输入(默认为Y)?(y/n): ")
else:
break
Expand Down Expand Up @@ -203,7 +203,7 @@ def get_game_uid():
game_uid_in = input("请输入需要写入的游戏UID序号(暂只支持一个): ")
if game_uid_in == "":
re_input = input("未输入游戏UID序号, 是否重新输入(默认为Y)?(y/n): ")
elif not game_uid_in.isdigit() or game_uid_id < int(game_uid_in) < 0:
elif not game_uid_in.isdigit() or game_uid_id < int(game_uid_in) or int(game_uid_in) <= 0:
re_input = input("游戏UID序号输入错误, 是否重新输入(默认为Y)?(y/n): ")
else:
break
Expand Down Expand Up @@ -274,6 +274,7 @@ def get_gift_list():
"Cookie": gl.MI_COOKIE,
}
gift_id_list = []
gift_point_list = []
gift_num = 1
while True:
gift_list_req = requests.get(gift_list_url,
Expand Down Expand Up @@ -309,6 +310,7 @@ def get_gift_list():
print(f"本月限购: {gift_data['account_cycle_limit']} 个")
gift_num += 1
gift_id_list.append(gift_data['goods_id'])
gift_point_list.append(gift_data['price'])
if gift_list['total'] > gift_list_params['page'] * gift_list_params['page_size']:
gift_list_params['page'] += 1
else:
Expand All @@ -319,9 +321,17 @@ def get_gift_list():
gift_id_in = set(input("请输入需要抢购的商品序号,以空格分开(请注意现有米游币是否足够): ").split(' '))
if '' not in gift_id_in:
gift_id_write = ''
gift_point = 0
for gift_id in gift_id_in:
if gift_id.isdigit() and 0 < int(gift_id) < gift_num:
gift_id_write += gift_id_list[int(gift_id) - 1] + ','
gift_point += gift_point_list[int(gift_id) - 1]
user_point = get_point()
if user_point and user_point < gift_point:
print(f"当前米游币不足,当前米游币: {user_point},所需米游币: {gift_point}")
choice = input("是否继续选择商品, 取消将返回上级菜单(默认为继续Y/N): ")
if choice in ('n', 'N'):
return True
if gl.INI_CONFIG.get('exchange_info', 'good_id'):
while True:
print("检测到已存在商品id,需要的操作是\n1.追加\n2.替换\n3.删除\n4.取消")
Expand Down Expand Up @@ -369,7 +379,8 @@ def info_main():
2. 查询收货地址
3. 查询绑定游戏UID
4. 查询商品ID
5. 更新Cookie
5. 查询米游币
6. 更新Cookie
0. 返回主菜单""")
select_function = input("请输入选择功能的序号: ")
os.system(gl.CLEAR_TYPE)
Expand All @@ -382,6 +393,11 @@ def info_main():
elif select_function == "4":
get_gift_list()
elif select_function == "5":
now_point = get_point()
if now_point:
print(f"当前米游币: {now_point}")
input("按回车键继续")
elif select_function == "6":
update_cookie()
elif select_function == "0":
return
Expand Down
2 changes: 1 addition & 1 deletion tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
初始化
"""
from .com_tool import check_plat, load_config, get_cookie_str, write_config_file, check_update, get_time, md5_encode
from .mi_tool import update_cookie, check_cookie, get_gift_detail, check_game_roles, GAME_NAME, YS_SERVER
from .mi_tool import update_cookie, check_cookie, get_gift_detail, check_game_roles, get_point, GAME_NAME, YS_SERVER
2 changes: 1 addition & 1 deletion tools/com_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import tools.global_var as gl

MAIN_VERSION = '2.0.0'
MAIN_VERSION = '2.0.1'
CHECK_UPDATE_URL_LIST = [
'https://cdn.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',
'https://fastly.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',
Expand Down
4 changes: 3 additions & 1 deletion tools/mi_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def get_point():
需要stoken与stuid
"""
try:
if get_cookie_str("stoken") == "" or get_cookie_str("stuid") == "":
return False
point_url = gl.BBS_URL + '/apihub/sapi/getUserMissionsState'
point_headers = {
'Cookie': gl.MI_COOKIE,
Expand All @@ -118,7 +120,7 @@ def get_point():
print(f"获取米游币数量失败, 原因为{point_req['message']}")
input("按回车键继续")
return False
return point_req['data']['total_points'], point_req['data']['can_get_points']
return point_req['data']['total_points']
except Exception as err:
print(f"运行出错, 错误为: {err}, 错误行数为: {err.__traceback__.tb_lineno}")
input("按回车键继续")
Expand Down
5 changes: 5 additions & 0 deletions update_log.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"version": "2.0.0",
"update_time": "2022-11-10",
"update_content": ["1.项目目录重构", "2.优化部分功能逻辑"]
},
{
"version": "2.0.1",
"update_time": "2022-11-11",
"update_content": ["1.修复部分输入判断逻辑", "2.添加当前米游币数量判断"]
}
]
}