Compare commits
235 Commits
v2.1.3
...
v4.2.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f45dc3a34c | ||
|
|
1c17f3d878 | ||
|
|
75e4d2b290 | ||
|
|
32fe941735 | ||
|
|
27633b1017 | ||
|
|
c34ca0dea9 | ||
|
|
0574e9c6cb | ||
|
|
b7f09141f1 | ||
|
|
022e59e65c | ||
|
|
a0731331a8 | ||
|
|
4b01222648 | ||
|
|
cae4b26c89 | ||
|
|
427c2332f5 | ||
|
|
6f0aec329b | ||
|
|
4e4d1d068f | ||
|
|
074f4f2ca9 | ||
|
|
c51f9ad901 | ||
|
|
792452c048 | ||
|
|
662eb0bc7f | ||
|
|
94a9bdbb93 | ||
|
|
df96183f42 | ||
|
|
a5b4f6f59f | ||
|
|
6f7497cbe9 | ||
|
|
dbdc2144b7 | ||
|
|
e34106f857 | ||
|
|
c3c07804cd | ||
|
|
0b5ac6bb6e | ||
|
|
ea87eefb9b | ||
|
|
20dc4656dc | ||
|
|
3f0f1612e3 | ||
|
|
e92b6ecfe6 | ||
|
|
37502b6fd8 | ||
|
|
8c1c3c5675 | ||
|
|
b4228e3f35 | ||
|
|
e78f3973be | ||
|
|
29536003a4 | ||
|
|
ffa3767198 | ||
|
|
8702070725 | ||
|
|
793259a194 | ||
|
|
3a63a73244 | ||
|
|
43448cc68d | ||
|
|
f0d272cce5 | ||
|
|
9983455b60 | ||
|
|
0a411c150a | ||
|
|
89b49a1143 | ||
|
|
917454c0b9 | ||
|
|
170b87e7a8 | ||
|
|
68db248a7e | ||
|
|
24614099ed | ||
|
|
8bbfdcbc04 | ||
|
|
126799d2a2 | ||
|
|
c625354dec | ||
|
|
7e08c88a3e | ||
|
|
764d0afb50 | ||
|
|
fe87547406 | ||
|
|
a1fd27722b | ||
|
|
3bd6611cd5 | ||
|
|
f3e1b4580a | ||
|
|
449d8a032e | ||
|
|
b40fa35622 | ||
|
|
ff7e433634 | ||
|
|
1ea9d10bb4 | ||
|
|
04fd2b10fa | ||
|
|
e79417ec5e | ||
|
|
684211c129 | ||
|
|
f94e129cba | ||
|
|
87a140d373 | ||
|
|
f135a6510f | ||
|
|
6960184911 | ||
|
|
7bd270c662 | ||
|
|
f54e83673f | ||
|
|
ee40fdb3c3 | ||
|
|
52ebf7b027 | ||
|
|
85891dc918 | ||
|
|
7348a87a20 | ||
|
|
1dfa3e3f44 | ||
|
|
37ced2e535 | ||
|
|
11876acc62 | ||
|
|
756c0926ec | ||
|
|
9604fc9a8e | ||
|
|
5bcc527889 | ||
|
|
0d616289ed | ||
|
|
a8473b6a04 | ||
|
|
e1352586b7 | ||
|
|
849d5f18eb | ||
|
|
77298f4dab | ||
|
|
b7a2b045fb | ||
|
|
c7072da81d | ||
|
|
4c9b9fb74a | ||
|
|
feb4b516a4 | ||
|
|
d50191c6b8 | ||
|
|
3db3fa4e1f | ||
|
|
ad31961c2b | ||
|
|
ccdaefeb61 | ||
|
|
8c9bcba198 | ||
|
|
a273af0abe | ||
|
|
05a063b001 | ||
|
|
8487195512 | ||
|
|
250c47ccb7 | ||
|
|
e5aeb4f3a7 | ||
|
|
eab8d984e6 | ||
|
|
6b3f19a618 | ||
|
|
d5f8871064 | ||
|
|
77e899957c | ||
|
|
dd3515305c | ||
|
|
73c3ec4820 | ||
|
|
fde5160d56 | ||
|
|
13923705e5 | ||
|
|
d3afc95261 | ||
|
|
326d7e474c | ||
|
|
537b5d9725 | ||
|
|
697c1b5b43 | ||
|
|
2b6057161e | ||
|
|
8e2a6444bd | ||
|
|
b04df40b7d | ||
|
|
3e17d94904 | ||
|
|
29123054cc | ||
|
|
530c038985 | ||
|
|
2e9d2f0491 | ||
|
|
69ab9b4f15 | ||
|
|
1c8b940925 | ||
|
|
0e05a4ea18 | ||
|
|
9e4285b4c5 | ||
|
|
e89d2af8ae | ||
|
|
8e7d663060 | ||
|
|
179b33387e | ||
|
|
2c9a7c443f | ||
|
|
0de964e68c | ||
|
|
97046af931 | ||
|
|
ec24e776e7 | ||
|
|
92d4ef05fa | ||
|
|
fb27c50c75 | ||
|
|
0141bf039a | ||
|
|
54f9bb7f21 | ||
|
|
2c4e5eb5cc | ||
|
|
cd42f45a1f | ||
|
|
ec38895765 | ||
|
|
fc30579bbc | ||
|
|
3e6223e4e5 | ||
|
|
27c71124ff | ||
|
|
3a8a8a36f5 | ||
|
|
ed6de5e806 | ||
|
|
bf8a5befa3 | ||
|
|
a3fe641f6b | ||
|
|
f4f99c25db | ||
|
|
640d80e334 | ||
|
|
4f196b516f | ||
|
|
87f07bf95c | ||
|
|
1bfd7891b5 | ||
|
|
472eb0ee52 | ||
|
|
7638c67da6 | ||
|
|
7a0c143b5b | ||
|
|
fff8e11524 | ||
|
|
af24208cf3 | ||
|
|
85bccea2dd | ||
|
|
f7c8cac6ec | ||
|
|
97a5ac5bb0 | ||
|
|
1d57076010 | ||
|
|
d298ac872c | ||
|
|
c0581e781c | ||
|
|
6befd6341a | ||
|
|
504ef8dd68 | ||
|
|
127500d890 | ||
|
|
ab94173df7 | ||
|
|
e50697aae1 | ||
|
|
c71389fc0b | ||
|
|
732129ba34 | ||
|
|
77dfc895ed | ||
|
|
0c6f3123f8 | ||
|
|
e872d30b3a | ||
|
|
48fa4413c8 | ||
|
|
94e693db77 | ||
|
|
025d328d79 | ||
|
|
d086a5a152 | ||
|
|
5f2337d949 | ||
|
|
5e163181a8 | ||
|
|
0913cbb813 | ||
|
|
6aed64ce4e | ||
|
|
3c95e58fb2 | ||
|
|
64d0d4ed41 | ||
|
|
7fb659c511 | ||
|
|
d4ec91940f | ||
|
|
77f63ebb44 | ||
|
|
051b062e29 | ||
|
|
ec9083b556 | ||
|
|
156080a3b7 | ||
|
|
5b6effd43e | ||
|
|
97e8d41c39 | ||
|
|
d64ef447d2 | ||
|
|
461b2a62b0 | ||
|
|
f8988651b5 | ||
|
|
ffe865e29e | ||
|
|
cd5250c09f | ||
|
|
8f01bf6027 | ||
|
|
81eb11f5c5 | ||
|
|
80cadfa52c | ||
|
|
9974d70d99 | ||
|
|
6e3e4662f4 | ||
|
|
e2fb2e5565 | ||
|
|
6f8be226b0 | ||
|
|
2606f1e587 | ||
|
|
4d1fd7ea76 | ||
|
|
e61fbe6c69 | ||
|
|
0c287577ca | ||
|
|
a4aa562db9 | ||
|
|
33c5ff3a52 | ||
|
|
7c8e43bd35 | ||
|
|
bc0014dbe6 | ||
|
|
e41eca33bc | ||
|
|
e39b965459 | ||
|
|
f2aa3d7347 | ||
|
|
76c126284f | ||
|
|
44ee917d88 | ||
|
|
669019c051 | ||
|
|
4685c12570 | ||
|
|
d815529510 | ||
|
|
1da3620feb | ||
|
|
44d529c60f | ||
|
|
cdbcebd945 | ||
|
|
5bc2bf9397 | ||
|
|
d41419a579 | ||
|
|
a7e15e509e | ||
|
|
6518a378ac | ||
|
|
ebb73182f7 | ||
|
|
8fcc69165f | ||
|
|
5b98c58926 | ||
|
|
ce1534657b | ||
|
|
e2f02ea616 | ||
|
|
76134c2e2b | ||
|
|
2010855139 | ||
|
|
e550b9a155 | ||
|
|
53049d4acd | ||
|
|
bb4b45bc36 | ||
|
|
caf37e6c99 | ||
|
|
5af41d3b72 |
153
.github/workflows/build-app.yml
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
name: Build AUTO_MAA
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
pre_check:
|
||||
name: Pre Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Repo Check
|
||||
id: repo_check
|
||||
run: |
|
||||
if [[ "$GITHUB_REPOSITORY" != "DLmaster361/AUTO_MAA" ]]; then
|
||||
echo "When forking this repository to make your own builds, you have to adjust this check."
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
build_AUTO_MAA:
|
||||
runs-on: windows-latest
|
||||
needs: pre_check
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8 pytest
|
||||
pip install -r requirements.txt
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
copy app\utils\package.py .\
|
||||
python package.py
|
||||
- name: Read version
|
||||
id: read_version
|
||||
run: |
|
||||
$MAIN_VERSION=(Get-Content -Path "version_info.txt" -TotalCount 1).Trim()
|
||||
"AUTO_MAA_version=$MAIN_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
$UPDATER_VERSION=(Get-Content -Path "version_info.txt" -TotalCount 2 | Select-Object -Index 1).Trim()
|
||||
"updater_version=$UPDATER_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
- name: Create Zip
|
||||
id: create_zip
|
||||
run: |
|
||||
Compress-Archive -Path app,resources,main.py,AUTO_MAA.exe,requirements.txt,README.md,LICENSE -DestinationPath AUTO_MAA_${{ env.AUTO_MAA_version }}.zip
|
||||
Compress-Archive -Path Updater.exe -DestinationPath Updater_${{ env.updater_version }}.zip
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: AUTO_MAA_${{ env.AUTO_MAA_version }}
|
||||
path: |
|
||||
AUTO_MAA_${{ env.AUTO_MAA_version }}.zip
|
||||
Updater_${{ env.updater_version }}.zip
|
||||
- name: Upload Version_Info Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: version_info
|
||||
path: version_info.txt
|
||||
publish_release:
|
||||
name: Publish release
|
||||
needs: build_AUTO_MAA
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: AUTO_MAA_*
|
||||
merge-multiple: true
|
||||
path: artifacts
|
||||
- name: Download Version_Info
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: version_info
|
||||
path: ./
|
||||
- name: Check if release exists
|
||||
id: check_if_release_exists
|
||||
run: |
|
||||
release_id=$(gh release view $(sed 's/\r$//g' <(head -n 1 version_info.txt)) --json id --jq .id || true)
|
||||
if [[ -z $release_id ]]; then
|
||||
echo "release_exists=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "release_exists=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
- name: Create release
|
||||
id: create_release
|
||||
if: steps.check_if_release_exists.outputs.release_exists == 'false'
|
||||
run: |
|
||||
set -xe
|
||||
shopt -s nullglob
|
||||
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
|
||||
NOTES_TAIL="\`\`\`本release通过GitHub Actions自动构建\`\`\`"
|
||||
NOTES="$NOTES_MAIN<br><br>$NOTES_TAIL"
|
||||
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" artifacts/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
- name: Update release
|
||||
id: update_release
|
||||
if: steps.check_if_release_exists.outputs.release_exists == 'true'
|
||||
run: |
|
||||
set -xe
|
||||
shopt -s nullglob
|
||||
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
|
||||
NOTES_TAIL="\`\`\`本release通过GitHub Actions自动构建\`\`\`"
|
||||
NOTES="$NOTES_MAIN<br><br>$NOTES_TAIL"
|
||||
gh release delete "$TAGNAME" --yes
|
||||
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" artifacts/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
153
.github/workflows/build-pre.yml
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
name: Build AUTO_MAA_Pre
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "dev" ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'LICENSE'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
pre_check:
|
||||
name: Pre Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Repo Check
|
||||
id: repo_check
|
||||
run: |
|
||||
if [[ "$GITHUB_REPOSITORY" != "DLmaster361/AUTO_MAA" ]]; then
|
||||
echo "When forking this repository to make your own builds, you have to adjust this check."
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
build_AUTO_MAA:
|
||||
runs-on: windows-latest
|
||||
needs: pre_check
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8 pytest
|
||||
pip install -r requirements.txt
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
copy app\utils\package.py .\
|
||||
python package.py
|
||||
- name: Read version
|
||||
id: read_version
|
||||
run: |
|
||||
$MAIN_VERSION=(Get-Content -Path "version_info.txt" -TotalCount 1).Trim()
|
||||
"AUTO_MAA_version=$MAIN_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
$UPDATER_VERSION=(Get-Content -Path "version_info.txt" -TotalCount 2 | Select-Object -Index 1).Trim()
|
||||
"updater_version=$UPDATER_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
- name: Create Zip
|
||||
id: create_zip
|
||||
run: |
|
||||
Compress-Archive -Path app,resources,main.py,AUTO_MAA.exe,requirements.txt,README.md,LICENSE -DestinationPath AUTO_MAA_${{ env.AUTO_MAA_version }}.zip
|
||||
Compress-Archive -Path Updater.exe -DestinationPath Updater_${{ env.updater_version }}.zip
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: AUTO_MAA_${{ env.AUTO_MAA_version }}
|
||||
path: |
|
||||
AUTO_MAA_${{ env.AUTO_MAA_version }}.zip
|
||||
Updater_${{ env.updater_version }}.zip
|
||||
- name: Upload Version_Info Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: version_info
|
||||
path: version_info.txt
|
||||
publish_prerelease:
|
||||
name: Publish prerelease
|
||||
needs: build_AUTO_MAA
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: AUTO_MAA_*
|
||||
merge-multiple: true
|
||||
path: artifacts
|
||||
- name: Download Version_Info
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: version_info
|
||||
path: ./
|
||||
- name: Check if release exists
|
||||
id: check_if_release_exists
|
||||
run: |
|
||||
release_id=$(gh release view $(sed 's/\r$//g' <(head -n 1 version_info.txt)) --json id --jq .id || true)
|
||||
if [[ -z $release_id ]]; then
|
||||
echo "release_exists=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "release_exists=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
- name: Create prerelease
|
||||
id: create_prerelease
|
||||
if: steps.check_if_release_exists.outputs.release_exists == 'false'
|
||||
run: |
|
||||
set -xe
|
||||
shopt -s nullglob
|
||||
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
|
||||
NOTES_TAIL="\`\`\`本release通过GitHub Actions自动构建\`\`\`"
|
||||
NOTES="$NOTES_MAIN<br><br>$NOTES_TAIL"
|
||||
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
- name: Update prerelease
|
||||
id: update_prerelease
|
||||
if: steps.check_if_release_exists.outputs.release_exists == 'true'
|
||||
run: |
|
||||
set -xe
|
||||
shopt -s nullglob
|
||||
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
|
||||
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
|
||||
NOTES_TAIL="\`\`\`本release通过GitHub Actions自动构建\`\`\`"
|
||||
NOTES="$NOTES_MAIN<br><br>$NOTES_TAIL"
|
||||
gh release delete "$TAGNAME" --yes
|
||||
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
|
||||
BIN
AUTO_MAA.exe
76
AUTO_MAA.py
@@ -1,76 +0,0 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import atexit
|
||||
import datetime
|
||||
import time
|
||||
import os
|
||||
from termcolor import colored
|
||||
|
||||
#资源回收
|
||||
def cleanup():
|
||||
if os.path.exists("state/BEGIN"):
|
||||
os.remove("state/BEGIN")
|
||||
|
||||
DATABASE="data/data.db"
|
||||
|
||||
#设置回调函数
|
||||
atexit.register(cleanup)
|
||||
while True:
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM timeset WHERE True")
|
||||
timeset=cur.fetchall()
|
||||
cur.close()
|
||||
db.close()
|
||||
timeset=[list(row) for row in timeset]
|
||||
timeset=[timeset[i][0] for i in range(len(timeset))]
|
||||
for i in range(60):
|
||||
#展示当前信息
|
||||
curtime=datetime.datetime.now().strftime("%H:%M")
|
||||
os.system('cls')
|
||||
if len(timeset)!=0:
|
||||
print(colored("设定时间:"+','.join(timeset),'green'))
|
||||
print(colored("当前时间:"+curtime,'green'))
|
||||
print(colored("运行日志:",'green'))
|
||||
if os.path.exists("state/running"):
|
||||
print(colored("正在运行代理",'yellow'))
|
||||
elif os.path.exists("log.txt"):
|
||||
with open("log.txt",'r',encoding="utf-8") as f:
|
||||
linex=f.read()
|
||||
print(colored(linex,'light_green'))
|
||||
else:
|
||||
print(colored("暂无",'light_green'))
|
||||
#定时执行
|
||||
if (curtime in timeset) and not os.path.exists("state/running"):
|
||||
with open("state/BEGIN","w",encoding="utf-8") as f:
|
||||
print("BEGIN",file=f)
|
||||
run=subprocess.Popen(["run.exe"])
|
||||
runpid=run.pid
|
||||
while True:
|
||||
if os.path.exists("state/END"):
|
||||
os.system('taskkill /F /T /PID '+str(runpid))
|
||||
os.remove("state/END")
|
||||
break
|
||||
time.sleep(1)
|
||||
os.remove("state/BEGIN")
|
||||
time.sleep(1)
|
||||
358
README.md
@@ -1,262 +1,198 @@
|
||||
# AUTO_MAA
|
||||
|
||||
MAA多账号管理与自动化软件
|
||||
|
||||

|
||||

|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
---
|
||||
|
||||
</h1>
|
||||
|
||||
[](https://github.com/DLmaster361/AUTO_MAA/stargazers)
|
||||
[](https://github.com/DLmaster361/AUTO_MAA/network)
|
||||
[](https://github.com/DLmaster361/AUTO_MAA/issues)
|
||||
[](https://github.com/DLmaster361/AUTO_MAA/graphs/contributors)
|
||||
[](https://github.com/DLmaster361/AUTO_MAA/blob/main/LICENSE)
|
||||
</div>
|
||||
|
||||
## 软件介绍
|
||||
|
||||
### 性质
|
||||
|
||||
本软件是明日方舟第三方软件`MAA`的第三方工具,即第3<sup>3</sup>方软件。旨在优化MAA多账号功能体验,并通过一些方法解决MAA项目未能解决的部分问题,提高代理的稳定性。
|
||||
|
||||
### 原理
|
||||
|
||||
本软件可以存储多个明日方舟账号数据,并通过以下流程实现代理功能:
|
||||
|
||||
1. **配置:** 根据对应用户的配置信息,生成配置文件并将其导入MAA。
|
||||
2. **监测:** 在MAA开始代理后,持续读取MAA的日志以判断其运行状态。当软件认定MAA出现异常时,通过重启MAA使之仍能继续完成任务。
|
||||
3. **循环:** 重复上述步骤,使MAA依次完成各个用户的自动代理任务。
|
||||
|
||||
### 优势
|
||||
|
||||
- **节省运行开销:** 只需要一份MAA软件与一个模拟器,无需多开就能完成多账号代理,羸弱的电脑也能代理日常。
|
||||
- **自定义空间大:** 依靠高级用户配置模式,支持MAA几乎所有设置选项自定义,支持模拟器多开。
|
||||
- **调度方法自由:** 通过调度队列功能,自由实现MAA多开等多种调度方式。
|
||||
- **一键代理无忧:** 无须中途手动修改MAA配置,将繁琐交给AUTO_MAA,把游戏留给自己。
|
||||
- **代理结果复核:** 通过人工排查功能核实各用户代理情况,堵住自动代理的最后一丝风险。
|
||||
|
||||
## 重要声明
|
||||
本软件是一个外部工具,旨在优化MAA多账号功能体验。该软件包可以存储明日方舟多账号数据,并通过修改MAA配置文件、读取MAA日志等行为自动完成多账号代理。本开发团队承诺,不会修改明日方舟游戏本体与相关配置文件。
|
||||
|
||||
本项目使用GPL开源,相关细则如下:
|
||||
本开发团队承诺,不会修改明日方舟游戏本体与相关配置文件。本项目使用GPL开源,相关细则如下:
|
||||
|
||||
- **作者:** AUTO_MAA软件作者为DLmaster、DLmaster361或DLmaster_361,以上均指代同一人。
|
||||
- **使用:** AUTO_MAA使用者可以按自己的意愿自由使用本软件。依据GPL,对于由此可能产生的损失,AUTO_MAA项目组不负任何责任
|
||||
- **分发:** AUTO_MAA允许任何人自由分发本软件,包括进行商业活动牟利。但所有分发者必须遵循GPL向接收者提供本软件项目地址、完整的软件源码与GPL协议原文(件),违反者可能会被追究法律责任
|
||||
- **传播:** AUTO_MAA原则上允许传播者自由传播本软件。但由于软件性质,项目组不希望发现任何人在明日方舟官方媒体(包括官方媒体账号与森空岛社区等)或明日方舟游戏相关内容(包括同好群、线下活动与游戏内容讨论等)下提及AUTO_MAA或MAA,希望各位理解
|
||||
- **衍生:** AUTO_MAA允许任何人对软件本体或软件部分代码进行二次开发或利用。但依据GPL,相关成果也必须使用GPL开源
|
||||
- **授权:** 如果希望在使用AUTO_MAA的相关成果后仍保持自己的项目闭源,请在Issues中说明来意。得到项目组认可后,我们可以提供另一份使用不同协议的代码,此协议主要内容如下:被授权者可以自由使用该代码并维持闭源;被授权者必须定期为AUTO_MAA作出贡献
|
||||
- **贡献:** 不论是直接参与软件的维护编写,或是撰写文档、测试、反馈BUG、给出建议、参与讨论,都为AUTO_MAA项目的发展完善做出了不可忽视的贡献。项目组提倡各位贡献者遵照GitHub开源社区惯例,发布Issues参与项目。避免私信或私发邮件(安全性漏洞或敏感问题除外),以帮助更多用户
|
||||
- **使用:** AUTO_MAA使用者可以按自己的意愿自由使用本软件。依据GPL,对于由此可能产生的损失,AUTO_MAA项目组不负任何责任。
|
||||
- **分发:** AUTO_MAA允许任何人自由分发本软件,包括进行商业活动牟利。若为直接分发本软件,必须遵循GPL向接收者提供本软件项目地址、完整的软件源码与GPL协议原文(件);若为修改软件后进行分发,必须遵循GPL向接收者提供本软件项目地址、修改前的完整软件源码副本与GPL协议原文(件),违反者可能会被追究法律责任。
|
||||
- **传播:** AUTO_MAA原则上允许传播者自由传播本软件,但无论在何种传播过程中,不得删除项目作者与开发者所留版权声明,不得隐瞒项目作者与相关开发者的存在。由于软件性质,项目组不希望发现任何人在明日方舟官方媒体(包括官方媒体账号与森空岛社区等)或明日方舟游戏相关内容(包括同好群、线下活动与游戏内容讨论等)下提及AUTO_MAA或MAA,希望各位理解。
|
||||
- **衍生:** AUTO_MAA允许任何人对软件本体或软件部分代码进行二次开发或利用。但依据GPL,相关成果再次分发时也必须使用GPL或兼容的协议开源。
|
||||
- **贡献:** 不论是直接参与软件的维护编写,或是撰写文档、测试、反馈BUG、给出建议、参与讨论,都为AUTO_MAA项目的发展完善做出了不可忽视的贡献。项目组提倡各位贡献者遵照GitHub开源社区惯例,发布Issues参与项目。避免私信或私发邮件(安全性漏洞或敏感问题除外),以帮助更多用户。
|
||||
|
||||
以上细则是本项目对GPL的相关补充与强调。未提及的以GPL为准,发生冲突的以GPL为准。如有不清楚的部分,请发Issues询问。若发生纠纷,相关内容也没有在Issues上提及的,项目组拥有最终解释权
|
||||
以上细则是本项目对GPL的相关补充与强调。未提及的以GPL为准,发生冲突的以本细则为准。如有不清楚的部分,请发Issues询问。若发生纠纷,相关内容也没有在Issues上提及的,项目组拥有最终解释权。
|
||||
|
||||
**注意**
|
||||
- 由于本软件有修改其它目录JSON文件等行为,使用前请将AUTO_MAA添加入Windows Defender信任区以及防病毒软件的信任区或开发者目录,避免被误杀
|
||||
- 如程序无法正常启动,请删除`state`目录下所有文件后重试
|
||||
|
||||
## 安装与配置MAA
|
||||
- 由于本软件有修改其它目录JSON文件等行为,使用前请将AUTO_MAA添加入Windows Defender信任区以及防病毒软件的信任区或开发者目录,避免被误杀。
|
||||
|
||||
本软件是MAA的外部工具,需要安装配置MAA后才能使用。
|
||||
---
|
||||
|
||||
### MAA安装
|
||||
# 使用方法
|
||||
|
||||
什么是MAA? [官网](https://maa.plus/)/[GitHub](https://github.com/CHNZYX/Auto_Simulated_Universe/archive/refs/heads/main.zip)
|
||||
|
||||
MAA下载地址 [GitHub下载](https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases)
|
||||
|
||||
### MAA配置
|
||||
|
||||
1.完成MAA的adb配置等基本配置
|
||||
|
||||
2.在“完成后”菜单,选择“退出MAA和模拟器”。勾选“手动输入关卡名”和“无限吃48小时内过期的理智药”
|
||||
|
||||

|
||||
|
||||
3.确保当前配置名为“Default”,取消所有“定时执行”
|
||||
|
||||

|
||||
|
||||
4.取消勾选“开机自启动MAA”,勾选“启动MAA后直接运行”和“启动MAA后自动开启模拟器”。配置自己模拟器所在的位置并根据实际情况填写“等待模拟器启动时间”(建议预留10s以防意外)。如果是多开用户,需要填写“附加命令”,具体填写值参见多开模拟器对应快捷方式路径(如“-v 1”)。
|
||||
|
||||

|
||||
|
||||
5.勾选“定时检查更新”、“自动下载更新包”和“自动安装更新包”
|
||||
|
||||

|
||||
|
||||
## 下载AUTO_MAA软件包 [](https://github.com/DLmaster361/AUTO_MAA/releases)
|
||||
|
||||
GitHub下载地址 [GitHub下载](https://github.com/DLmaster361/AUTO_MAA/releases)
|
||||
|
||||
## 配置用户信息与相关参数
|
||||
|
||||
**注意:** 当前所有的密码输入部分都存在一点“小问题”,请在输入密码时避免输入Delete、F12、Tab等功能键。
|
||||
|
||||
-------------------------------------------------
|
||||
|
||||
### 第一次启动
|
||||
|
||||
双击启动`manage.exe`,输入MAA所在文件夹路径并回车(注意使用斜杠的种类,不要使用反斜杠),然后设置管理密钥(密钥可以包含字母大小写与特殊字符)。
|
||||
|
||||

|
||||
|
||||
管理密钥是解密用户密码的唯一凭证,与数据库绑定。密钥丢失或`data/key/`目录下任一文件损坏都将导致解密无法正常进行。
|
||||
|
||||
本项目采用自主开发的混合加密模式,项目组也无法找回您的管理密钥或修复`data/key/`目录下的文件。如果不幸的事发生,建议您删除`data/data.db`重新录入信息。
|
||||
|
||||
### 添加用户
|
||||
|
||||
输入“+”以开始添加用户。依次输入:
|
||||
|
||||
**用户名:** 管理用户的惟一凭证
|
||||
|
||||
**手机号码:** 允许隐去中间四位以“****”代替
|
||||
|
||||
**代理天数:** 这个还要我解释吗?
|
||||
|
||||

|
||||
|
||||
### 删除用户
|
||||
|
||||
输入用户名+“-”以删除用户。格式:
|
||||
## 安装软件
|
||||
|
||||
```
|
||||
用户名 -
|
||||
本软件是MAA的外部工具,需要安装MAA后才能使用。
|
||||
```
|
||||
|
||||

|
||||
### 下载MAA
|
||||
|
||||
### 配置用户状态
|
||||
- 什么是MAA? [官网](https://maa.plus/)/[GitHub](https://github.com/MaaAssistantArknights/MaaAssistantArknights)
|
||||
- MAA下载地址 [GitHub下载](https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases)
|
||||
|
||||
**启用代理:** 输入用户名+“y”以启用该用户的代理。格式:
|
||||
### 安装MAA
|
||||
|
||||
- 将MAA压缩包解压至任意普通文件夹即可。
|
||||
- 若为首次安装MAA,请双击`MAA.exe`启动MAA程序以生成MAA配置文件。
|
||||
|
||||
### 下载AUTO_MAA [](https://github.com/DLmaster361/AUTO_MAA/releases)
|
||||
|
||||
- GitHub下载地址 [GitHub下载](https://github.com/DLmaster361/AUTO_MAA/releases)
|
||||
|
||||
### 安装AUTO_MAA
|
||||
|
||||
- 将AUTO_MAA压缩包解压至任意普通文件夹即可。
|
||||
|
||||
## 配置AUTO_MAA
|
||||
|
||||
### 启动AUTO_MAA
|
||||
|
||||
- 双击`AUTO_MAA.exe`以启动软件。
|
||||
|
||||
```
|
||||
用户名 y
|
||||
注意:
|
||||
|
||||
首次启动时会要求设置管理密钥。
|
||||
|
||||
管理密钥是解密用户密码的唯一凭证,与用户数据库绑定。
|
||||
密钥丢失或data/key/目录下任一文件损坏都将导致解密无法正常进行。
|
||||
|
||||
本项目采用自主开发的混合加密模式,项目组也无法找回您的管理密钥或修复data/key/目录下的文件。
|
||||
如果不幸的事发生,建议您删除data/key目录与config目录后重新录入信息。
|
||||
```
|
||||
|
||||

|
||||
### 配置信息
|
||||
|
||||
**禁用代理:** 输入用户名+“n”以禁用该用户的代理。格式:
|
||||
#### 设置脚本实例
|
||||
|
||||
```
|
||||
用户名 n
|
||||
```
|
||||
1. 单击`+`并选择`MAA`以添加MAA脚本实例。
|
||||
2. 在`MAA目录`选项卡中通过`选择文件夹`打开MAA软件目录以绑定MAA。
|
||||
3. 在`MAA全局配置`选项卡中通过`设置`进行MAA全局设置。在打开的MAA界面完成`性能设置`、`游戏设置`、`连接设置`、`启动设置`、`界面设置`、`软件更新`等基本配置以及代理任务的详细配置。
|
||||
4. 完成基本配置后,关闭MAA页面,AUTO_MAA会自动保存您的配置。
|
||||
|
||||

|
||||
- 注意:在MAA的设置过程中,若MAA要求`立刻重启应用更改`,请选择`稍后`。否则,MAA重启后的一切更改都不会被程序记录。
|
||||
|
||||
### 续期
|
||||
- 特别的,在设置MAA过程中,您需要确保自己:
|
||||
- 在`切换配置`选项卡中选择了`Default`项。
|
||||
- 取消勾选`开机自启动MAA`。
|
||||
- 配置自己模拟器所在的位置并根据实际情况填写`等待模拟器启动时间`(建议预留10s以防意外)。
|
||||
- 如果是模拟器多开用户,还需要填写`附加命令`,具体填写值参见多开模拟器对应快捷方式路径(如`-v 1`)。
|
||||
|
||||
输入用户名+续期天数+“+”以延长该用户的代理天数。格式:
|
||||

|
||||
|
||||
```
|
||||
用户名 续期天数 +
|
||||
```
|
||||
|
||||

|
||||
#### 设置用户配置
|
||||
|
||||
### 修改刷取关卡
|
||||
每一个脚本实例都有独立的用户数据库,您可以直接在`用户列表`选项卡配置用户相关信息,页面简介如下:
|
||||
- `新建用户`、`删除用户`:新建一个用户到当前用户配置列表、删除当前所选第一行所对应的用户。
|
||||
- `向上移动`、`向下移动`:移动用户位置,用户位置即代理顺序。
|
||||
- `模式转换`:将当前所选第一行所对应的用户转为高级/简洁配置模式。
|
||||
- `用户选项配置`:选择用户与对应配置项目,执行对应配置流程。
|
||||
- `自定义基建`:选择自定义基建配置文件。
|
||||
- `日常`、`剿灭`:打开MAA界面进行设置,设置方法与MAA全局配置相同。
|
||||
- `显示密码`:输入管理密钥以显示用户密码,仅当管理密钥正确时能够修改`密码栏目`。
|
||||
- `简洁用户配置列表`:仅支持核心代理选项的设置,其它设置选项沿用MAA的全局设置,部分代理核心功能选项由程序托管。
|
||||
- `高级用户配置列表`:支持几乎所有代理选项的设置,通过`用户选项配置`进行MAA自定义,仅部分代理核心功能选项由程序托管。
|
||||
- `用户配置列表栏目`详解如下:
|
||||
- `用户名`:展示在执行界面的用户名,用于区分不同用户。
|
||||
- `账号ID`:MAA进行账号切换所需的凭据,官服用户请输入手机号码、B服请输入B站ID。
|
||||
- `服务器`:当前支持官服、B服。
|
||||
- `代理天数`:剩余需要进行代理的天数,输入`任意负数`可设置为无限代理天数,当剩余天数为0时不再代理或排查。
|
||||
- `状态`:用户的状态,禁用时将不再对其进行代理或排查。
|
||||
- `执行情况`:当日执行情况,不可编辑。
|
||||
- `关卡`、`备选关卡-1`、`备选关卡-2`:关卡号。
|
||||
- `日常`:单独设定是否进行自动代理的日常部分,可进一步配置MAA的具体代理任务,该配置与全局MAA配置相互独立。
|
||||
- `剿灭`:单独设定是否进行自动代理的剿灭部分,高级配置模式下可进一步配置MAA的具体代理任务,该配置与全局MAA配置相互独立。
|
||||
- `自定义基建`:是否启用自定义基建功能,需要进一步配置自定义基建文件,该配置与其他用户相互独立。
|
||||
- `密码`:仅用于登记用户的密码,可留空。
|
||||
- `备注`:用于备注用户信息。
|
||||
|
||||
输入用户名+关卡号+“~”以更改该用户的代理关卡。格式:
|
||||
- 特别的:
|
||||
- 对于`简洁用户配置列表的关卡、备选关卡-1、备选关卡-2栏目`您可以自定义关卡号替换方案。
|
||||
- 程序会读取`data/gameid.txt`中的数据,依据此进行关卡号的替换,便于常用关卡的使用。
|
||||
- `gameid.txt`会在程序首次运行时生成,其中将预置一些常用资源本的替换方案。
|
||||
|
||||
```
|
||||
用户名 关卡号 ~
|
||||
```
|
||||

|
||||
|
||||

|
||||
#### 设置调度队列
|
||||
|
||||
**特别的:**
|
||||
- 单个调度队列可包含至多10个定时与至多10个任务实例。
|
||||
- 调度队列状态为关闭时,将不会定时启动该调度队列,但仍能在主调度台直接运行该调度队列。
|
||||
- 同一调度队列内任务实例被依次挨个调起运行,非同一调度队列内的不同任务实例可被同时调起。
|
||||
- 同一时间内,任何脚本实例或调度队列都不会被重复调起,若某一任务运行时发现同一任务已在运行,将自动跳过。
|
||||
|
||||
你可以自定义关卡号替换方案。程序会读取`gameid.txt`中的数据,依据此进行关卡号的替换,便于常用关卡的使用。`gameid.txt`在初始已经存储了一些常用资源本的替代方案。
|
||||
#### 设置AUTO_MAA
|
||||
|
||||

|
||||
- 详见软件中对应选项卡的注解。
|
||||
|
||||
### 设置MAA路径
|
||||
|
||||
输入“/”+新的MAA文件夹路径以修改MAA安装位置的配置。格式:
|
||||
|
||||
```
|
||||
/新的MAA文件夹路径
|
||||
```
|
||||
|
||||
**注意:** ‘/’与路径间没有空格,路径同样不能使用反斜杠
|
||||
|
||||

|
||||
|
||||
### 设置启动时间
|
||||
|
||||
**添加启动时间:** 输入“:+”+时间以添加定时启动时间。格式:
|
||||
|
||||
```
|
||||
:+小时:分钟
|
||||
```
|
||||
|
||||
**注意:** 所有输入间没有空格
|
||||
|
||||

|
||||
|
||||
**删除启动时间:** 输入“:-”+时间以删除定时启动时间。格式:
|
||||
|
||||
```
|
||||
:-小时:分钟
|
||||
```
|
||||
|
||||
**注意:** 所有输入间没有空格
|
||||
|
||||

|
||||
|
||||
### 检索信息
|
||||
|
||||
**检索所有信息:** `manage.exe`打开时会打印所有用户与配置信息。除此之外,你可以通过输入“all ?”以打印所有信息,如下:
|
||||
|
||||
```
|
||||
all ?
|
||||
```
|
||||
|
||||

|
||||
|
||||
**检索MAA路径:** 输入“maa ?”以检索MAA安装路径,如下:
|
||||
|
||||
```
|
||||
maa ?
|
||||
```
|
||||
|
||||

|
||||
|
||||
**检索启动时间:** 输入“time ?”以检索定时启动的时间,如下:
|
||||
|
||||
```
|
||||
time ?
|
||||
```
|
||||
|
||||

|
||||
|
||||
**检索指定用户:** 输入用户名+“?”以检索指定用户信息,如下:
|
||||
|
||||
```
|
||||
用户名 ?
|
||||
```
|
||||
|
||||
**注意:** 由于需要检索用户密码,每一次`manage.exe`启动后的首次查询需要验证管理密钥。为了方便操作,之后的查询不会再要求重复验证。因此,完成密码查询后,请及时关闭`manage.exe`。
|
||||
|
||||

|
||||
|
||||
### 修改管理密钥
|
||||
|
||||
输入“*”以开始修改管理密钥。依次输入:
|
||||
|
||||
**旧管理密钥:** 当数据库中没有存储用户信息时,允许跳过验证直接配置新管理密钥
|
||||
|
||||
**新管理密钥:** 请妥善保管,丢失无法找回。
|
||||
|
||||

|
||||
|
||||
### 退出
|
||||
|
||||
输入“-”以退出`manage.exe`,如下:
|
||||
|
||||
```
|
||||
-
|
||||
```
|
||||
|
||||
## 运行代理
|
||||
## 运行代理任务
|
||||
|
||||
### 直接运行
|
||||
|
||||
双击`run.exe`直接运行
|
||||
- 在`调度中心`的`主调度台`选择对应任务与`自动代理`模式,单击`开始任务`即可开始代理。
|
||||
|
||||
### 定时运行
|
||||
|
||||
双击`AUTO_MAA.exe`打开,不要关闭。它会读取设定时间,在该时刻自动运行
|
||||
- 将调度队列状态设为开启,并在`定时`选项卡设置定时启动时间。
|
||||
- 保持软件开启,软件会在设定的时间自动运行。
|
||||
|
||||
**注意:** 将优先进行剿灭代理
|
||||
## 人工排查代理结果
|
||||
|
||||
## 关于
|
||||
### 直接开始人工排查
|
||||
|
||||
项目图标由文心一格AI生成
|
||||
- 在`调度中心`的`主调度台`选择对应任务与`人工排查`模式,单击`开始任务`即可开始人工排查。
|
||||
- 软件将调起MAA,依次登录各用户的账号。
|
||||
- 完成PRTS登录后,请人工检查代理情况,可以手动完成未代理的任务。
|
||||
- 在对话框中单击对应账号的代理情况。
|
||||
- 结束人工排查后,相应排查情况将被写入用户管理页的`备注栏目`。
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
---
|
||||
|
||||
欢迎加入AUTO_MAA项目组,欢迎反馈bug
|
||||
# 关于
|
||||
|
||||
QQ群:暂时没有
|
||||
## 项目开发情况
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
可在[《AUTO_MAA开发者协作文档》](https://docs.qq.com/aio/DQ3Z5eHNxdmxFQmZX)的`开发任务`页面中查看开发进度。
|
||||
|
||||
如果喜欢本项目,可以打赏送作者一杯咖啡喵!
|
||||
|
||||

|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
## 贡献者
|
||||
|
||||
感谢以下贡献者对本项目做出的贡献
|
||||
@@ -271,4 +207,16 @@ QQ群:暂时没有
|
||||
|
||||
## Star History
|
||||
|
||||
[](https://star-history.com/#DLmaster361/AUTO_MAA&Date)
|
||||
[](https://star-history.com/#DLmaster361/AUTO_MAA&Date)
|
||||
|
||||
## 交流与赞助
|
||||
|
||||
欢迎加入AUTO_MAA项目组,欢迎反馈bug
|
||||
|
||||
- QQ群:[957750551](https://qm.qq.com/q/bd9fISNoME)
|
||||
|
||||
---
|
||||
|
||||
如果喜欢这个项目的话,给作者来杯咖啡吧!
|
||||
|
||||

|
||||
|
||||
51
app/__init__.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA主程序包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .core import AppConfig, QueueConfig, MaaConfig, Task, Task_manager, Main_timer
|
||||
from .models import MaaManager
|
||||
from .services import Notify, Crypto, System
|
||||
from .ui import AUTO_MAA
|
||||
from .utils import Updater
|
||||
|
||||
__all__ = [
|
||||
"AppConfig",
|
||||
"QueueConfig",
|
||||
"MaaConfig",
|
||||
"Task",
|
||||
"Task_manager",
|
||||
"Main_timer",
|
||||
"MaaManager",
|
||||
"Notify",
|
||||
"Crypto",
|
||||
"System",
|
||||
"AUTO_MAA",
|
||||
"Updater",
|
||||
]
|
||||
46
app/core/__init__.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA核心组件包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .config import AppConfig, QueueConfig, MaaConfig, Config
|
||||
from .main_info_bar import MainInfoBar
|
||||
from .task_manager import Task, Task_manager
|
||||
from .timer import Main_timer
|
||||
|
||||
__all__ = [
|
||||
"AppConfig",
|
||||
"Config",
|
||||
"QueueConfig",
|
||||
"MaaConfig",
|
||||
"MainInfoBar",
|
||||
"Task",
|
||||
"Task_manager",
|
||||
"Main_timer",
|
||||
]
|
||||
645
app/core/config.py
Normal file
@@ -0,0 +1,645 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA配置管理
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
import sqlite3
|
||||
import json
|
||||
import sys
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from qfluentwidgets import (
|
||||
QConfig,
|
||||
ConfigItem,
|
||||
OptionsConfigItem,
|
||||
RangeConfigItem,
|
||||
FolderValidator,
|
||||
BoolValidator,
|
||||
RangeValidator,
|
||||
OptionsValidator,
|
||||
qconfig,
|
||||
)
|
||||
|
||||
|
||||
class AppConfig:
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
self.app_path = Path(sys.argv[0]).resolve().parent # 获取软件根目录
|
||||
self.app_path_sys = str(Path(sys.argv[0]).resolve()) # 获取软件自身的路径
|
||||
|
||||
self.log_path = self.app_path / "debug/AUTO_MAA.log"
|
||||
self.database_path = self.app_path / "data/data.db"
|
||||
self.config_path = self.app_path / "config/config.json"
|
||||
self.history_path = self.app_path / "config/history.json"
|
||||
self.key_path = self.app_path / "data/key"
|
||||
self.gameid_path = self.app_path / "data/gameid.txt"
|
||||
self.version_path = self.app_path / "resources/version.json"
|
||||
|
||||
self.PASSWORD = ""
|
||||
self.running_list = []
|
||||
self.silence_list = []
|
||||
self.if_database_opened = False
|
||||
|
||||
# 检查文件完整性
|
||||
self.initialize()
|
||||
|
||||
def initialize(self) -> None:
|
||||
"""初始化程序的配置文件"""
|
||||
|
||||
# 检查目录
|
||||
(self.app_path / "config").mkdir(parents=True, exist_ok=True)
|
||||
(self.app_path / "data").mkdir(parents=True, exist_ok=True)
|
||||
(self.app_path / "debug").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 生成版本信息文件
|
||||
if not self.version_path.exists():
|
||||
version = {
|
||||
"main_version": "0.0.0.0",
|
||||
"updater_version": "0.0.0.0",
|
||||
}
|
||||
with self.version_path.open(mode="w", encoding="utf-8") as f:
|
||||
json.dump(version, f, ensure_ascii=False, indent=4)
|
||||
|
||||
# 生成预设gameid替换方案文件
|
||||
if not self.gameid_path.exists():
|
||||
self.gameid_path.write_text(
|
||||
"龙门币:CE-6\n技能:CA-5\n红票:AP-5\n经验:LS-6\n剿灭模式:Annihilation",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
self.init_logger()
|
||||
self.init_config()
|
||||
self.check_data()
|
||||
logger.info("程序配置管理模块初始化完成")
|
||||
|
||||
def init_logger(self) -> None:
|
||||
"""初始化日志记录器"""
|
||||
|
||||
logger.remove(0)
|
||||
|
||||
logger.add(
|
||||
sink=self.log_path,
|
||||
level="DEBUG",
|
||||
format="<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <level>{message}</level>",
|
||||
enqueue=True,
|
||||
backtrace=True,
|
||||
diagnose=True,
|
||||
rotation="1 week",
|
||||
retention="1 month",
|
||||
compression="zip",
|
||||
)
|
||||
logger.info("===================================")
|
||||
logger.info("AUTO_MAA 主程序")
|
||||
logger.info("版本号: v4.2.1.1")
|
||||
logger.info(f"根目录: {self.app_path}")
|
||||
logger.info("===================================")
|
||||
|
||||
logger.info("日志记录器初始化完成")
|
||||
|
||||
def init_config(self) -> None:
|
||||
"""初始化配置类"""
|
||||
|
||||
self.global_config = GlobalConfig()
|
||||
self.queue_config = QueueConfig()
|
||||
self.maa_config = MaaConfig()
|
||||
|
||||
config_list = self.search_config()
|
||||
for config in config_list:
|
||||
if config[0] == "Maa":
|
||||
qconfig.load(config[1], self.maa_config)
|
||||
self.maa_config.save()
|
||||
elif config[0] == "Queue":
|
||||
qconfig.load(config[1], self.queue_config)
|
||||
self.queue_config.save()
|
||||
|
||||
logger.info("配置类初始化完成")
|
||||
|
||||
def init_database(self, mode: str) -> None:
|
||||
"""初始化用户数据库"""
|
||||
|
||||
if mode == "Maa":
|
||||
self.cur.execute(
|
||||
"CREATE TABLE adminx(admin text,id text,server text,day int,status text,last date,game text,game_1 text,game_2 text,routine text,annihilation text,infrastructure text,password byte,notes text,numb int,mode text,uid int)"
|
||||
)
|
||||
self.cur.execute("CREATE TABLE version(v text)")
|
||||
self.cur.execute("INSERT INTO version VALUES(?)", ("v1.4",))
|
||||
self.db.commit()
|
||||
|
||||
logger.info("用户数据库初始化完成")
|
||||
|
||||
def check_data(self) -> None:
|
||||
"""检查用户数据文件并处理数据文件版本更新"""
|
||||
|
||||
# 生成主数据库
|
||||
if not self.database_path.exists():
|
||||
db = sqlite3.connect(self.database_path)
|
||||
cur = db.cursor()
|
||||
cur.execute("CREATE TABLE version(v text)")
|
||||
cur.execute("INSERT INTO version VALUES(?)", ("v1.4",))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
# 数据文件版本更新
|
||||
db = sqlite3.connect(self.database_path)
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT * FROM version WHERE True")
|
||||
version = cur.fetchall()
|
||||
|
||||
if version[0][0] != "v1.4":
|
||||
logger.info("数据文件版本更新开始")
|
||||
if_streaming = False
|
||||
# v1.0-->v1.1
|
||||
if version[0][0] == "v1.0" or if_streaming:
|
||||
logger.info("数据文件版本更新:v1.0-->v1.1")
|
||||
if_streaming = True
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data = cur.fetchall()
|
||||
cur.execute("DROP TABLE IF EXISTS adminx")
|
||||
cur.execute(
|
||||
"CREATE TABLE adminx(admin text,id text,server text,day int,status text,last date,game text,game_1 text,game_2 text,routines text,annihilation text,infrastructure text,password byte,notes text,numb int,mode text,uid int)"
|
||||
)
|
||||
for i in range(len(data)):
|
||||
cur.execute(
|
||||
"INSERT INTO adminx VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
(
|
||||
data[i][0], # 0 0 0
|
||||
data[i][1], # 1 1 -
|
||||
"Official", # 2 2 -
|
||||
data[i][2], # 3 3 1
|
||||
data[i][3], # 4 4 2
|
||||
data[i][4], # 5 5 3
|
||||
data[i][5], # 6 6 -
|
||||
data[i][6], # 7 7 -
|
||||
data[i][7], # 8 8 -
|
||||
"y", # 9 - 4
|
||||
data[i][8], # 10 9 5
|
||||
data[i][9], # 11 10 -
|
||||
data[i][10], # 12 11 6
|
||||
data[i][11], # 13 12 7
|
||||
data[i][12], # 14 - -
|
||||
"simple", # 15 - -
|
||||
data[i][13], # 16 - -
|
||||
),
|
||||
)
|
||||
cur.execute("DELETE FROM version WHERE v = ?", ("v1.0",))
|
||||
cur.execute("INSERT INTO version VALUES(?)", ("v1.1",))
|
||||
db.commit()
|
||||
# v1.1-->v1.2
|
||||
if version[0][0] == "v1.1" or if_streaming:
|
||||
logger.info("数据文件版本更新:v1.1-->v1.2")
|
||||
if_streaming = True
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data = cur.fetchall()
|
||||
for i in range(len(data)):
|
||||
cur.execute(
|
||||
"UPDATE adminx SET infrastructure = 'n' WHERE mode = ? AND uid = ?",
|
||||
(
|
||||
data[i][15],
|
||||
data[i][16],
|
||||
),
|
||||
)
|
||||
cur.execute("DELETE FROM version WHERE v = ?", ("v1.1",))
|
||||
cur.execute("INSERT INTO version VALUES(?)", ("v1.2",))
|
||||
db.commit()
|
||||
# v1.2-->v1.3
|
||||
if version[0][0] == "v1.2" or if_streaming:
|
||||
logger.info("数据文件版本更新:v1.2-->v1.3")
|
||||
if_streaming = True
|
||||
cur.execute("ALTER TABLE adminx RENAME COLUMN routines TO routine")
|
||||
cur.execute("DELETE FROM version WHERE v = ?", ("v1.2",))
|
||||
cur.execute("INSERT INTO version VALUES(?)", ("v1.3",))
|
||||
db.commit()
|
||||
# v1.3-->v1.4
|
||||
if version[0][0] == "v1.3" or if_streaming:
|
||||
logger.info("数据文件版本更新:v1.3-->v1.4")
|
||||
if_streaming = True
|
||||
(self.app_path / "config/MaaConfig").mkdir(parents=True, exist_ok=True)
|
||||
shutil.move(
|
||||
self.app_path / "data/MaaConfig",
|
||||
self.app_path / "config/MaaConfig",
|
||||
)
|
||||
(self.app_path / "config/MaaConfig/MaaConfig").rename(
|
||||
self.app_path / "config/MaaConfig/脚本_1"
|
||||
)
|
||||
shutil.copy(
|
||||
self.database_path,
|
||||
self.app_path / "config/MaaConfig/脚本_1/user_data.db",
|
||||
)
|
||||
cur.execute("DROP TABLE IF EXISTS adminx")
|
||||
cur.execute("DELETE FROM version WHERE v = ?", ("v1.3",))
|
||||
cur.execute("INSERT INTO version VALUES(?)", ("v1.4",))
|
||||
db.commit()
|
||||
with (self.app_path / "config/gui.json").open(
|
||||
"r", encoding="utf-8"
|
||||
) as f:
|
||||
info = json.load(f)
|
||||
maa_config = {
|
||||
"MaaSet": {
|
||||
"Name": "",
|
||||
"Path": info["Default"]["MaaSet.path"],
|
||||
},
|
||||
"RunSet": {
|
||||
"AnnihilationTimeLimit": info["Default"][
|
||||
"TimeLimit.annihilation"
|
||||
],
|
||||
"RoutineTimeLimit": info["Default"]["TimeLimit.routine"],
|
||||
"RunTimesLimit": info["Default"]["TimesLimit.run"],
|
||||
},
|
||||
}
|
||||
with (self.app_path / "config/MaaConfig/脚本_1/config.json").open(
|
||||
"w", encoding="utf-8"
|
||||
) as f:
|
||||
json.dump(maa_config, f, ensure_ascii=False, indent=4)
|
||||
config = {
|
||||
"Function": {
|
||||
"BossKey": info["Default"]["SelfSet.BossKey"],
|
||||
"IfAllowSleep": bool(
|
||||
info["Default"]["SelfSet.IfSleep"] == "True"
|
||||
),
|
||||
"IfSilence": bool(
|
||||
info["Default"]["SelfSet.IfSilence"] == "True"
|
||||
),
|
||||
},
|
||||
"Notify": {
|
||||
"IfPushPlyer": True,
|
||||
"IfSendErrorOnly": bool(
|
||||
info["Default"]["SelfSet.IfSendMail.OnlyError"] == "True"
|
||||
),
|
||||
"IfSendMail": bool(
|
||||
info["Default"]["SelfSet.IfSendMail"] == "True"
|
||||
),
|
||||
"MailAddress": info["Default"]["SelfSet.MailAddress"],
|
||||
},
|
||||
"Start": {
|
||||
"IfRunDirectly": bool(
|
||||
info["Default"]["SelfSet.IfProxyDirectly"] == "True"
|
||||
),
|
||||
"IfSelfStart": bool(
|
||||
info["Default"]["SelfSet.IfSelfStart"] == "True"
|
||||
),
|
||||
},
|
||||
"UI": {
|
||||
"IfShowTray": bool(
|
||||
info["Default"]["SelfSet.IfToTray"] == "True"
|
||||
),
|
||||
"IfToTray": bool(info["Default"]["SelfSet.IfToTray"] == "True"),
|
||||
"location": info["Default"]["SelfSet.UIlocation"],
|
||||
"maximized": bool(
|
||||
info["Default"]["SelfSet.UImaximized"] == "True"
|
||||
),
|
||||
"size": info["Default"]["SelfSet.UIsize"],
|
||||
},
|
||||
"Update": {"IfAutoUpdate": False},
|
||||
}
|
||||
with (self.app_path / "config/config.json").open(
|
||||
"w", encoding="utf-8"
|
||||
) as f:
|
||||
json.dump(config, f, ensure_ascii=False, indent=4)
|
||||
queue_config = {
|
||||
"QueueSet": {"Enabled": True, "Name": ""},
|
||||
"Queue": {
|
||||
"Member_1": "脚本_1",
|
||||
"Member_10": "禁用",
|
||||
"Member_2": "禁用",
|
||||
"Member_3": "禁用",
|
||||
"Member_4": "禁用",
|
||||
"Member_5": "禁用",
|
||||
"Member_6": "禁用",
|
||||
"Member_7": "禁用",
|
||||
"Member_8": "禁用",
|
||||
"Member_9": "禁用",
|
||||
},
|
||||
"Time": {
|
||||
"TimeEnabled_0": bool(
|
||||
info["Default"]["TimeSet.set1"] == "True"
|
||||
),
|
||||
"TimeEnabled_1": bool(
|
||||
info["Default"]["TimeSet.set2"] == "True"
|
||||
),
|
||||
"TimeEnabled_2": bool(
|
||||
info["Default"]["TimeSet.set3"] == "True"
|
||||
),
|
||||
"TimeEnabled_3": bool(
|
||||
info["Default"]["TimeSet.set4"] == "True"
|
||||
),
|
||||
"TimeEnabled_4": bool(
|
||||
info["Default"]["TimeSet.set5"] == "True"
|
||||
),
|
||||
"TimeEnabled_5": bool(
|
||||
info["Default"]["TimeSet.set6"] == "True"
|
||||
),
|
||||
"TimeEnabled_6": bool(
|
||||
info["Default"]["TimeSet.set7"] == "True"
|
||||
),
|
||||
"TimeEnabled_7": bool(
|
||||
info["Default"]["TimeSet.set8"] == "True"
|
||||
),
|
||||
"TimeEnabled_8": bool(
|
||||
info["Default"]["TimeSet.set9"] == "True"
|
||||
),
|
||||
"TimeEnabled_9": bool(
|
||||
info["Default"]["TimeSet.set10"] == "True"
|
||||
),
|
||||
"TimeSet_0": info["Default"]["TimeSet.run1"],
|
||||
"TimeSet_1": info["Default"]["TimeSet.run2"],
|
||||
"TimeSet_2": info["Default"]["TimeSet.run3"],
|
||||
"TimeSet_3": info["Default"]["TimeSet.run4"],
|
||||
"TimeSet_4": info["Default"]["TimeSet.run5"],
|
||||
"TimeSet_5": info["Default"]["TimeSet.run6"],
|
||||
"TimeSet_6": info["Default"]["TimeSet.run7"],
|
||||
"TimeSet_7": info["Default"]["TimeSet.run8"],
|
||||
"TimeSet_8": info["Default"]["TimeSet.run9"],
|
||||
"TimeSet_9": info["Default"]["TimeSet.run10"],
|
||||
},
|
||||
}
|
||||
(self.app_path / "config/QueueConfig").mkdir(
|
||||
parents=True, exist_ok=True
|
||||
)
|
||||
with (self.app_path / "config/QueueConfig/调度队列_1.json").open(
|
||||
"w", encoding="utf-8"
|
||||
) as f:
|
||||
json.dump(queue_config, f, ensure_ascii=False, indent=4)
|
||||
(self.app_path / "config/gui.json").unlink()
|
||||
cur.close()
|
||||
db.close()
|
||||
logger.info("数据文件版本更新完成")
|
||||
|
||||
def search_config(self) -> list:
|
||||
"""搜索所有子配置文件"""
|
||||
|
||||
config_list = []
|
||||
|
||||
if (self.app_path / "config/MaaConfig").exists():
|
||||
for subdir in (self.app_path / "config/MaaConfig").iterdir():
|
||||
if subdir.is_dir():
|
||||
config_list.append(["Maa", subdir / "config.json"])
|
||||
|
||||
if (self.app_path / "config/QueueConfig").exists():
|
||||
for json_file in (self.app_path / "config/QueueConfig").glob("*.json"):
|
||||
config_list.append(["Queue", json_file])
|
||||
|
||||
return config_list
|
||||
|
||||
def open_database(self, mode: str, index: str = None) -> None:
|
||||
"""打开数据库"""
|
||||
|
||||
self.close_database()
|
||||
self.db = sqlite3.connect(
|
||||
self.app_path / f"config/{mode}Config/{index}/user_data.db"
|
||||
)
|
||||
self.cur = self.db.cursor()
|
||||
self.if_database_opened = True
|
||||
|
||||
def close_database(self) -> None:
|
||||
"""关闭数据库"""
|
||||
|
||||
if self.if_database_opened:
|
||||
self.cur.close()
|
||||
self.db.close()
|
||||
self.if_database_opened = False
|
||||
|
||||
def change_user_info(
|
||||
self,
|
||||
data_path: Path,
|
||||
modes: list,
|
||||
uids: list,
|
||||
days: list,
|
||||
lasts: list,
|
||||
notes: list,
|
||||
numbs: list,
|
||||
) -> None:
|
||||
"""将代理完成后发生改动的用户信息同步至本地数据库"""
|
||||
|
||||
db = sqlite3.connect(data_path / "user_data.db")
|
||||
cur = db.cursor()
|
||||
|
||||
for index in range(len(uids)):
|
||||
cur.execute(
|
||||
"UPDATE adminx SET day = ? WHERE mode = ? AND uid = ?",
|
||||
(days[index], modes[index], uids[index]),
|
||||
)
|
||||
cur.execute(
|
||||
"UPDATE adminx SET last = ? WHERE mode = ? AND uid = ?",
|
||||
(lasts[index], modes[index], uids[index]),
|
||||
)
|
||||
cur.execute(
|
||||
"UPDATE adminx SET notes = ? WHERE mode = ? AND uid = ?",
|
||||
(notes[index], modes[index], uids[index]),
|
||||
)
|
||||
cur.execute(
|
||||
"UPDATE adminx SET numb = ? WHERE mode = ? AND uid = ?",
|
||||
(numbs[index], modes[index], uids[index]),
|
||||
)
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
def save_history(self, key: str, content: dict) -> None:
|
||||
"""保存历史记录"""
|
||||
|
||||
history = {}
|
||||
if self.history_path.exists():
|
||||
with self.history_path.open(mode="r", encoding="utf-8") as f:
|
||||
history = json.load(f)
|
||||
history[key] = content
|
||||
with self.history_path.open(mode="w", encoding="utf-8") as f:
|
||||
json.dump(history, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def get_history(self, key: str) -> dict:
|
||||
"""获取历史记录"""
|
||||
|
||||
history = {}
|
||||
if self.history_path.exists():
|
||||
with self.history_path.open(mode="r", encoding="utf-8") as f:
|
||||
history = json.load(f)
|
||||
return history.get(
|
||||
key, {"Time": "0000-00-00 00:00", "History": "暂无历史运行记录"}
|
||||
)
|
||||
|
||||
def clear_maa_config(self) -> None:
|
||||
"""清空MAA配置"""
|
||||
|
||||
self.maa_config.set(self.maa_config.MaaSet_Name, "")
|
||||
self.maa_config.set(self.maa_config.MaaSet_Path, ".")
|
||||
self.maa_config.set(self.maa_config.RunSet_ProxyTimesLimit, 0)
|
||||
self.maa_config.set(self.maa_config.RunSet_AnnihilationTimeLimit, 40)
|
||||
self.maa_config.set(self.maa_config.RunSet_RoutineTimeLimit, 10)
|
||||
self.maa_config.set(self.maa_config.RunSet_RunTimesLimit, 3)
|
||||
self.maa_config.set(self.maa_config.MaaSet_Name, "")
|
||||
self.maa_config.set(self.maa_config.MaaSet_Name, "")
|
||||
self.maa_config.set(self.maa_config.MaaSet_Name, "")
|
||||
|
||||
def clear_queue_config(self) -> None:
|
||||
"""清空队列配置"""
|
||||
|
||||
self.queue_config.set(self.queue_config.queueSet_Name, "")
|
||||
self.queue_config.set(self.queue_config.queueSet_Enabled, False)
|
||||
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_0, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_0, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_1, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_1, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_2, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_2, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_3, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_3, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_4, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_4, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_5, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_5, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_6, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_6, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_7, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_7, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_8, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_8, "00:00")
|
||||
self.queue_config.set(self.queue_config.time_TimeEnabled_9, False)
|
||||
self.queue_config.set(self.queue_config.time_TimeSet_9, "00:00")
|
||||
|
||||
self.queue_config.set(self.queue_config.queue_Member_1, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_2, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_3, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_4, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_5, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_6, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_7, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_8, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_9, "禁用")
|
||||
self.queue_config.set(self.queue_config.queue_Member_10, "禁用")
|
||||
|
||||
|
||||
class GlobalConfig(QConfig):
|
||||
"""全局配置"""
|
||||
|
||||
function_IfAllowSleep = ConfigItem(
|
||||
"Function", "IfAllowSleep", False, BoolValidator()
|
||||
)
|
||||
function_IfSilence = ConfigItem("Function", "IfSilence", False, BoolValidator())
|
||||
function_BossKey = ConfigItem("Function", "BossKey", "")
|
||||
|
||||
start_IfSelfStart = ConfigItem("Start", "IfSelfStart", False, BoolValidator())
|
||||
start_IfRunDirectly = ConfigItem("Start", "IfRunDirectly", False, BoolValidator())
|
||||
|
||||
ui_IfShowTray = ConfigItem("UI", "IfShowTray", False, BoolValidator())
|
||||
ui_IfToTray = ConfigItem("UI", "IfToTray", False, BoolValidator())
|
||||
ui_size = ConfigItem("UI", "size", "1200x700")
|
||||
ui_location = ConfigItem("UI", "location", "100x100")
|
||||
ui_maximized = ConfigItem("UI", "maximized", False, BoolValidator())
|
||||
|
||||
notify_IfPushPlyer = ConfigItem("Notify", "IfPushPlyer", False, BoolValidator())
|
||||
notify_IfSendMail = ConfigItem("Notify", "IfSendMail", False, BoolValidator())
|
||||
notify_IfSendErrorOnly = ConfigItem(
|
||||
"Notify", "IfSendErrorOnly", False, BoolValidator()
|
||||
)
|
||||
notify_MailAddress = ConfigItem("Notify", "MailAddress", "")
|
||||
notify_IfServerChan = ConfigItem("Notify", "IfServerChan", False, BoolValidator())
|
||||
notify_ServerChanKey = ConfigItem("Notify", "ServerChanKey", "")
|
||||
notify_ServerChanChannel = ConfigItem("Notify", "ServerChanChannel", "")
|
||||
notify_ServerChanTag = ConfigItem("Notify", "ServerChanTag", "")
|
||||
notify_IfCompanyWebHookBot = ConfigItem(
|
||||
"Notify", "IfCompanyWebHookBot", False, BoolValidator()
|
||||
)
|
||||
notify_CompanyWebHookBotUrl = ConfigItem("Notify", "CompanyWebHookBotUrl", "")
|
||||
notify_IfPushDeer = ConfigItem("Notify", "IfPushDeer", False, BoolValidator())
|
||||
notify_IfPushDeerKey = ConfigItem("Notify", "PushDeerKey", "")
|
||||
|
||||
update_IfAutoUpdate = ConfigItem("Update", "IfAutoUpdate", False, BoolValidator())
|
||||
update_UpdateType = OptionsConfigItem(
|
||||
"Update", "UpdateType", "main", OptionsValidator(["main", "dev"])
|
||||
)
|
||||
|
||||
|
||||
class QueueConfig(QConfig):
|
||||
"""队列配置"""
|
||||
|
||||
queueSet_Name = ConfigItem("QueueSet", "Name", "")
|
||||
queueSet_Enabled = ConfigItem("QueueSet", "Enabled", False, BoolValidator())
|
||||
|
||||
time_TimeEnabled_0 = ConfigItem("Time", "TimeEnabled_0", False, BoolValidator())
|
||||
time_TimeSet_0 = ConfigItem("Time", "TimeSet_0", "00:00")
|
||||
|
||||
time_TimeEnabled_1 = ConfigItem("Time", "TimeEnabled_1", False, BoolValidator())
|
||||
time_TimeSet_1 = ConfigItem("Time", "TimeSet_1", "00:00")
|
||||
|
||||
time_TimeEnabled_2 = ConfigItem("Time", "TimeEnabled_2", False, BoolValidator())
|
||||
time_TimeSet_2 = ConfigItem("Time", "TimeSet_2", "00:00")
|
||||
|
||||
time_TimeEnabled_3 = ConfigItem("Time", "TimeEnabled_3", False, BoolValidator())
|
||||
time_TimeSet_3 = ConfigItem("Time", "TimeSet_3", "00:00")
|
||||
|
||||
time_TimeEnabled_4 = ConfigItem("Time", "TimeEnabled_4", False, BoolValidator())
|
||||
time_TimeSet_4 = ConfigItem("Time", "TimeSet_4", "00:00")
|
||||
|
||||
time_TimeEnabled_5 = ConfigItem("Time", "TimeEnabled_5", False, BoolValidator())
|
||||
time_TimeSet_5 = ConfigItem("Time", "TimeSet_5", "00:00")
|
||||
|
||||
time_TimeEnabled_6 = ConfigItem("Time", "TimeEnabled_6", False, BoolValidator())
|
||||
time_TimeSet_6 = ConfigItem("Time", "TimeSet_6", "00:00")
|
||||
|
||||
time_TimeEnabled_7 = ConfigItem("Time", "TimeEnabled_7", False, BoolValidator())
|
||||
time_TimeSet_7 = ConfigItem("Time", "TimeSet_7", "00:00")
|
||||
|
||||
time_TimeEnabled_8 = ConfigItem("Time", "TimeEnabled_8", False, BoolValidator())
|
||||
time_TimeSet_8 = ConfigItem("Time", "TimeSet_8", "00:00")
|
||||
|
||||
time_TimeEnabled_9 = ConfigItem("Time", "TimeEnabled_9", False, BoolValidator())
|
||||
time_TimeSet_9 = ConfigItem("Time", "TimeSet_9", "00:00")
|
||||
|
||||
queue_Member_1 = OptionsConfigItem("Queue", "Member_1", "禁用")
|
||||
queue_Member_2 = OptionsConfigItem("Queue", "Member_2", "禁用")
|
||||
queue_Member_3 = OptionsConfigItem("Queue", "Member_3", "禁用")
|
||||
queue_Member_4 = OptionsConfigItem("Queue", "Member_4", "禁用")
|
||||
queue_Member_5 = OptionsConfigItem("Queue", "Member_5", "禁用")
|
||||
queue_Member_6 = OptionsConfigItem("Queue", "Member_6", "禁用")
|
||||
queue_Member_7 = OptionsConfigItem("Queue", "Member_7", "禁用")
|
||||
queue_Member_8 = OptionsConfigItem("Queue", "Member_8", "禁用")
|
||||
queue_Member_9 = OptionsConfigItem("Queue", "Member_9", "禁用")
|
||||
queue_Member_10 = OptionsConfigItem("Queue", "Member_10", "禁用")
|
||||
|
||||
|
||||
class MaaConfig(QConfig):
|
||||
"""MAA配置"""
|
||||
|
||||
MaaSet_Name = ConfigItem("MaaSet", "Name", "")
|
||||
MaaSet_Path = ConfigItem("MaaSet", "Path", ".", FolderValidator())
|
||||
|
||||
RunSet_ProxyTimesLimit = RangeConfigItem(
|
||||
"RunSet", "ProxyTimesLimit", 0, RangeValidator(0, 1024)
|
||||
)
|
||||
RunSet_AnnihilationTimeLimit = RangeConfigItem(
|
||||
"RunSet", "AnnihilationTimeLimit", 40, RangeValidator(1, 1024)
|
||||
)
|
||||
RunSet_RoutineTimeLimit = RangeConfigItem(
|
||||
"RunSet", "RoutineTimeLimit", 10, RangeValidator(1, 1024)
|
||||
)
|
||||
RunSet_RunTimesLimit = RangeConfigItem(
|
||||
"RunSet", "RunTimesLimit", 3, RangeValidator(1, 1024)
|
||||
)
|
||||
|
||||
|
||||
Config = AppConfig()
|
||||
92
app/core/main_info_bar.py
Normal file
@@ -0,0 +1,92 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA信息通知栏
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtCore import Qt
|
||||
from qfluentwidgets import (
|
||||
InfoBar,
|
||||
InfoBarPosition,
|
||||
)
|
||||
|
||||
|
||||
class _MainInfoBar:
|
||||
"""信息通知栏"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
||||
self.parent = parent
|
||||
|
||||
def push_info_bar(self, mode: str, title: str, content: str, time: int):
|
||||
"""推送到信息通知栏"""
|
||||
|
||||
if self.parent is None:
|
||||
logger.error("信息通知栏未设置父窗口")
|
||||
return None
|
||||
|
||||
if mode == "success":
|
||||
InfoBar.success(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.TOP_RIGHT,
|
||||
duration=time,
|
||||
parent=self.parent,
|
||||
)
|
||||
elif mode == "warning":
|
||||
InfoBar.warning(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.TOP_RIGHT,
|
||||
duration=time,
|
||||
parent=self.parent,
|
||||
)
|
||||
elif mode == "error":
|
||||
InfoBar.error(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.TOP_RIGHT,
|
||||
duration=time,
|
||||
parent=self.parent,
|
||||
)
|
||||
elif mode == "info":
|
||||
InfoBar.info(
|
||||
title=title,
|
||||
content=content,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.TOP_RIGHT,
|
||||
duration=time,
|
||||
parent=self.parent,
|
||||
)
|
||||
|
||||
|
||||
MainInfoBar = _MainInfoBar()
|
||||
287
app/core/task_manager.py
Normal file
@@ -0,0 +1,287 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA业务调度器
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtCore import QThread, QObject, Signal
|
||||
from qfluentwidgets import Dialog
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from typing import Dict, Union
|
||||
|
||||
from .config import Config
|
||||
from .main_info_bar import MainInfoBar
|
||||
from app.models import MaaManager
|
||||
|
||||
|
||||
class Task(QThread):
|
||||
"""业务线程"""
|
||||
|
||||
push_info_bar = Signal(str, str, str, int)
|
||||
question = Signal(str, str)
|
||||
question_response = Signal(bool)
|
||||
update_user_info = Signal(Path, list, list, list, list, list, list)
|
||||
create_task_list = Signal(list)
|
||||
create_user_list = Signal(list)
|
||||
update_task_list = Signal(list)
|
||||
update_user_list = Signal(list)
|
||||
update_log_text = Signal(str)
|
||||
accomplish = Signal(list)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
mode: str,
|
||||
name: str,
|
||||
info: Dict[str, Dict[str, Union[str, int, bool]]],
|
||||
):
|
||||
super(Task, self).__init__()
|
||||
|
||||
self.mode = mode
|
||||
self.name = name
|
||||
self.info = info
|
||||
|
||||
self.logs = []
|
||||
|
||||
self.question_response.connect(lambda: print("response"))
|
||||
|
||||
def run(self):
|
||||
|
||||
if "设置MAA" in self.mode:
|
||||
|
||||
logger.info(f"任务开始:设置{self.name}")
|
||||
self.push_info_bar.emit("info", "设置MAA", self.name, 3000)
|
||||
|
||||
self.task = MaaManager(
|
||||
self.mode,
|
||||
Config.app_path / f"config/MaaConfig/{self.name}",
|
||||
(
|
||||
None
|
||||
if "全局" in self.mode
|
||||
else Config.app_path
|
||||
/ f"config/MaaConfig/{self.name}/beta/{self.info["SetMaaInfo"]["UserId"]}/{self.info["SetMaaInfo"]["SetType"]}"
|
||||
),
|
||||
)
|
||||
self.task.push_info_bar.connect(self.push_info_bar.emit)
|
||||
self.task.accomplish.connect(lambda: self.accomplish.emit([]))
|
||||
|
||||
self.task.run()
|
||||
|
||||
else:
|
||||
|
||||
self.member_dict = self.search_member()
|
||||
self.task_list = [
|
||||
[value, "等待"]
|
||||
for _, value in self.info["Queue"].items()
|
||||
if value != "禁用"
|
||||
]
|
||||
|
||||
self.create_task_list.emit(self.task_list)
|
||||
|
||||
for i in range(len(self.task_list)):
|
||||
|
||||
if self.isInterruptionRequested():
|
||||
break
|
||||
|
||||
self.task_list[i][1] = "运行"
|
||||
self.update_task_list.emit(self.task_list)
|
||||
|
||||
if self.task_list[i][0] in Config.running_list:
|
||||
|
||||
self.task_list[i][1] = "跳过"
|
||||
self.update_task_list.emit(self.task_list)
|
||||
logger.info(f"跳过任务:{self.task_list[i][0]}")
|
||||
self.push_info_bar.emit(
|
||||
"info", "跳过任务", self.task_list[i][0], 3000
|
||||
)
|
||||
continue
|
||||
|
||||
Config.running_list.append(self.task_list[i][0])
|
||||
logger.info(f"任务开始:{self.task_list[i][0]}")
|
||||
self.push_info_bar.emit("info", "任务开始", self.task_list[i][0], 3000)
|
||||
|
||||
if self.member_dict[self.task_list[i][0]][0] == "Maa":
|
||||
|
||||
self.task = MaaManager(
|
||||
self.mode[0:4],
|
||||
self.member_dict[self.task_list[i][0]][1],
|
||||
)
|
||||
|
||||
self.task.question.connect(self.question.emit)
|
||||
self.question_response.disconnect()
|
||||
self.question_response.connect(self.task.question_response.emit)
|
||||
self.task.push_info_bar.connect(self.push_info_bar.emit)
|
||||
self.task.create_user_list.connect(self.create_user_list.emit)
|
||||
self.task.update_user_list.connect(self.update_user_list.emit)
|
||||
self.task.update_log_text.connect(self.update_log_text.emit)
|
||||
self.task.update_user_info.connect(
|
||||
lambda modes, uids, days, lasts, notes, numbs: self.update_user_info.emit(
|
||||
self.member_dict[self.task_list[i][0]][1],
|
||||
modes,
|
||||
uids,
|
||||
days,
|
||||
lasts,
|
||||
notes,
|
||||
numbs,
|
||||
)
|
||||
)
|
||||
self.task.accomplish.connect(
|
||||
lambda log: self.save_log(self.task_list[i][0], log)
|
||||
)
|
||||
|
||||
self.task.run()
|
||||
|
||||
Config.running_list.remove(self.task_list[i][0])
|
||||
|
||||
self.task_list[i][1] = "完成"
|
||||
logger.info(f"任务完成:{self.task_list[i][0]}")
|
||||
self.push_info_bar.emit("info", "任务完成", self.task_list[i][0], 3000)
|
||||
|
||||
self.accomplish.emit(self.logs)
|
||||
|
||||
def search_member(self) -> dict:
|
||||
"""搜索所有脚本实例及其路径"""
|
||||
|
||||
member_dict = {}
|
||||
|
||||
if (Config.app_path / "config/MaaConfig").exists():
|
||||
for subdir in (Config.app_path / "config/MaaConfig").iterdir():
|
||||
if subdir.is_dir():
|
||||
|
||||
member_dict[subdir.name] = ["Maa", subdir]
|
||||
|
||||
return member_dict
|
||||
|
||||
def save_log(self, name: str, log: dict):
|
||||
"""保存保存任务结果"""
|
||||
|
||||
self.logs.append([name, log])
|
||||
|
||||
|
||||
class TaskManager(QObject):
|
||||
"""业务调度器"""
|
||||
|
||||
create_gui = Signal(Task)
|
||||
connect_gui = Signal(Task)
|
||||
push_info_bar = Signal(str, str, str, int)
|
||||
|
||||
def __init__(self):
|
||||
super(TaskManager, self).__init__()
|
||||
|
||||
self.task_list: Dict[str, Task] = {}
|
||||
|
||||
def add_task(
|
||||
self, mode: str, name: str, info: Dict[str, Dict[str, Union[str, int, bool]]]
|
||||
):
|
||||
"""添加任务"""
|
||||
|
||||
if name in Config.running_list or name in self.task_list:
|
||||
|
||||
logger.warning(f"任务已存在:{name}")
|
||||
MainInfoBar.push_info_bar("warning", "任务已存在", name, 5000)
|
||||
return None
|
||||
|
||||
logger.info(f"任务开始:{name}")
|
||||
MainInfoBar.push_info_bar("info", "任务开始", name, 3000)
|
||||
|
||||
Config.running_list.append(name)
|
||||
self.task_list[name] = Task(mode, name, info)
|
||||
self.task_list[name].question.connect(
|
||||
lambda title, content: self.push_dialog(name, title, content)
|
||||
)
|
||||
self.task_list[name].push_info_bar.connect(MainInfoBar.push_info_bar)
|
||||
self.task_list[name].update_user_info.connect(Config.change_user_info)
|
||||
self.task_list[name].accomplish.connect(
|
||||
lambda logs: self.remove_task(name, logs)
|
||||
)
|
||||
|
||||
if "新调度台" in mode:
|
||||
self.create_gui.emit(self.task_list[name])
|
||||
|
||||
elif "主调度台" in mode:
|
||||
self.connect_gui.emit(self.task_list[name])
|
||||
|
||||
self.task_list[name].start()
|
||||
|
||||
def stop_task(self, name: str):
|
||||
"""中止任务"""
|
||||
|
||||
logger.info(f"中止任务:{name}")
|
||||
MainInfoBar.push_info_bar("info", "中止任务", name, 3000)
|
||||
|
||||
if name == "ALL":
|
||||
|
||||
for name in self.task_list:
|
||||
|
||||
self.task_list[name].task.requestInterruption()
|
||||
self.task_list[name].requestInterruption()
|
||||
self.task_list[name].quit()
|
||||
self.task_list[name].wait()
|
||||
|
||||
elif name in self.task_list:
|
||||
|
||||
self.task_list[name].task.requestInterruption()
|
||||
self.task_list[name].requestInterruption()
|
||||
self.task_list[name].quit()
|
||||
self.task_list[name].wait()
|
||||
|
||||
def remove_task(self, name: str, logs: str):
|
||||
"""移除任务标记"""
|
||||
|
||||
logger.info(f"任务结束:{name}")
|
||||
MainInfoBar.push_info_bar("info", "任务结束", name, 3000)
|
||||
|
||||
if len(logs) > 0:
|
||||
time = logs[0][1]["Time"]
|
||||
history = ""
|
||||
for log in logs:
|
||||
Config.save_history(log[0], log[1])
|
||||
history += (
|
||||
f"任务名称:{log[0]},{log[1]["History"].replace("\n","\n ")}\n"
|
||||
)
|
||||
Config.save_history(name, {"Time": time, "History": history})
|
||||
else:
|
||||
Config.save_history(
|
||||
name,
|
||||
{
|
||||
"Time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"History": "没有任务被执行",
|
||||
},
|
||||
)
|
||||
|
||||
self.task_list.pop(name)
|
||||
Config.running_list.remove(name)
|
||||
|
||||
def push_dialog(self, name: str, title: str, content: str):
|
||||
"""推送对话框"""
|
||||
|
||||
choice = Dialog(title, content, None)
|
||||
choice.yesButton.setText("是")
|
||||
choice.cancelButton.setText("否")
|
||||
|
||||
self.task_list[name].question_response.emit(bool(choice.exec_()))
|
||||
|
||||
|
||||
Task_manager = TaskManager()
|
||||
123
app/core/timer.py
Normal file
@@ -0,0 +1,123 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA主业务定时器
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import QWidget
|
||||
from PySide6.QtCore import QTimer
|
||||
import json
|
||||
from datetime import datetime
|
||||
import pyautogui
|
||||
|
||||
from .config import Config
|
||||
from .task_manager import Task_manager
|
||||
from app.services import System
|
||||
|
||||
|
||||
class MainTimer(QWidget):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent=None,
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self.if_FailSafeException = False
|
||||
|
||||
self.Timer = QTimer()
|
||||
self.Timer.timeout.connect(self.timed_start)
|
||||
self.Timer.timeout.connect(self.set_silence)
|
||||
self.Timer.start(1000)
|
||||
|
||||
def timed_start(self):
|
||||
"""定时启动代理任务"""
|
||||
|
||||
# 获取定时列表
|
||||
queue_list = self.search_queue()
|
||||
|
||||
for i in queue_list:
|
||||
|
||||
name, info = i
|
||||
|
||||
if not info["QueueSet"]["Enabled"]:
|
||||
continue
|
||||
|
||||
history = Config.get_history(name)
|
||||
|
||||
time_set = [
|
||||
info["Time"][f"TimeSet_{_}"]
|
||||
for _ in range(10)
|
||||
if info["Time"][f"TimeEnabled_{_}"]
|
||||
]
|
||||
# 按时间调起代理任务
|
||||
curtime = datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
if (
|
||||
curtime[11:16] in time_set
|
||||
and curtime != history["Time"][:16]
|
||||
and name not in Config.running_list
|
||||
):
|
||||
|
||||
logger.info(f"定时任务:{name}")
|
||||
Task_manager.add_task("自动代理_新调度台", name, info)
|
||||
|
||||
def set_silence(self):
|
||||
"""设置静默模式"""
|
||||
|
||||
windows = System.get_window_info()
|
||||
if any(
|
||||
str(emulator_path) in window
|
||||
for window in windows
|
||||
for emulator_path in Config.silence_list
|
||||
):
|
||||
try:
|
||||
pyautogui.hotkey(
|
||||
*[
|
||||
_.strip().lower()
|
||||
for _ in Config.global_config.get(
|
||||
Config.global_config.function_BossKey
|
||||
).split("+")
|
||||
]
|
||||
)
|
||||
except pyautogui.FailSafeException as e:
|
||||
if not self.if_FailSafeException:
|
||||
logger.warning(f"FailSafeException: {e}")
|
||||
self.if_FailSafeException = True
|
||||
|
||||
def search_queue(self) -> list:
|
||||
"""搜索所有调度队列实例"""
|
||||
|
||||
queue_list = []
|
||||
|
||||
if (Config.app_path / "config/QueueConfig").exists():
|
||||
for json_file in (Config.app_path / "config/QueueConfig").glob("*.json"):
|
||||
with json_file.open("r", encoding="utf-8") as f:
|
||||
info = json.load(f)
|
||||
queue_list.append([json_file.stem, info])
|
||||
|
||||
return queue_list
|
||||
|
||||
|
||||
Main_timer = MainTimer()
|
||||
1039
app/models/MAA.py
Normal file
@@ -18,8 +18,17 @@
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
import os
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA模组包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
os.system("pyinstaller -F --version-file res/info.txt -i res/AUTO_MAA.ico manage.py")
|
||||
os.system("pyinstaller -F --version-file res/info.txt -i res/AUTO_MAA.ico run.py")
|
||||
os.system("pyinstaller -F --version-file res/info.txt -i res/AUTO_MAA.ico AUTO_MAA.py")
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .MAA import MaaManager
|
||||
|
||||
__all__ = ["MaaManager"]
|
||||
36
app/services/__init__.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA服务包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .notification import Notify
|
||||
from .security import Crypto
|
||||
from .system import System
|
||||
|
||||
__all__ = ["Notify", "Crypto", "System"]
|
||||
160
app/services/notification.py
Normal file
@@ -0,0 +1,160 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA通知服务
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
import requests
|
||||
from loguru import logger
|
||||
from plyer import notification
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.header import Header
|
||||
from email.utils import formataddr
|
||||
|
||||
from serverchan_sdk import sc_send
|
||||
|
||||
from app.core import Config
|
||||
|
||||
|
||||
class Notification:
|
||||
|
||||
def push_notification(self, title, message, ticker, t):
|
||||
"""推送系统通知"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfPushPlyer):
|
||||
|
||||
notification.notify(
|
||||
title=title,
|
||||
message=message,
|
||||
app_name="AUTO_MAA",
|
||||
app_icon=str(Config.app_path / "resources/icons/AUTO_MAA.ico"),
|
||||
timeout=t,
|
||||
ticker=ticker,
|
||||
toast=True,
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
def send_mail(self, title, content):
|
||||
"""使用官方专用邮箱推送邮件通知"""
|
||||
|
||||
# 声明:此邮箱为AUTO_MAA项目组资产,未经授权不得私自使用
|
||||
# 注意:此声明注释只有使用者更换发信邮箱时才能删除,本条规则优先级高于GPLv3
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfSendMail):
|
||||
|
||||
# 第三方 SMTP 服务配置
|
||||
mail_host = "smtp.163.com" # 设置服务器
|
||||
mail_sender = "AUTO_MAA_server@163.com" # 用户名
|
||||
mail_key = "SYrq87nDLD4RNB5T" # 授权码 24/11/15
|
||||
|
||||
# 定义邮件正文
|
||||
message = MIMEText(content, "plain", "utf-8")
|
||||
message["From"] = formataddr(
|
||||
(
|
||||
Header("AUTO_MAA通知服务", "utf-8").encode(),
|
||||
"AUTO_MAA_server@163.com",
|
||||
)
|
||||
) # 发件人显示的名字
|
||||
message["To"] = formataddr(
|
||||
(
|
||||
Header("AUTO_MAA用户", "utf-8").encode(),
|
||||
Config.global_config.get(Config.global_config.notify_MailAddress),
|
||||
)
|
||||
) # 收件人显示的名字
|
||||
message["Subject"] = Header(title, "utf-8")
|
||||
|
||||
try:
|
||||
smtpObj = smtplib.SMTP_SSL(mail_host, 465) # 465为SMTP_SSL默认端口
|
||||
smtpObj.login(mail_sender, mail_key)
|
||||
smtpObj.sendmail(
|
||||
mail_sender,
|
||||
Config.global_config.get(Config.global_config.notify_MailAddress),
|
||||
message.as_string(),
|
||||
)
|
||||
return True
|
||||
except smtplib.SMTPException as e:
|
||||
return f"发送邮件时出错:\n{e}"
|
||||
finally:
|
||||
smtpObj.quit()
|
||||
|
||||
def ServerChanPush(self, title, content):
|
||||
"""使用Server酱推送通知"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.notify_IfServerChan):
|
||||
send_key = Config.global_config.get(Config.global_config.notify_ServerChanKey)
|
||||
option = {}
|
||||
is_valid = lambda s: s == "" or (s == '|'.join(s.split('|')) and (s.count('|') == 0 or all(s.split('|'))))
|
||||
"""
|
||||
is_valid => True, 如果启用的话需要正确设置Tag和Channel。
|
||||
允许空的Tag和Channel即不启用,但不允许例如a||b,|a|b,a|b|,||||
|
||||
"""
|
||||
send_tag = Config.global_config.get(Config.global_config.notify_ServerChanTag)
|
||||
send_channel = Config.global_config.get(Config.global_config.notify_ServerChanChannel)
|
||||
|
||||
if is_valid(send_tag):
|
||||
option['tags'] = send_tag
|
||||
else:
|
||||
option['tags'] = ''
|
||||
logger.warning('请正确设置Auto_MAA中ServerChan的Tag。')
|
||||
|
||||
if is_valid(send_channel):
|
||||
option['channel'] = send_channel
|
||||
else:
|
||||
option['channel'] = ''
|
||||
logger.warning('请正确设置Auto_MAA中ServerChan的Channel。')
|
||||
|
||||
response = sc_send(send_key, title, content, option)
|
||||
if response["code"] == 0:
|
||||
logger.info("Server酱推送通知成功")
|
||||
return True
|
||||
else:
|
||||
logger.info("Server酱推送通知失败")
|
||||
logger.error(response)
|
||||
return f'使用Server酱推送通知时出错:\n{response["data"]['error']}'
|
||||
|
||||
def CompanyWebHookBotPush(self, title, content):
|
||||
"""使用企业微信群机器人推送通知"""
|
||||
if Config.global_config.get(Config.global_config.notify_IfCompanyWebHookBot):
|
||||
content = f'{title}\n{content}'
|
||||
data = {
|
||||
"msgtype": "text",
|
||||
"text": {
|
||||
"content": content
|
||||
}
|
||||
}
|
||||
response = requests.post(
|
||||
url=Config.global_config.get(Config.global_config.notify_CompanyWebHookBotUrl),
|
||||
json=data
|
||||
)
|
||||
if response.json()["errcode"] == 0:
|
||||
logger.info("企业微信群机器人推送通知成功")
|
||||
return True
|
||||
else:
|
||||
logger.info("企业微信群机器人推送通知失败")
|
||||
logger.error(response.json())
|
||||
return f'使用企业微信群机器人推送通知时出错:\n{response.json()["errmsg"]}'
|
||||
|
||||
|
||||
Notify = Notification()
|
||||
203
app/services/security.py
Normal file
@@ -0,0 +1,203 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA安全服务
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
import sqlite3
|
||||
import hashlib
|
||||
import random
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import PKCS1_OAEP
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
from typing import List, Dict, Union
|
||||
|
||||
from app.core import Config
|
||||
|
||||
|
||||
class CryptoHandler:
|
||||
|
||||
def get_PASSWORD(self, PASSWORD: str) -> None:
|
||||
"""配置管理密钥"""
|
||||
|
||||
# 生成目录
|
||||
Config.key_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 生成RSA密钥对
|
||||
key = RSA.generate(2048)
|
||||
public_key_local = key.publickey()
|
||||
private_key = key
|
||||
# 保存RSA公钥
|
||||
(Config.app_path / "data/key/public_key.pem").write_bytes(
|
||||
public_key_local.exportKey()
|
||||
)
|
||||
# 生成密钥转换与校验随机盐
|
||||
PASSWORD_salt = secrets.token_hex(random.randint(32, 1024))
|
||||
(Config.app_path / "data/key/PASSWORDsalt.txt").write_text(
|
||||
PASSWORD_salt,
|
||||
encoding="utf-8",
|
||||
)
|
||||
verify_salt = secrets.token_hex(random.randint(32, 1024))
|
||||
(Config.app_path / "data/key/verifysalt.txt").write_text(
|
||||
verify_salt,
|
||||
encoding="utf-8",
|
||||
)
|
||||
# 将管理密钥转化为AES-256密钥
|
||||
AES_password = hashlib.sha256(
|
||||
(PASSWORD + PASSWORD_salt).encode("utf-8")
|
||||
).digest()
|
||||
# 生成AES-256密钥校验哈希值并保存
|
||||
AES_password_verify = hashlib.sha256(
|
||||
AES_password + verify_salt.encode("utf-8")
|
||||
).digest()
|
||||
(Config.app_path / "data/key/AES_password_verify.bin").write_bytes(
|
||||
AES_password_verify
|
||||
)
|
||||
# AES-256加密RSA私钥并保存密文
|
||||
AES_key = AES.new(AES_password, AES.MODE_ECB)
|
||||
private_key_local = AES_key.encrypt(pad(private_key.exportKey(), 32))
|
||||
(Config.app_path / "data/key/private_key.bin").write_bytes(private_key_local)
|
||||
|
||||
def encryptx(self, note: str) -> bytes:
|
||||
"""加密数据"""
|
||||
|
||||
# 读取RSA公钥
|
||||
public_key_local = RSA.import_key(
|
||||
(Config.app_path / "data/key/public_key.pem").read_bytes()
|
||||
)
|
||||
# 使用RSA公钥对数据进行加密
|
||||
cipher = PKCS1_OAEP.new(public_key_local)
|
||||
encrypted = cipher.encrypt(note.encode("utf-8"))
|
||||
return encrypted
|
||||
|
||||
def decryptx(self, note: bytes, PASSWORD: str) -> str:
|
||||
"""解密数据"""
|
||||
|
||||
# 读入RSA私钥密文、盐与校验哈希值
|
||||
private_key_local = (
|
||||
(Config.app_path / "data/key/private_key.bin").read_bytes().strip()
|
||||
)
|
||||
PASSWORD_salt = (
|
||||
(Config.app_path / "data/key/PASSWORDsalt.txt")
|
||||
.read_text(encoding="utf-8")
|
||||
.strip()
|
||||
)
|
||||
verify_salt = (
|
||||
(Config.app_path / "data/key/verifysalt.txt")
|
||||
.read_text(encoding="utf-8")
|
||||
.strip()
|
||||
)
|
||||
AES_password_verify = (
|
||||
(Config.app_path / "data/key/AES_password_verify.bin").read_bytes().strip()
|
||||
)
|
||||
# 将管理密钥转化为AES-256密钥并验证
|
||||
AES_password = hashlib.sha256(
|
||||
(PASSWORD + PASSWORD_salt).encode("utf-8")
|
||||
).digest()
|
||||
AES_password_SHA = hashlib.sha256(
|
||||
AES_password + verify_salt.encode("utf-8")
|
||||
).digest()
|
||||
if AES_password_SHA != AES_password_verify:
|
||||
return "管理密钥错误"
|
||||
else:
|
||||
# AES解密RSA私钥
|
||||
AES_key = AES.new(AES_password, AES.MODE_ECB)
|
||||
private_key_pem = unpad(AES_key.decrypt(private_key_local), 32)
|
||||
private_key = RSA.import_key(private_key_pem)
|
||||
# 使用RSA私钥解密数据
|
||||
decrypter = PKCS1_OAEP.new(private_key)
|
||||
note = decrypter.decrypt(note)
|
||||
return note.decode("utf-8")
|
||||
|
||||
def change_PASSWORD(self, PASSWORD_old: str, PASSWORD_new: str) -> None:
|
||||
"""修改管理密钥"""
|
||||
|
||||
member_list = self.search_member()
|
||||
|
||||
for user_data in member_list:
|
||||
|
||||
# 读取用户数据
|
||||
db = sqlite3.connect(user_data["Path"])
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data = cur.fetchall()
|
||||
|
||||
# 使用旧管理密钥解密
|
||||
user_data["Password"] = []
|
||||
for i in range(len(data)):
|
||||
user_data["Password"].append(self.decryptx(data[i][12], PASSWORD_old))
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
self.get_PASSWORD(PASSWORD_new)
|
||||
|
||||
for user_data in member_list:
|
||||
|
||||
# 读取用户数据
|
||||
db = sqlite3.connect(user_data["Path"])
|
||||
cur = db.cursor()
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data = cur.fetchall()
|
||||
|
||||
# 使用新管理密钥重新加密
|
||||
for i in range(len(data)):
|
||||
cur.execute(
|
||||
"UPDATE adminx SET password = ? WHERE mode = ? AND uid = ?",
|
||||
(
|
||||
self.encryptx(user_data["Password"][i]),
|
||||
data[i][15],
|
||||
data[i][16],
|
||||
),
|
||||
)
|
||||
db.commit()
|
||||
user_data["Password"][i] = None
|
||||
del user_data["Password"]
|
||||
|
||||
cur.close()
|
||||
db.close()
|
||||
|
||||
def search_member(self) -> List[Dict[str, Union[Path, list]]]:
|
||||
"""搜索所有脚本实例及其用户数据库路径"""
|
||||
|
||||
member_list = []
|
||||
|
||||
if (Config.app_path / "config/MaaConfig").exists():
|
||||
for subdir in (Config.app_path / "config/MaaConfig").iterdir():
|
||||
if subdir.is_dir():
|
||||
|
||||
member_list.append({"Path": subdir / "user_data.db"})
|
||||
|
||||
return member_list
|
||||
|
||||
def check_PASSWORD(self, PASSWORD: str) -> bool:
|
||||
"""验证管理密钥"""
|
||||
|
||||
return bool(self.decryptx(self.encryptx(""), PASSWORD) != "管理密钥错误")
|
||||
|
||||
|
||||
Crypto = CryptoHandler()
|
||||
120
app/services/system.py
Normal file
@@ -0,0 +1,120 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA系统服务
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
import win32gui
|
||||
import win32process
|
||||
import winreg
|
||||
import psutil
|
||||
|
||||
from app.core import Config
|
||||
|
||||
|
||||
class SystemHandler:
|
||||
|
||||
ES_CONTINUOUS = 0x80000000
|
||||
ES_SYSTEM_REQUIRED = 0x00000001
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.set_Sleep()
|
||||
self.set_SelfStart()
|
||||
|
||||
def set_Sleep(self):
|
||||
"""同步系统休眠状态"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.function_IfAllowSleep):
|
||||
# 设置系统电源状态
|
||||
ctypes.windll.kernel32.SetThreadExecutionState(
|
||||
self.ES_CONTINUOUS | self.ES_SYSTEM_REQUIRED
|
||||
)
|
||||
else:
|
||||
# 恢复系统电源状态
|
||||
ctypes.windll.kernel32.SetThreadExecutionState(self.ES_CONTINUOUS)
|
||||
|
||||
def set_SelfStart(self):
|
||||
"""同步开机自启"""
|
||||
|
||||
if (
|
||||
Config.global_config.get(Config.global_config.start_IfSelfStart)
|
||||
and not self.is_startup()
|
||||
):
|
||||
key = winreg.OpenKey(
|
||||
winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\CurrentVersion\Run",
|
||||
winreg.KEY_SET_VALUE,
|
||||
winreg.KEY_ALL_ACCESS | winreg.KEY_WRITE | winreg.KEY_CREATE_SUB_KEY,
|
||||
)
|
||||
winreg.SetValueEx(key, "AUTO_MAA", 0, winreg.REG_SZ, Config.app_path_sys)
|
||||
winreg.CloseKey(key)
|
||||
elif (
|
||||
not Config.global_config.get(Config.global_config.start_IfSelfStart)
|
||||
and self.is_startup()
|
||||
):
|
||||
key = winreg.OpenKey(
|
||||
winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\CurrentVersion\Run",
|
||||
winreg.KEY_SET_VALUE,
|
||||
winreg.KEY_ALL_ACCESS | winreg.KEY_WRITE | winreg.KEY_CREATE_SUB_KEY,
|
||||
)
|
||||
winreg.DeleteValue(key, "AUTO_MAA")
|
||||
winreg.CloseKey(key)
|
||||
|
||||
def is_startup(self):
|
||||
"""判断程序是否已经开机自启"""
|
||||
|
||||
key = winreg.OpenKey(
|
||||
winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\CurrentVersion\Run",
|
||||
0,
|
||||
winreg.KEY_READ,
|
||||
)
|
||||
|
||||
try:
|
||||
value, _ = winreg.QueryValueEx(key, "AUTO_MAA")
|
||||
winreg.CloseKey(key)
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
winreg.CloseKey(key)
|
||||
return False
|
||||
|
||||
def get_window_info(self):
|
||||
"""获取当前窗口信息"""
|
||||
|
||||
def callback(hwnd, window_info):
|
||||
if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd):
|
||||
_, pid = win32process.GetWindowThreadProcessId(hwnd)
|
||||
process = psutil.Process(pid)
|
||||
window_info.append((win32gui.GetWindowText(hwnd), process.exe()))
|
||||
return True
|
||||
|
||||
window_info = []
|
||||
win32gui.EnumWindows(callback, window_info)
|
||||
return window_info
|
||||
|
||||
|
||||
System = SystemHandler()
|
||||
282
app/ui/Widget.py
Normal file
@@ -0,0 +1,282 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA组件
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from PySide6.QtCore import Qt, QTime
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout
|
||||
from qfluentwidgets import (
|
||||
LineEdit,
|
||||
PasswordLineEdit,
|
||||
MessageBoxBase,
|
||||
SubtitleLabel,
|
||||
SettingCard,
|
||||
SpinBox,
|
||||
FluentIconBase,
|
||||
Signal,
|
||||
ComboBox,
|
||||
CheckBox,
|
||||
qconfig,
|
||||
ConfigItem,
|
||||
TimeEdit,
|
||||
OptionsConfigItem,
|
||||
)
|
||||
|
||||
from typing import Union, List
|
||||
|
||||
|
||||
class InputMessageBox(MessageBoxBase):
|
||||
"""输入对话框"""
|
||||
|
||||
def __init__(self, parent, title: str, content: str, mode: str, list: list = None):
|
||||
super().__init__(parent)
|
||||
self.title = SubtitleLabel(title)
|
||||
|
||||
if mode == "明文":
|
||||
self.input = LineEdit()
|
||||
self.input.setClearButtonEnabled(True)
|
||||
elif mode == "密码":
|
||||
self.input = PasswordLineEdit()
|
||||
elif mode == "选择":
|
||||
self.input = ComboBox()
|
||||
self.input.addItems(list)
|
||||
self.input.setCurrentIndex(-1)
|
||||
|
||||
self.input.setPlaceholderText(content)
|
||||
|
||||
# 将组件添加到布局中
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(self.input)
|
||||
|
||||
|
||||
class SetMessageBox(MessageBoxBase):
|
||||
"""输入对话框"""
|
||||
|
||||
def __init__(self, parent, title: str, content: List[str], list: List[List[str]]):
|
||||
super().__init__(parent)
|
||||
self.title = SubtitleLabel(title)
|
||||
|
||||
Widget = QWidget()
|
||||
Layout = QHBoxLayout(Widget)
|
||||
|
||||
self.input: List[ComboBox] = []
|
||||
|
||||
for i in range(len(content)):
|
||||
|
||||
self.input.append(ComboBox())
|
||||
self.input[i].addItems(list[i])
|
||||
self.input[i].setCurrentIndex(-1)
|
||||
self.input[i].setPlaceholderText(content[i])
|
||||
Layout.addWidget(self.input[i])
|
||||
|
||||
# 将组件添加到布局中
|
||||
self.viewLayout.addWidget(self.title)
|
||||
self.viewLayout.addWidget(Widget)
|
||||
|
||||
|
||||
class LineEditSettingCard(SettingCard):
|
||||
"""Setting card with switch button"""
|
||||
|
||||
textChanged = Signal(str)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title,
|
||||
content=None,
|
||||
configItem: ConfigItem = None,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem = configItem
|
||||
self.LineEdit = LineEdit(self)
|
||||
self.LineEdit.setMinimumWidth(250)
|
||||
self.LineEdit.setPlaceholderText(text)
|
||||
|
||||
if configItem:
|
||||
self.setValue(qconfig.get(configItem))
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
self.hBoxLayout.addWidget(self.LineEdit, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.LineEdit.textChanged.connect(self.__textChanged)
|
||||
|
||||
def __textChanged(self, content: str):
|
||||
self.setValue(content)
|
||||
self.textChanged.emit(content)
|
||||
|
||||
def setValue(self, content: str):
|
||||
if self.configItem:
|
||||
qconfig.set(self.configItem, content)
|
||||
|
||||
self.LineEdit.setText(content)
|
||||
|
||||
|
||||
class SpinBoxSettingCard(SettingCard):
|
||||
|
||||
textChanged = Signal(int)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
range: tuple[int, int],
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title,
|
||||
content=None,
|
||||
configItem: ConfigItem = None,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem = configItem
|
||||
self.SpinBox = SpinBox(self)
|
||||
self.SpinBox.setRange(range[0], range[1])
|
||||
self.SpinBox.setMinimumWidth(150)
|
||||
|
||||
if configItem:
|
||||
self.setValue(qconfig.get(configItem))
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
self.hBoxLayout.addWidget(self.SpinBox, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.SpinBox.valueChanged.connect(self.__valueChanged)
|
||||
|
||||
def __valueChanged(self, value: int):
|
||||
self.setValue(value)
|
||||
self.textChanged.emit(value)
|
||||
|
||||
def setValue(self, value: int):
|
||||
if self.configItem:
|
||||
qconfig.set(self.configItem, value)
|
||||
|
||||
self.SpinBox.setValue(value)
|
||||
|
||||
|
||||
class NoOptionComboBoxSettingCard(SettingCard):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
configItem: OptionsConfigItem,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title,
|
||||
content=None,
|
||||
value=None,
|
||||
texts=None,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem = configItem
|
||||
self.comboBox = ComboBox(self)
|
||||
self.comboBox.setMinimumWidth(250)
|
||||
self.hBoxLayout.addWidget(self.comboBox, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.optionToText = {o: t for o, t in zip(value, texts)}
|
||||
for text, option in zip(texts, value):
|
||||
self.comboBox.addItem(text, userData=option)
|
||||
|
||||
self.comboBox.setCurrentText(self.optionToText[qconfig.get(configItem)])
|
||||
self.comboBox.currentIndexChanged.connect(self._onCurrentIndexChanged)
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
def _onCurrentIndexChanged(self, index: int):
|
||||
|
||||
qconfig.set(self.configItem, self.comboBox.itemData(index))
|
||||
|
||||
def setValue(self, value):
|
||||
if value not in self.optionToText:
|
||||
return
|
||||
|
||||
self.comboBox.setCurrentText(self.optionToText[value])
|
||||
qconfig.set(self.configItem, value)
|
||||
|
||||
|
||||
class TimeEditSettingCard(SettingCard):
|
||||
|
||||
enabledChanged = Signal(bool)
|
||||
timeChanged = Signal(str)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title,
|
||||
content=None,
|
||||
configItem_bool: ConfigItem = None,
|
||||
configItem_time: ConfigItem = None,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem_bool = configItem_bool
|
||||
self.configItem_time = configItem_time
|
||||
self.CheckBox = CheckBox(self)
|
||||
self.CheckBox.setTristate(False)
|
||||
self.TimeEdit = TimeEdit(self)
|
||||
self.TimeEdit.setDisplayFormat("HH:mm")
|
||||
self.TimeEdit.setMinimumWidth(150)
|
||||
|
||||
if configItem_bool:
|
||||
self.setValue_bool(qconfig.get(configItem_bool))
|
||||
configItem_bool.valueChanged.connect(self.setValue_bool)
|
||||
|
||||
if configItem_time:
|
||||
self.setValue_time(qconfig.get(configItem_time))
|
||||
configItem_time.valueChanged.connect(self.setValue_time)
|
||||
|
||||
self.hBoxLayout.addWidget(self.CheckBox, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addWidget(self.TimeEdit, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.CheckBox.stateChanged.connect(self.__enableChanged)
|
||||
self.TimeEdit.timeChanged.connect(self.__timeChanged)
|
||||
|
||||
def __timeChanged(self, value: QTime):
|
||||
self.setValue_time(value.toString("HH:mm"))
|
||||
self.timeChanged.emit(value.toString("HH:mm"))
|
||||
|
||||
def __enableChanged(self, value: int):
|
||||
if value == 0:
|
||||
self.setValue_bool(False)
|
||||
self.enabledChanged.emit(False)
|
||||
else:
|
||||
self.setValue_bool(True)
|
||||
self.enabledChanged.emit(True)
|
||||
|
||||
def setValue_bool(self, value: bool):
|
||||
if self.configItem_bool:
|
||||
qconfig.set(self.configItem_bool, value)
|
||||
|
||||
self.CheckBox.setChecked(value)
|
||||
|
||||
def setValue_time(self, value: str):
|
||||
if self.configItem_time:
|
||||
qconfig.set(self.configItem_time, value)
|
||||
|
||||
self.TimeEdit.setTime(QTime.fromString(value, "HH:mm"))
|
||||
34
app/ui/__init__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA图形化界面包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .main_window import AUTO_MAA
|
||||
|
||||
__all__ = ["AUTO_MAA"]
|
||||
446
app/ui/dispatch_center.py
Normal file
@@ -0,0 +1,446 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA调度中枢界面
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QStackedWidget,
|
||||
QHBoxLayout,
|
||||
)
|
||||
from qfluentwidgets import (
|
||||
CardWidget,
|
||||
IconWidget,
|
||||
BodyLabel,
|
||||
Pivot,
|
||||
ScrollArea,
|
||||
FluentIcon,
|
||||
HeaderCardWidget,
|
||||
FluentIcon,
|
||||
TextBrowser,
|
||||
ComboBox,
|
||||
SubtitleLabel,
|
||||
PushButton,
|
||||
)
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QTextCursor
|
||||
from typing import List, Dict
|
||||
import json
|
||||
|
||||
|
||||
from app.core import Config, Task_manager, Task, MainInfoBar
|
||||
|
||||
|
||||
class DispatchCenter(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName("调度中枢")
|
||||
|
||||
self.pivot = Pivot(self)
|
||||
self.stackedWidget = QStackedWidget(self)
|
||||
self.Layout = QVBoxLayout(self)
|
||||
|
||||
self.script_list: Dict[str, DispatchBox] = {}
|
||||
|
||||
dispatch_box = DispatchBox("主调度台", self)
|
||||
self.script_list["主调度台"] = dispatch_box
|
||||
self.stackedWidget.addWidget(self.script_list["主调度台"])
|
||||
self.pivot.addItem(
|
||||
routeKey="主调度台",
|
||||
text="主调度台",
|
||||
onClick=self.update_top_bar,
|
||||
icon=FluentIcon.CAFE,
|
||||
)
|
||||
|
||||
self.Layout.addWidget(self.pivot, 0, Qt.AlignHCenter)
|
||||
self.Layout.addWidget(self.stackedWidget)
|
||||
self.Layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
self.pivot.currentItemChanged.connect(
|
||||
lambda index: self.stackedWidget.setCurrentWidget(self.script_list[index])
|
||||
)
|
||||
|
||||
def add_board(self, task: Task) -> None:
|
||||
"""添加一个调度台界面"""
|
||||
|
||||
dispatch_box = DispatchBox(task.name, self)
|
||||
|
||||
dispatch_box.top_bar.button.clicked.connect(
|
||||
lambda: Task_manager.stop_task(task.name)
|
||||
)
|
||||
|
||||
task.create_task_list.connect(dispatch_box.info.task.create_task)
|
||||
task.create_user_list.connect(dispatch_box.info.user.create_user)
|
||||
task.update_task_list.connect(dispatch_box.info.task.update_task)
|
||||
task.update_user_list.connect(dispatch_box.info.user.update_user)
|
||||
task.update_log_text.connect(dispatch_box.info.log_text.text.setText)
|
||||
task.accomplish.connect(lambda: self.del_board(f"调度台_{task.name}"))
|
||||
|
||||
self.script_list[f"调度台_{task.name}"] = dispatch_box
|
||||
|
||||
self.stackedWidget.addWidget(self.script_list[f"调度台_{task.name}"])
|
||||
|
||||
self.pivot.addItem(routeKey=f"调度台_{task.name}", text=f"调度台 {task.name}")
|
||||
|
||||
def del_board(self, name: str) -> None:
|
||||
"""删除指定子界面"""
|
||||
|
||||
self.pivot.setCurrentItem("主调度台")
|
||||
self.stackedWidget.removeWidget(self.script_list[name])
|
||||
self.script_list[name].deleteLater()
|
||||
self.pivot.removeWidget(name)
|
||||
|
||||
def connect_main_board(self, task: Task) -> None:
|
||||
"""连接主调度台"""
|
||||
|
||||
self.script_list["主调度台"].top_bar.Lable.setText(
|
||||
f"{task.name} - {task.mode.replace("_主调度台","")}模式"
|
||||
)
|
||||
self.script_list["主调度台"].top_bar.Lable.show()
|
||||
self.script_list["主调度台"].top_bar.object.hide()
|
||||
self.script_list["主调度台"].top_bar.mode.hide()
|
||||
self.script_list["主调度台"].top_bar.button.clicked.disconnect()
|
||||
self.script_list["主调度台"].top_bar.button.setText("中止任务")
|
||||
self.script_list["主调度台"].top_bar.button.clicked.connect(
|
||||
lambda: Task_manager.stop_task(task.name)
|
||||
)
|
||||
task.create_task_list.connect(
|
||||
self.script_list["主调度台"].info.task.create_task
|
||||
)
|
||||
task.create_user_list.connect(
|
||||
self.script_list["主调度台"].info.user.create_user
|
||||
)
|
||||
task.update_task_list.connect(
|
||||
self.script_list["主调度台"].info.task.update_task
|
||||
)
|
||||
task.update_user_list.connect(
|
||||
self.script_list["主调度台"].info.user.update_user
|
||||
)
|
||||
task.update_log_text.connect(
|
||||
self.script_list["主调度台"].info.log_text.text.setText
|
||||
)
|
||||
task.accomplish.connect(lambda: self.disconnect_main_board(task.name))
|
||||
|
||||
def disconnect_main_board(self, name: str) -> None:
|
||||
"""断开主调度台"""
|
||||
|
||||
self.script_list["主调度台"].top_bar.Lable.hide()
|
||||
self.script_list["主调度台"].top_bar.object.show()
|
||||
self.script_list["主调度台"].top_bar.mode.show()
|
||||
self.script_list["主调度台"].top_bar.button.clicked.disconnect()
|
||||
self.script_list["主调度台"].top_bar.button.setText("开始任务")
|
||||
self.script_list["主调度台"].top_bar.button.clicked.connect(
|
||||
self.script_list["主调度台"].top_bar.start_task
|
||||
)
|
||||
self.script_list["主调度台"].info.log_text.text.setText(
|
||||
Config.get_history(name)["History"]
|
||||
)
|
||||
|
||||
def update_top_bar(self):
|
||||
"""更新顶栏"""
|
||||
|
||||
list = []
|
||||
|
||||
if (Config.app_path / "config/QueueConfig").exists():
|
||||
for json_file in (Config.app_path / "config/QueueConfig").glob("*.json"):
|
||||
list.append(f"队列 - {json_file.stem}")
|
||||
|
||||
if (Config.app_path / "config/MaaConfig").exists():
|
||||
for subdir in (Config.app_path / "config/MaaConfig").iterdir():
|
||||
if subdir.is_dir():
|
||||
list.append(f"实例 - Maa - {subdir.name}")
|
||||
|
||||
self.script_list["主调度台"].top_bar.object.clear()
|
||||
self.script_list["主调度台"].top_bar.object.addItems(list)
|
||||
self.script_list["主调度台"].top_bar.object.setCurrentIndex(-1)
|
||||
self.script_list["主调度台"].top_bar.mode.setCurrentIndex(-1)
|
||||
|
||||
|
||||
class DispatchBox(QWidget):
|
||||
|
||||
def __init__(self, name: str, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName(name)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
scrollArea = ScrollArea()
|
||||
scrollArea.setWidgetResizable(True)
|
||||
|
||||
content_widget = QWidget()
|
||||
content_layout = QVBoxLayout(content_widget)
|
||||
|
||||
self.top_bar = self.DispatchTopBar(self, name)
|
||||
self.info = self.DispatchInfoCard(self)
|
||||
|
||||
content_layout.addWidget(self.top_bar)
|
||||
content_layout.addWidget(self.info)
|
||||
|
||||
scrollArea.setWidget(content_widget)
|
||||
|
||||
layout.addWidget(scrollArea)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
class DispatchTopBar(CardWidget):
|
||||
|
||||
def __init__(self, parent=None, name: str = None):
|
||||
super().__init__(parent)
|
||||
|
||||
Layout = QHBoxLayout(self)
|
||||
|
||||
if name == "主调度台":
|
||||
|
||||
self.Lable = SubtitleLabel("", self)
|
||||
self.Lable.hide()
|
||||
self.object = ComboBox()
|
||||
self.object.setPlaceholderText("请选择调度对象")
|
||||
self.mode = ComboBox()
|
||||
self.mode.addItems(["自动代理", "人工排查"])
|
||||
self.mode.setPlaceholderText("请选择调度模式")
|
||||
|
||||
self.button = PushButton("开始任务")
|
||||
self.button.clicked.connect(self.start_task)
|
||||
|
||||
Layout.addWidget(self.Lable)
|
||||
Layout.addWidget(self.object)
|
||||
Layout.addWidget(self.mode)
|
||||
Layout.addStretch(1)
|
||||
Layout.addWidget(self.button)
|
||||
|
||||
else:
|
||||
|
||||
self.Lable = SubtitleLabel(name, self)
|
||||
self.button = PushButton("中止任务")
|
||||
|
||||
Layout.addWidget(self.Lable)
|
||||
Layout.addStretch(1)
|
||||
Layout.addWidget(self.button)
|
||||
|
||||
def start_task(self):
|
||||
"""开始任务"""
|
||||
|
||||
if self.object.currentIndex() == -1:
|
||||
logger.warning("未选择调度对象")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度对象", "请选择后再开始任务", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
if self.mode.currentIndex() == -1:
|
||||
logger.warning("未选择调度模式")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度模式", "请选择后再开始任务", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
name = self.object.currentText().split(" - ")[-1]
|
||||
|
||||
if name in Config.running_list:
|
||||
logger.warning(f"任务已存在:{name}")
|
||||
MainInfoBar.push_info_bar("warning", "任务已存在", name, 5000)
|
||||
return None
|
||||
|
||||
if self.object.currentText().split(" - ")[0] == "队列":
|
||||
|
||||
with (Config.app_path / f"config/QueueConfig/{name}.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
info = json.load(f)
|
||||
|
||||
logger.info(f"用户添加任务:{name}")
|
||||
Task_manager.add_task(f"{self.mode.currentText()}_主调度台", name, info)
|
||||
|
||||
elif self.object.currentText().split(" - ")[0] == "实例":
|
||||
|
||||
if self.object.currentText().split(" - ")[1] == "Maa":
|
||||
|
||||
info = {"Queue": {"Member_1": name}}
|
||||
|
||||
logger.info(f"用户添加任务:{name}")
|
||||
Task_manager.add_task(
|
||||
f"{self.mode.currentText()}_主调度台", "用户自定义队列", info
|
||||
)
|
||||
|
||||
class DispatchInfoCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("调度信息")
|
||||
|
||||
self.task = self.TaskInfoCard(self)
|
||||
self.user = self.UserInfoCard(self)
|
||||
self.log_text = self.LogCard(self)
|
||||
|
||||
self.viewLayout.addWidget(self.task)
|
||||
self.viewLayout.addWidget(self.user)
|
||||
self.viewLayout.addWidget(self.log_text)
|
||||
|
||||
self.viewLayout.setStretch(0, 1)
|
||||
self.viewLayout.setStretch(1, 1)
|
||||
self.viewLayout.setStretch(2, 5)
|
||||
|
||||
def update_board(self, task_list: list, user_list: list, log: str):
|
||||
"""更新调度信息"""
|
||||
|
||||
self.task.update_task(task_list)
|
||||
self.user.update_user(user_list)
|
||||
self.log_text.text.setText(log)
|
||||
|
||||
class TaskInfoCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("任务队列")
|
||||
|
||||
self.Layout = QVBoxLayout()
|
||||
self.viewLayout.addLayout(self.Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
self.task_cards: List[ItemCard] = []
|
||||
|
||||
def create_task(self, task_list: list):
|
||||
"""创建任务队列"""
|
||||
|
||||
while self.Layout.count() > 0:
|
||||
item = self.Layout.takeAt(0)
|
||||
if item.spacerItem():
|
||||
self.Layout.removeItem(item.spacerItem())
|
||||
elif item.widget():
|
||||
item.widget().deleteLater()
|
||||
|
||||
self.task_cards = []
|
||||
|
||||
for task in task_list:
|
||||
|
||||
self.task_cards.append(ItemCard(task))
|
||||
self.Layout.addWidget(self.task_cards[-1])
|
||||
|
||||
self.Layout.addStretch(1)
|
||||
|
||||
def update_task(self, task_list: list):
|
||||
"""更新任务队列"""
|
||||
|
||||
for i in range(len(task_list)):
|
||||
|
||||
self.task_cards[i].update_status(task_list[i][1])
|
||||
|
||||
class UserInfoCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("用户队列")
|
||||
|
||||
self.Layout = QVBoxLayout()
|
||||
self.viewLayout.addLayout(self.Layout)
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
|
||||
self.user_cards: List[ItemCard] = []
|
||||
|
||||
def create_user(self, user_list: list):
|
||||
"""创建用户队列"""
|
||||
|
||||
while self.Layout.count() > 0:
|
||||
item = self.Layout.takeAt(0)
|
||||
if item.spacerItem():
|
||||
self.Layout.removeItem(item.spacerItem())
|
||||
elif item.widget():
|
||||
item.widget().deleteLater()
|
||||
|
||||
self.user_cards = []
|
||||
|
||||
for user in user_list:
|
||||
|
||||
self.user_cards.append(ItemCard(user))
|
||||
self.Layout.addWidget(self.user_cards[-1])
|
||||
|
||||
self.Layout.addStretch(1)
|
||||
|
||||
def update_user(self, user_list: list):
|
||||
"""更新用户队列"""
|
||||
|
||||
for i in range(len(user_list)):
|
||||
|
||||
self.user_cards[i].Label.setText(user_list[i][0])
|
||||
self.user_cards[i].update_status(user_list[i][1])
|
||||
|
||||
class LogCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("日志")
|
||||
|
||||
self.text = TextBrowser()
|
||||
self.viewLayout.setContentsMargins(3, 0, 3, 3)
|
||||
self.viewLayout.addWidget(self.text)
|
||||
|
||||
self.text.textChanged.connect(self.to_end)
|
||||
|
||||
def to_end(self):
|
||||
"""滚动到底部"""
|
||||
|
||||
self.text.moveCursor(QTextCursor.End)
|
||||
self.text.ensureCursorVisible()
|
||||
|
||||
|
||||
class ItemCard(CardWidget):
|
||||
|
||||
def __init__(self, task_item: list, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.Layout = QHBoxLayout(self)
|
||||
|
||||
self.Label = BodyLabel(task_item[0], self)
|
||||
self.icon = IconWidget(FluentIcon.MORE, self)
|
||||
self.icon.setFixedSize(16, 16)
|
||||
self.update_status(task_item[1])
|
||||
|
||||
self.Layout.addWidget(self.icon)
|
||||
self.Layout.addWidget(self.Label)
|
||||
self.Layout.addStretch(1)
|
||||
|
||||
def update_status(self, status: str):
|
||||
|
||||
if status == "完成":
|
||||
self.icon.setIcon(FluentIcon.ACCEPT)
|
||||
self.Label.setTextColor("#0eb840", "#0eb840")
|
||||
elif status == "等待":
|
||||
self.icon.setIcon(FluentIcon.MORE)
|
||||
self.Label.setTextColor("#7397ab", "#7397ab")
|
||||
elif status == "运行":
|
||||
self.icon.setIcon(FluentIcon.PLAY)
|
||||
self.Label.setTextColor("#2e4e7e", "#2e4e7e")
|
||||
elif status == "跳过":
|
||||
self.icon.setIcon(FluentIcon.REMOVE)
|
||||
self.Label.setTextColor("#606060", "#d2d2d2")
|
||||
elif status == "异常":
|
||||
self.icon.setIcon(FluentIcon.CLOSE)
|
||||
self.Label.setTextColor("#ff2121", "#ff2121")
|
||||
347
app/ui/main_window.py
Normal file
@@ -0,0 +1,347 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA主界面
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QSystemTrayIcon,
|
||||
)
|
||||
from qfluentwidgets import (
|
||||
Action,
|
||||
PushButton,
|
||||
SystemTrayMenu,
|
||||
SplashScreen,
|
||||
FluentIcon,
|
||||
InfoBar,
|
||||
InfoBarPosition,
|
||||
setTheme,
|
||||
Theme,
|
||||
MSFluentWindow,
|
||||
NavigationItemPosition,
|
||||
qconfig,
|
||||
)
|
||||
from PySide6.QtGui import QIcon, QCloseEvent
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from app.core import Config, Task_manager, Main_timer, MainInfoBar
|
||||
from app.services import Notify, Crypto, System
|
||||
from .setting import Setting
|
||||
from .member_manager import MemberManager
|
||||
from .queue_manager import QueueManager
|
||||
from .dispatch_center import DispatchCenter
|
||||
|
||||
|
||||
class AUTO_MAA(MSFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowIcon(QIcon(str(Config.app_path / "resources/icons/AUTO_MAA.ico")))
|
||||
self.setWindowTitle("AUTO_MAA")
|
||||
|
||||
setTheme(Theme.AUTO)
|
||||
|
||||
self.splashScreen = SplashScreen(self.windowIcon(), self)
|
||||
self.show_ui("显示主窗口", if_quick=True)
|
||||
|
||||
MainInfoBar.parent = self
|
||||
|
||||
# 创建主窗口
|
||||
self.setting = Setting(self)
|
||||
self.member_manager = MemberManager(self)
|
||||
self.queue_manager = QueueManager(self)
|
||||
self.dispatch_center = DispatchCenter(self)
|
||||
|
||||
self.addSubInterface(
|
||||
self.setting,
|
||||
FluentIcon.SETTING,
|
||||
"设置",
|
||||
FluentIcon.SETTING,
|
||||
NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
self.addSubInterface(
|
||||
self.member_manager,
|
||||
FluentIcon.ROBOT,
|
||||
"脚本管理",
|
||||
FluentIcon.ROBOT,
|
||||
NavigationItemPosition.TOP,
|
||||
)
|
||||
self.addSubInterface(
|
||||
self.queue_manager,
|
||||
FluentIcon.BOOK_SHELF,
|
||||
"调度队列",
|
||||
FluentIcon.BOOK_SHELF,
|
||||
NavigationItemPosition.TOP,
|
||||
)
|
||||
self.addSubInterface(
|
||||
self.dispatch_center,
|
||||
FluentIcon.IOT,
|
||||
"调度中心",
|
||||
FluentIcon.IOT,
|
||||
NavigationItemPosition.TOP,
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (self.member_manager.refresh() if index == 1 else None)
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: self.queue_manager.refresh() if index == 2 else None
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (
|
||||
self.dispatch_center.pivot.setCurrentItem("主调度台")
|
||||
if index == 3
|
||||
else None
|
||||
)
|
||||
)
|
||||
self.stackedWidget.currentChanged.connect(
|
||||
lambda index: (
|
||||
self.dispatch_center.update_top_bar() if index == 3 else None
|
||||
)
|
||||
)
|
||||
|
||||
# 创建系统托盘及其菜单
|
||||
self.tray = QSystemTrayIcon(
|
||||
QIcon(str(Config.app_path / "resources/icons/AUTO_MAA.ico")),
|
||||
self,
|
||||
)
|
||||
self.tray.setToolTip("AUTO_MAA")
|
||||
self.tray_menu = SystemTrayMenu("AUTO_MAA", self)
|
||||
|
||||
# 显示主界面菜单项
|
||||
self.tray_menu.addAction(
|
||||
Action(
|
||||
FluentIcon.CAFE,
|
||||
"显示主界面",
|
||||
triggered=lambda: self.show_ui("显示主窗口"),
|
||||
)
|
||||
)
|
||||
self.tray_menu.addSeparator()
|
||||
|
||||
# 开始任务菜单项
|
||||
# self.tray_menu.addActions(
|
||||
# [
|
||||
# Action(
|
||||
# FluentIcon.PLAY,
|
||||
# "运行自动代理",
|
||||
# triggered=lambda: self.start_task("自动代理"),
|
||||
# ),
|
||||
# Action(
|
||||
# FluentIcon.PLAY,
|
||||
# "运行人工排查",
|
||||
# triggered=lambda: self.start_task("人工排查"),
|
||||
# ),
|
||||
# Action(FluentIcon.PAUSE, "中止当前任务", triggered=self.stop_task),
|
||||
# ]
|
||||
# )
|
||||
# self.tray_menu.addSeparator()
|
||||
|
||||
# 退出主程序菜单项
|
||||
self.tray_menu.addAction(
|
||||
Action(FluentIcon.POWER_BUTTON, "退出主程序", triggered=self.kill_main)
|
||||
)
|
||||
|
||||
# 设置托盘菜单
|
||||
self.tray.setContextMenu(self.tray_menu)
|
||||
self.tray.activated.connect(self.on_tray_activated)
|
||||
|
||||
Task_manager.create_gui.connect(self.dispatch_center.add_board)
|
||||
Task_manager.connect_gui.connect(self.dispatch_center.connect_main_board)
|
||||
self.setting.ui.card_IfShowTray.checkedChanged.connect(
|
||||
lambda: self.show_ui("配置托盘")
|
||||
)
|
||||
self.setting.ui.card_IfToTray.checkedChanged.connect(self.set_min_method)
|
||||
|
||||
self.splashScreen.finish()
|
||||
|
||||
def start_up_task(self) -> None:
|
||||
"""启动时任务"""
|
||||
|
||||
# 加载配置
|
||||
qconfig.load(Config.config_path, Config.global_config)
|
||||
Config.global_config.save()
|
||||
|
||||
# 检查密码
|
||||
self.setting.check_PASSWORD()
|
||||
|
||||
# 获取公告
|
||||
self.setting.show_notice(if_show=False)
|
||||
|
||||
# 检查更新
|
||||
if Config.global_config.get(Config.global_config.update_IfAutoUpdate):
|
||||
result = self.setting.get_update_info()
|
||||
if result == "已是最新版本~":
|
||||
MainInfoBar.push_info_bar("success", "更新检查", result, 3000)
|
||||
else:
|
||||
info = InfoBar.info(
|
||||
title="更新检查",
|
||||
content=result,
|
||||
orient=Qt.Horizontal,
|
||||
isClosable=True,
|
||||
position=InfoBarPosition.BOTTOM_LEFT,
|
||||
duration=-1,
|
||||
parent=self,
|
||||
)
|
||||
Up = PushButton("更新")
|
||||
Up.clicked.connect(lambda: self.setting.get_update(if_question=False))
|
||||
Up.clicked.connect(info.close)
|
||||
info.addWidget(Up)
|
||||
info.show()
|
||||
|
||||
def set_min_method(self) -> None:
|
||||
"""设置最小化方法"""
|
||||
|
||||
if Config.global_config.get(Config.global_config.ui_IfToTray):
|
||||
|
||||
self.titleBar.minBtn.clicked.disconnect()
|
||||
self.titleBar.minBtn.clicked.connect(lambda: self.show_ui("隐藏到托盘"))
|
||||
|
||||
else:
|
||||
|
||||
self.titleBar.minBtn.clicked.disconnect()
|
||||
self.titleBar.minBtn.clicked.connect(self.showMinimized)
|
||||
|
||||
def on_tray_activated(self, reason):
|
||||
"""双击返回主界面"""
|
||||
if reason == QSystemTrayIcon.DoubleClick:
|
||||
self.show_ui("显示主窗口")
|
||||
|
||||
# def start_task(self, mode):
|
||||
# """调起对应任务"""
|
||||
# if self.main.MaaManager.isRunning():
|
||||
# Notify.push_notification(
|
||||
# f"无法运行{mode}!",
|
||||
# "当前已有任务正在运行,请在该任务结束后重试",
|
||||
# "当前已有任务正在运行,请在该任务结束后重试",
|
||||
# 3,
|
||||
# )
|
||||
# else:
|
||||
# self.main.maa_starter(mode)
|
||||
|
||||
# def stop_task(self):
|
||||
# """中止当前任务"""
|
||||
# if self.main.MaaManager.isRunning():
|
||||
# if (
|
||||
# self.main.MaaManager.mode == "自动代理"
|
||||
# or self.main.MaaManager.mode == "人工排查"
|
||||
# ):
|
||||
# self.main.maa_ender(f"{self.main.MaaManager.mode}_结束")
|
||||
# elif "设置MAA" in self.main.MaaManager.mode:
|
||||
# Notify.push_notification(
|
||||
# "正在设置MAA!",
|
||||
# "正在运行设置MAA任务,无法中止",
|
||||
# "正在运行设置MAA任务,无法中止",
|
||||
# 3,
|
||||
# )
|
||||
# else:
|
||||
# Notify.push_notification(
|
||||
# "无任务运行!",
|
||||
# "当前无任务正在运行,无需中止",
|
||||
# "当前无任务正在运行,无需中止",
|
||||
# 3,
|
||||
# )
|
||||
|
||||
def kill_main(self) -> None:
|
||||
"""退出主程序"""
|
||||
self.close()
|
||||
QApplication.quit()
|
||||
|
||||
def show_ui(self, mode: str, if_quick: bool = False) -> None:
|
||||
"""配置窗口状态"""
|
||||
|
||||
if mode == "显示主窗口":
|
||||
|
||||
# 配置主窗口
|
||||
size = list(
|
||||
map(
|
||||
int,
|
||||
Config.global_config.get(Config.global_config.ui_size).split("x"),
|
||||
)
|
||||
)
|
||||
location = list(
|
||||
map(
|
||||
int,
|
||||
Config.global_config.get(Config.global_config.ui_location).split(
|
||||
"x"
|
||||
),
|
||||
)
|
||||
)
|
||||
self.setGeometry(location[0], location[1], size[0], size[1])
|
||||
self.show()
|
||||
if not if_quick:
|
||||
if Config.global_config.get(Config.global_config.ui_maximized):
|
||||
self.showMaximized()
|
||||
self.set_min_method()
|
||||
self.show_ui("配置托盘")
|
||||
|
||||
elif mode == "配置托盘":
|
||||
|
||||
if Config.global_config.get(Config.global_config.ui_IfShowTray):
|
||||
self.tray.show()
|
||||
else:
|
||||
self.tray.hide()
|
||||
|
||||
elif mode == "隐藏到托盘":
|
||||
|
||||
# 保存窗口相关属性
|
||||
if not self.isMaximized():
|
||||
|
||||
Config.global_config.set(
|
||||
Config.global_config.ui_size,
|
||||
f"{self.geometry().width()}x{self.geometry().height()}",
|
||||
)
|
||||
Config.global_config.set(
|
||||
Config.global_config.ui_location,
|
||||
f"{self.geometry().x()}x{self.geometry().y()}",
|
||||
)
|
||||
Config.global_config.set(
|
||||
Config.global_config.ui_maximized, self.isMaximized()
|
||||
)
|
||||
Config.global_config.save()
|
||||
|
||||
# 隐藏主窗口
|
||||
if not if_quick:
|
||||
|
||||
self.hide()
|
||||
self.tray.show()
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
"""清理残余进程"""
|
||||
|
||||
self.show_ui("隐藏到托盘", if_quick=True)
|
||||
|
||||
# 清理各功能线程
|
||||
Main_timer.Timer.stop()
|
||||
Main_timer.Timer.deleteLater()
|
||||
Task_manager.stop_task("ALL")
|
||||
|
||||
# 关闭数据库连接
|
||||
Config.close_database()
|
||||
|
||||
logger.info("AUTO_MAA主程序关闭")
|
||||
logger.info("===================================")
|
||||
|
||||
event.accept()
|
||||
1646
app/ui/member_manager.py
Normal file
657
app/ui/queue_manager.py
Normal file
@@ -0,0 +1,657 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA调度队列界面
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QStackedWidget,
|
||||
QHBoxLayout,
|
||||
)
|
||||
from qfluentwidgets import (
|
||||
Action,
|
||||
qconfig,
|
||||
Pivot,
|
||||
ScrollArea,
|
||||
FluentIcon,
|
||||
MessageBox,
|
||||
HeaderCardWidget,
|
||||
TextBrowser,
|
||||
CommandBar,
|
||||
SwitchSettingCard,
|
||||
)
|
||||
from PySide6.QtCore import Qt
|
||||
from typing import List
|
||||
import json
|
||||
import shutil
|
||||
|
||||
from app.core import Config, MainInfoBar
|
||||
from .Widget import (
|
||||
LineEditSettingCard,
|
||||
TimeEditSettingCard,
|
||||
NoOptionComboBoxSettingCard,
|
||||
)
|
||||
|
||||
|
||||
class QueueManager(QWidget):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent=None,
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName("调度队列")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
self.tools = CommandBar()
|
||||
|
||||
self.queue_manager = QueueSettingBox(self)
|
||||
|
||||
# 逐个添加动作
|
||||
self.tools.addActions(
|
||||
[
|
||||
Action(
|
||||
FluentIcon.ADD_TO, "新建调度队列", triggered=self.add_setting_box
|
||||
),
|
||||
Action(
|
||||
FluentIcon.REMOVE_FROM,
|
||||
"删除调度队列",
|
||||
triggered=self.del_setting_box,
|
||||
),
|
||||
]
|
||||
)
|
||||
self.tools.addSeparator()
|
||||
self.tools.addActions(
|
||||
[
|
||||
Action(
|
||||
FluentIcon.LEFT_ARROW, "向左移动", triggered=self.left_setting_box
|
||||
),
|
||||
Action(
|
||||
FluentIcon.RIGHT_ARROW, "向右移动", triggered=self.right_setting_box
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
layout.addWidget(self.tools)
|
||||
layout.addWidget(self.queue_manager)
|
||||
|
||||
def add_setting_box(self):
|
||||
"""添加一个调度队列"""
|
||||
|
||||
index = len(self.queue_manager.search_queue()) + 1
|
||||
|
||||
qconfig.load(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_{index}.json",
|
||||
Config.queue_config,
|
||||
)
|
||||
Config.clear_queue_config()
|
||||
Config.queue_config.save()
|
||||
|
||||
self.queue_manager.add_QueueSettingBox(index)
|
||||
self.queue_manager.switch_SettingBox(index)
|
||||
|
||||
def del_setting_box(self):
|
||||
"""删除一个调度队列实例"""
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
if name in Config.running_list:
|
||||
logger.warning("调度队列正在运行")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "调度队列正在运行", "请先停止调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
f"确定要删除 {name} 吗?",
|
||||
self,
|
||||
)
|
||||
if choice.exec():
|
||||
|
||||
queue_list = self.queue_manager.search_queue()
|
||||
move_list = [_ for _ in queue_list if int(_[0][5:]) > int(name[5:])]
|
||||
|
||||
index = max(int(name[5:]) - 1, 1)
|
||||
|
||||
self.queue_manager.clear_SettingBox()
|
||||
|
||||
(Config.app_path / f"config/QueueConfig/{name}.json").unlink()
|
||||
for queue in move_list:
|
||||
if (Config.app_path / f"config/QueueConfig/{queue[0]}.json").exists():
|
||||
(Config.app_path / f"config/QueueConfig/{queue[0]}.json").rename(
|
||||
Config.app_path
|
||||
/ f"config/QueueConfig/调度队列_{int(queue[0][5:])-1}.json",
|
||||
)
|
||||
|
||||
self.queue_manager.show_SettingBox(index)
|
||||
|
||||
def left_setting_box(self):
|
||||
"""向左移动调度队列实例"""
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
index = int(name[5:])
|
||||
|
||||
if index == 1:
|
||||
logger.warning("向左移动调度队列时已到达最左端")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "已经是第一个调度队列", "无法向左移动", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
if name in Config.running_list or f"调度队列_{index-1}" in Config.running_list:
|
||||
logger.warning("相关调度队列正在运行")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "相关调度队列正在运行", "请先停止调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
self.queue_manager.clear_SettingBox()
|
||||
|
||||
(Config.app_path / f"config/QueueConfig/调度队列_{index}.json").rename(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_0.json",
|
||||
)
|
||||
shutil.move(
|
||||
str(Config.app_path / f"config/QueueConfig/调度队列_{index-1}.json"),
|
||||
str(Config.app_path / f"config/QueueConfig/调度队列_{index}.json"),
|
||||
)
|
||||
(Config.app_path / f"config/QueueConfig/调度队列_0.json").rename(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_{index-1}.json",
|
||||
)
|
||||
|
||||
self.queue_manager.show_SettingBox(index - 1)
|
||||
|
||||
def right_setting_box(self):
|
||||
"""向右移动调度队列实例"""
|
||||
|
||||
name = self.queue_manager.pivot.currentRouteKey()
|
||||
|
||||
if name == None:
|
||||
logger.warning("未选择调度队列")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "未选择调度队列", "请先选择一个调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
queue_list = self.queue_manager.search_queue()
|
||||
index = int(name[5:])
|
||||
|
||||
if index == len(queue_list):
|
||||
logger.warning("向右移动调度队列时已到达最右端")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "已经是最后一个调度队列", "无法向右移动", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
if name in Config.running_list or f"调度队列_{index+1}" in Config.running_list:
|
||||
logger.warning("相关调度队列正在运行")
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "相关调度队列正在运行", "请先停止调度队列", 5000
|
||||
)
|
||||
return None
|
||||
|
||||
self.queue_manager.clear_SettingBox()
|
||||
|
||||
(Config.app_path / f"config/QueueConfig/调度队列_{index}.json").rename(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_0.json",
|
||||
)
|
||||
(Config.app_path / f"config/QueueConfig/调度队列_{index+1}.json").rename(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_{index}.json",
|
||||
)
|
||||
(Config.app_path / f"config/QueueConfig/调度队列_0.json").rename(
|
||||
Config.app_path / f"config/QueueConfig/调度队列_{index+1}.json",
|
||||
)
|
||||
|
||||
self.queue_manager.show_SettingBox(index + 1)
|
||||
|
||||
def refresh(self):
|
||||
"""刷新调度队列界面"""
|
||||
|
||||
if len(self.queue_manager.search_queue()) == 0:
|
||||
index = 0
|
||||
else:
|
||||
index = int(self.queue_manager.pivot.currentRouteKey()[5:])
|
||||
self.queue_manager.clear_SettingBox()
|
||||
self.queue_manager.show_SettingBox(index)
|
||||
|
||||
|
||||
class QueueSettingBox(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName("调度队列管理")
|
||||
|
||||
self.pivot = Pivot(self)
|
||||
self.stackedWidget = QStackedWidget(self)
|
||||
self.Layout = QVBoxLayout(self)
|
||||
|
||||
self.script_list: List[QueueMemberSettingBox] = []
|
||||
|
||||
self.Layout.addWidget(self.pivot, 0, Qt.AlignHCenter)
|
||||
self.Layout.addWidget(self.stackedWidget)
|
||||
self.Layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
self.pivot.currentItemChanged.connect(
|
||||
lambda index: self.switch_SettingBox(int(index[5:]), if_change_pivot=False)
|
||||
)
|
||||
|
||||
self.show_SettingBox(1)
|
||||
|
||||
def show_SettingBox(self, index) -> None:
|
||||
"""加载所有子界面"""
|
||||
|
||||
queue_list = self.search_queue()
|
||||
|
||||
qconfig.load(
|
||||
Config.app_path / "config/临时.json",
|
||||
Config.queue_config,
|
||||
)
|
||||
Config.clear_queue_config()
|
||||
for queue in queue_list:
|
||||
self.add_QueueSettingBox(int(queue[0][5:]))
|
||||
if (Config.app_path / "config/临时.json").exists():
|
||||
(Config.app_path / "config/临时.json").unlink()
|
||||
|
||||
self.switch_SettingBox(index)
|
||||
|
||||
def switch_SettingBox(self, index: int, if_change_pivot: bool = True) -> None:
|
||||
"""切换到指定的子界面"""
|
||||
|
||||
queue_list = self.search_queue()
|
||||
|
||||
if len(queue_list) == 0:
|
||||
return None
|
||||
|
||||
if index > len(queue_list):
|
||||
return None
|
||||
|
||||
qconfig.load(
|
||||
Config.app_path
|
||||
/ f"config/QueueConfig/{self.script_list[index-1].objectName()}.json",
|
||||
Config.queue_config,
|
||||
)
|
||||
|
||||
if if_change_pivot:
|
||||
self.pivot.setCurrentItem(self.script_list[index - 1].objectName())
|
||||
self.stackedWidget.setCurrentWidget(self.script_list[index - 1])
|
||||
|
||||
def clear_SettingBox(self) -> None:
|
||||
"""清空所有子界面"""
|
||||
|
||||
for sub_interface in self.script_list:
|
||||
self.stackedWidget.removeWidget(sub_interface)
|
||||
sub_interface.deleteLater()
|
||||
self.script_list.clear()
|
||||
self.pivot.clear()
|
||||
qconfig.load(
|
||||
Config.app_path / "config/临时.json",
|
||||
Config.queue_config,
|
||||
)
|
||||
Config.clear_queue_config()
|
||||
if (Config.app_path / "config/临时.json").exists():
|
||||
(Config.app_path / "config/临时.json").unlink()
|
||||
|
||||
def add_QueueSettingBox(self, uid: int) -> None:
|
||||
"""添加一个调度队列设置界面"""
|
||||
|
||||
maa_setting_box = QueueMemberSettingBox(uid, self)
|
||||
|
||||
self.script_list.append(maa_setting_box)
|
||||
|
||||
self.stackedWidget.addWidget(self.script_list[-1])
|
||||
|
||||
self.pivot.addItem(routeKey=f"调度队列_{uid}", text=f"调度队列 {uid}")
|
||||
|
||||
def search_queue(self) -> list:
|
||||
"""搜索所有调度队列实例"""
|
||||
|
||||
queue_list = []
|
||||
|
||||
if (Config.app_path / "config/QueueConfig").exists():
|
||||
for json_file in (Config.app_path / "config/QueueConfig").glob("*.json"):
|
||||
with json_file.open("r", encoding="utf-8") as f:
|
||||
info = json.load(f)
|
||||
queue_list.append([json_file.stem, info["QueueSet"]["Name"]])
|
||||
|
||||
return queue_list
|
||||
|
||||
|
||||
class QueueMemberSettingBox(QWidget):
|
||||
|
||||
def __init__(self, uid: int, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName(f"调度队列_{uid}")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
scrollArea = ScrollArea()
|
||||
scrollArea.setWidgetResizable(True)
|
||||
|
||||
content_widget = QWidget()
|
||||
content_layout = QVBoxLayout(content_widget)
|
||||
|
||||
self.queue_set = self.QueueSetSettingCard(self)
|
||||
self.time = self.TimeSettingCard(self)
|
||||
self.task = self.TaskSettingCard(self)
|
||||
self.history = self.HistoryCard(self, f"调度队列_{uid}")
|
||||
|
||||
content_layout.addWidget(self.queue_set)
|
||||
content_layout.addWidget(self.time)
|
||||
content_layout.addWidget(self.task)
|
||||
content_layout.addWidget(self.history)
|
||||
content_layout.addStretch(1)
|
||||
|
||||
scrollArea.setWidget(content_widget)
|
||||
|
||||
layout.addWidget(scrollArea)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
class QueueSetSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("队列设置")
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
|
||||
self.card_Name = LineEditSettingCard(
|
||||
"请输入调度队列名称",
|
||||
FluentIcon.EDIT,
|
||||
"调度队列名称",
|
||||
"用于标识调度队列的名称",
|
||||
Config.queue_config.queueSet_Name,
|
||||
)
|
||||
self.card_Enable = SwitchSettingCard(
|
||||
FluentIcon.HOME,
|
||||
"状态",
|
||||
"调度队列状态",
|
||||
Config.queue_config.queueSet_Enabled,
|
||||
)
|
||||
|
||||
Layout.addWidget(self.card_Name)
|
||||
Layout.addWidget(self.card_Enable)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
class TimeSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("定时设置")
|
||||
|
||||
widget_1 = QWidget()
|
||||
Layout_1 = QVBoxLayout(widget_1)
|
||||
widget_2 = QWidget()
|
||||
Layout_2 = QVBoxLayout(widget_2)
|
||||
Layout = QHBoxLayout()
|
||||
|
||||
self.card_Time_0 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 1",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_0,
|
||||
Config.queue_config.time_TimeSet_0,
|
||||
)
|
||||
self.card_Time_1 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 2",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_1,
|
||||
Config.queue_config.time_TimeSet_1,
|
||||
)
|
||||
self.card_Time_2 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 3",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_2,
|
||||
Config.queue_config.time_TimeSet_2,
|
||||
)
|
||||
self.card_Time_3 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 4",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_3,
|
||||
Config.queue_config.time_TimeSet_3,
|
||||
)
|
||||
self.card_Time_4 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 5",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_4,
|
||||
Config.queue_config.time_TimeSet_4,
|
||||
)
|
||||
self.card_Time_5 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 6",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_5,
|
||||
Config.queue_config.time_TimeSet_5,
|
||||
)
|
||||
self.card_Time_6 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 7",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_6,
|
||||
Config.queue_config.time_TimeSet_6,
|
||||
)
|
||||
self.card_Time_7 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 8",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_7,
|
||||
Config.queue_config.time_TimeSet_7,
|
||||
)
|
||||
self.card_Time_8 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 9",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_8,
|
||||
Config.queue_config.time_TimeSet_8,
|
||||
)
|
||||
self.card_Time_9 = TimeEditSettingCard(
|
||||
FluentIcon.STOP_WATCH,
|
||||
"定时 10",
|
||||
"",
|
||||
Config.queue_config.time_TimeEnabled_9,
|
||||
Config.queue_config.time_TimeSet_9,
|
||||
)
|
||||
|
||||
Layout_1.addWidget(self.card_Time_0)
|
||||
Layout_1.addWidget(self.card_Time_1)
|
||||
Layout_1.addWidget(self.card_Time_2)
|
||||
Layout_1.addWidget(self.card_Time_3)
|
||||
Layout_1.addWidget(self.card_Time_4)
|
||||
Layout_2.addWidget(self.card_Time_5)
|
||||
Layout_2.addWidget(self.card_Time_6)
|
||||
Layout_2.addWidget(self.card_Time_7)
|
||||
Layout_2.addWidget(self.card_Time_8)
|
||||
Layout_2.addWidget(self.card_Time_9)
|
||||
Layout.addWidget(widget_1)
|
||||
Layout.addWidget(widget_2)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
class TaskSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("任务队列")
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
|
||||
member_list = self.search_member()
|
||||
|
||||
self.card_Member_1 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_1,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 1",
|
||||
"第一个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_2 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_2,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 2",
|
||||
"第二个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_3 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_3,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 3",
|
||||
"第三个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_4 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_4,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 4",
|
||||
"第四个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_5 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_5,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 5",
|
||||
"第五个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_6 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_6,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 6",
|
||||
"第六个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_7 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_7,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 7",
|
||||
"第七个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_8 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_8,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 8",
|
||||
"第八个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_9 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_9,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 9",
|
||||
"第九个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
self.card_Member_10 = NoOptionComboBoxSettingCard(
|
||||
Config.queue_config.queue_Member_10,
|
||||
FluentIcon.APPLICATION,
|
||||
"任务实例 10",
|
||||
"第十个调起的脚本任务实例",
|
||||
member_list[0],
|
||||
member_list[1],
|
||||
)
|
||||
|
||||
Layout.addWidget(self.card_Member_1)
|
||||
Layout.addWidget(self.card_Member_2)
|
||||
Layout.addWidget(self.card_Member_3)
|
||||
Layout.addWidget(self.card_Member_4)
|
||||
Layout.addWidget(self.card_Member_5)
|
||||
Layout.addWidget(self.card_Member_6)
|
||||
Layout.addWidget(self.card_Member_7)
|
||||
Layout.addWidget(self.card_Member_8)
|
||||
Layout.addWidget(self.card_Member_9)
|
||||
Layout.addWidget(self.card_Member_10)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
def search_member(self) -> list:
|
||||
"""搜索所有脚本实例"""
|
||||
|
||||
member_list_name = ["禁用"]
|
||||
member_list_text = ["未启用"]
|
||||
|
||||
if (Config.app_path / "config/MaaConfig").exists():
|
||||
for subdir in (Config.app_path / "config/MaaConfig").iterdir():
|
||||
if subdir.is_dir():
|
||||
member_list_name.append(subdir.name)
|
||||
with (subdir / "config.json").open("r", encoding="utf-8") as f:
|
||||
info = json.load(f)
|
||||
if info["MaaSet"]["Name"] != "":
|
||||
member_list_text.append(
|
||||
f"{subdir.name} - {info["MaaSet"]["Name"]}"
|
||||
)
|
||||
else:
|
||||
member_list_text.append(subdir.name)
|
||||
|
||||
return [member_list_name, member_list_text]
|
||||
|
||||
class HistoryCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None, name: str = None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("历史运行记录")
|
||||
|
||||
self.text = TextBrowser()
|
||||
self.text.setMinimumHeight(300)
|
||||
history = Config.get_history(name)
|
||||
self.text.setPlainText(history["History"])
|
||||
|
||||
self.viewLayout.addWidget(self.text)
|
||||
755
app/ui/setting.py
Normal file
@@ -0,0 +1,755 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA设置界面
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
QApplication,
|
||||
QVBoxLayout,
|
||||
QVBoxLayout,
|
||||
)
|
||||
from qfluentwidgets import (
|
||||
ScrollArea,
|
||||
FluentIcon,
|
||||
MessageBox,
|
||||
Dialog,
|
||||
HyperlinkCard,
|
||||
HeaderCardWidget,
|
||||
SwitchSettingCard,
|
||||
ExpandGroupSettingCard,
|
||||
PushSettingCard,
|
||||
ComboBoxSettingCard,
|
||||
)
|
||||
from datetime import datetime
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
import requests
|
||||
|
||||
from app.core import Config, MainInfoBar
|
||||
from app.services import Crypto, System
|
||||
from app.utils import Updater
|
||||
from .Widget import InputMessageBox, LineEditSettingCard
|
||||
|
||||
|
||||
class Setting(QWidget):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
parent=None,
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setObjectName("设置")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
|
||||
scrollArea = ScrollArea()
|
||||
scrollArea.setWidgetResizable(True)
|
||||
|
||||
content_widget = QWidget()
|
||||
content_layout = QVBoxLayout(content_widget)
|
||||
|
||||
self.function = FunctionSettingCard(self)
|
||||
self.start = StartSettingCard(self)
|
||||
self.ui = UiSettingCard(self)
|
||||
self.notification = NotifySettingCard(self)
|
||||
self.security = SecuritySettingCard(self)
|
||||
self.updater = UpdaterSettingCard(self)
|
||||
self.other = OtherSettingCard(self)
|
||||
|
||||
self.function.card_IfAllowSleep.checkedChanged.connect(System.set_Sleep)
|
||||
self.start.card_IfSelfStart.checkedChanged.connect(System.set_SelfStart)
|
||||
self.security.card_changePASSWORD.clicked.connect(self.change_PASSWORD)
|
||||
self.updater.card_CheckUpdate.clicked.connect(self.get_update)
|
||||
self.other.card_Notice.clicked.connect(self.show_notice)
|
||||
|
||||
content_layout.addWidget(self.function)
|
||||
content_layout.addWidget(self.start)
|
||||
content_layout.addWidget(self.ui)
|
||||
content_layout.addWidget(self.notification)
|
||||
content_layout.addWidget(self.security)
|
||||
content_layout.addWidget(self.updater)
|
||||
content_layout.addWidget(self.other)
|
||||
|
||||
scrollArea.setWidget(content_widget)
|
||||
|
||||
layout.addWidget(scrollArea)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
def check_PASSWORD(self) -> None:
|
||||
"""检查并配置管理密钥"""
|
||||
|
||||
if Config.key_path.exists():
|
||||
return None
|
||||
|
||||
while True:
|
||||
|
||||
choice = InputMessageBox(
|
||||
self.parent().parent().parent(),
|
||||
"未检测到管理密钥,请设置您的管理密钥",
|
||||
"管理密钥",
|
||||
"密码",
|
||||
)
|
||||
if choice.exec() and choice.input.text() != "":
|
||||
Crypto.get_PASSWORD(choice.input.text())
|
||||
break
|
||||
else:
|
||||
choice = MessageBox(
|
||||
"警告",
|
||||
"您没有设置管理密钥,无法使用本软件,请先设置管理密钥",
|
||||
self.parent().parent().parent(),
|
||||
)
|
||||
choice.cancelButton.hide()
|
||||
choice.buttonLayout.insertStretch(1)
|
||||
if choice.exec():
|
||||
pass
|
||||
|
||||
def change_PASSWORD(self) -> None:
|
||||
"""修改管理密钥"""
|
||||
|
||||
if_change = True
|
||||
|
||||
while if_change:
|
||||
|
||||
choice = InputMessageBox(
|
||||
self,
|
||||
"请输入旧的管理密钥",
|
||||
"旧管理密钥",
|
||||
"密码",
|
||||
)
|
||||
if choice.exec() and choice.input.text() != "":
|
||||
|
||||
# 验证旧管理密钥
|
||||
if Crypto.check_PASSWORD(choice.input.text()):
|
||||
|
||||
PASSWORD_old = choice.input.text()
|
||||
# 获取新的管理密钥
|
||||
while True:
|
||||
|
||||
choice = InputMessageBox(
|
||||
self,
|
||||
"请输入新的管理密钥",
|
||||
"新管理密钥",
|
||||
"密码",
|
||||
)
|
||||
if choice.exec() and choice.input.text() != "":
|
||||
|
||||
# 修改管理密钥
|
||||
Crypto.change_PASSWORD(PASSWORD_old, choice.input.text())
|
||||
MainInfoBar.push_info_bar(
|
||||
"success", "操作成功", "管理密钥修改成功", 3000
|
||||
)
|
||||
if_change = False
|
||||
break
|
||||
|
||||
else:
|
||||
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
"您没有输入新的管理密钥,是否取消修改管理密钥?",
|
||||
self,
|
||||
)
|
||||
if choice.exec():
|
||||
if_change = False
|
||||
break
|
||||
|
||||
else:
|
||||
choice = MessageBox("错误", "管理密钥错误", self)
|
||||
choice.cancelButton.hide()
|
||||
choice.buttonLayout.insertStretch(1)
|
||||
if choice.exec():
|
||||
pass
|
||||
else:
|
||||
choice = MessageBox(
|
||||
"确认",
|
||||
"您没有输入管理密钥,是否取消修改管理密钥?",
|
||||
self,
|
||||
)
|
||||
if choice.exec():
|
||||
break
|
||||
|
||||
def get_update_info(self) -> str:
|
||||
"""检查主程序版本更新,返回更新信息"""
|
||||
|
||||
# 从本地版本信息文件获取当前版本信息
|
||||
with Config.version_path.open(mode="r", encoding="utf-8") as f:
|
||||
version_current = json.load(f)
|
||||
main_version_current = list(
|
||||
map(int, version_current["main_version"].split("."))
|
||||
)
|
||||
|
||||
# 从远程服务器获取最新版本信息
|
||||
for _ in range(3):
|
||||
try:
|
||||
response = requests.get(
|
||||
f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json"
|
||||
)
|
||||
version_remote = response.json()
|
||||
break
|
||||
except Exception as e:
|
||||
err = e
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
return f"获取版本信息时出错:\n{err}"
|
||||
|
||||
main_version_remote = list(map(int, version_remote["main_version"].split(".")))
|
||||
|
||||
# 有版本更新
|
||||
if main_version_remote > main_version_current:
|
||||
|
||||
main_version_info = f" 主程序:{version_text(main_version_current)} --> {version_text(main_version_remote)}\n"
|
||||
|
||||
return f"发现新版本:\n{main_version_info} 更新说明:\n{version_remote['announcement'].replace("\n# ","\n !").replace("\n## ","\n - ").replace("\n- ","\n · ")}\n\n是否开始更新?\n\n 注意:主程序更新时AUTO_MAA将自动关闭"
|
||||
|
||||
else:
|
||||
return "已是最新版本~"
|
||||
|
||||
def get_update(self, if_question: bool = True) -> None:
|
||||
"""检查版本更新,调起文件下载进程"""
|
||||
|
||||
# 从本地版本信息文件获取当前版本信息
|
||||
with Config.version_path.open(mode="r", encoding="utf-8") as f:
|
||||
version_current = json.load(f)
|
||||
main_version_current = list(
|
||||
map(int, version_current["main_version"].split("."))
|
||||
)
|
||||
updater_version_current = list(
|
||||
map(int, version_current["updater_version"].split("."))
|
||||
)
|
||||
# 检查更新器是否存在
|
||||
if not (Config.app_path / "Updater.exe").exists():
|
||||
updater_version_current = [0, 0, 0, 0]
|
||||
|
||||
# 从远程服务器获取最新版本信息
|
||||
for _ in range(3):
|
||||
try:
|
||||
response = requests.get(
|
||||
f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{Config.global_config.get(Config.global_config.update_UpdateType)}/resources/version.json"
|
||||
)
|
||||
version_remote = response.json()
|
||||
break
|
||||
except Exception as e:
|
||||
err = e
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
choice = MessageBox(
|
||||
"错误",
|
||||
f"获取版本信息时出错:\n{err}",
|
||||
self,
|
||||
)
|
||||
choice.cancelButton.hide()
|
||||
choice.buttonLayout.insertStretch(1)
|
||||
if choice.exec():
|
||||
return None
|
||||
|
||||
main_version_remote = list(map(int, version_remote["main_version"].split(".")))
|
||||
updater_version_remote = list(
|
||||
map(int, version_remote["updater_version"].split("."))
|
||||
)
|
||||
|
||||
# 有版本更新
|
||||
if (main_version_remote > main_version_current) or (
|
||||
updater_version_remote > updater_version_current
|
||||
):
|
||||
|
||||
# 生成版本更新信息
|
||||
if main_version_remote > main_version_current:
|
||||
main_version_info = f" 主程序:{version_text(main_version_current)} --> {version_text(main_version_remote)}\n"
|
||||
else:
|
||||
main_version_info = (
|
||||
f" 主程序:{version_text(main_version_current)}\n"
|
||||
)
|
||||
if updater_version_remote > updater_version_current:
|
||||
updater_version_info = f" 更新器:{version_text(updater_version_current)} --> {version_text(updater_version_remote)}\n"
|
||||
else:
|
||||
updater_version_info = (
|
||||
f" 更新器:{version_text(updater_version_current)}\n"
|
||||
)
|
||||
|
||||
# 询问是否开始版本更新
|
||||
if if_question:
|
||||
choice = MessageBox(
|
||||
"版本更新",
|
||||
f"发现新版本:\n{main_version_info}{updater_version_info} 更新说明:\n{version_remote['announcement'].replace("\n# ","\n !").replace("\n## ","\n - ").replace("\n- ","\n · ")}\n\n是否开始更新?\n\n 注意:主程序更新时AUTO_MAA将自动关闭",
|
||||
self,
|
||||
)
|
||||
if not choice.exec():
|
||||
return None
|
||||
|
||||
# 更新更新器
|
||||
if updater_version_remote > updater_version_current:
|
||||
# 创建更新进程
|
||||
self.updater = Updater(
|
||||
Config.app_path,
|
||||
"AUTO_MAA更新器",
|
||||
main_version_remote,
|
||||
updater_version_remote,
|
||||
)
|
||||
# 完成更新器的更新后更新主程序
|
||||
if main_version_remote > main_version_current:
|
||||
self.updater.update_process.accomplish.connect(self.update_main)
|
||||
# 显示更新页面
|
||||
self.updater.ui.show()
|
||||
|
||||
# 更新主程序
|
||||
elif main_version_remote > main_version_current:
|
||||
self.update_main()
|
||||
|
||||
# 无版本更新
|
||||
else:
|
||||
MainInfoBar.push_info_bar("success", "更新检查", "已是最新版本~", 3000)
|
||||
|
||||
def update_main(self) -> None:
|
||||
"""更新主程序"""
|
||||
|
||||
subprocess.Popen(
|
||||
str(Config.app_path / "Updater.exe"),
|
||||
shell=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
self.close()
|
||||
QApplication.quit()
|
||||
|
||||
def show_notice(self, if_show: bool = True):
|
||||
"""显示公告"""
|
||||
|
||||
# 从远程服务器获取最新版本信息
|
||||
for _ in range(3):
|
||||
try:
|
||||
response = requests.get(
|
||||
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/server/notice.json"
|
||||
)
|
||||
notice = response.json()
|
||||
break
|
||||
except Exception as e:
|
||||
err = e
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
logger.warning(f"获取最新公告时出错:\n{err}")
|
||||
if if_show:
|
||||
choice = Dialog(
|
||||
"网络错误",
|
||||
f"获取最新公告时出错:\n{err}",
|
||||
self,
|
||||
)
|
||||
choice.cancelButton.hide()
|
||||
choice.buttonLayout.insertStretch(1)
|
||||
choice.exec()
|
||||
return None
|
||||
|
||||
if (Config.app_path / "resources/notice.json").exists():
|
||||
with (Config.app_path / "resources/notice.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
notice_local = json.load(f)
|
||||
time_local = datetime.strptime(notice_local["time"], "%Y-%m-%d %H:%M")
|
||||
else:
|
||||
time_local = datetime.strptime("2000-01-01 00:00", "%Y-%m-%d %H:%M")
|
||||
|
||||
if if_show or (
|
||||
datetime.now() > datetime.strptime(notice["time"], "%Y-%m-%d %H:%M")
|
||||
and datetime.strptime(notice["time"], "%Y-%m-%d %H:%M") > time_local
|
||||
):
|
||||
|
||||
choice = Dialog("公告", notice["content"], self)
|
||||
choice.cancelButton.hide()
|
||||
choice.buttonLayout.insertStretch(1)
|
||||
if choice.exec():
|
||||
with (Config.app_path / "resources/notice.json").open(
|
||||
mode="w", encoding="utf-8"
|
||||
) as f:
|
||||
json.dump(notice, f, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
class FunctionSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("功能")
|
||||
|
||||
self.card_IfAllowSleep = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="启动时阻止系统休眠",
|
||||
content="仅阻止电脑自动休眠,不会影响屏幕是否熄灭",
|
||||
configItem=Config.global_config.function_IfAllowSleep,
|
||||
)
|
||||
self.card_IfSilence = self.SilenceSettingCard(self)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfAllowSleep)
|
||||
Layout.addWidget(self.card_IfSilence)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
class SilenceSettingCard(ExpandGroupSettingCard):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"静默模式",
|
||||
"将各代理窗口置于后台运行,减少对前台的干扰",
|
||||
parent,
|
||||
)
|
||||
|
||||
self.card_IfSilence = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="静默模式",
|
||||
content="是否启用静默模式",
|
||||
configItem=Config.global_config.function_IfSilence,
|
||||
)
|
||||
self.card_BossKey = LineEditSettingCard(
|
||||
text="请输入安卓模拟器老版键",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="模拟器老版键",
|
||||
content="输入模拟器老版快捷键,以“+”分隔",
|
||||
configItem=Config.global_config.function_BossKey,
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_IfSilence)
|
||||
Layout.addWidget(self.card_BossKey)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
|
||||
class StartSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("启动")
|
||||
|
||||
self.card_IfSelfStart = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="开机时自动启动",
|
||||
content="将AUTO_MAA添加到开机启动项",
|
||||
configItem=Config.global_config.start_IfSelfStart,
|
||||
)
|
||||
self.card_IfRunDirectly = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="启动后直接运行",
|
||||
content="启动AUTO_MAA后自动运行任务(暂不可用)",
|
||||
configItem=Config.global_config.start_IfRunDirectly,
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfSelfStart)
|
||||
Layout.addWidget(self.card_IfRunDirectly)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
|
||||
class UiSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("界面")
|
||||
|
||||
self.card_IfShowTray = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="显示托盘图标",
|
||||
content="常态显示托盘图标",
|
||||
configItem=Config.global_config.ui_IfShowTray,
|
||||
)
|
||||
self.card_IfToTray = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="最小化到托盘",
|
||||
content="最小化时隐藏到托盘",
|
||||
configItem=Config.global_config.ui_IfToTray,
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfShowTray)
|
||||
Layout.addWidget(self.card_IfToTray)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
|
||||
class NotifySettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTitle("通知")
|
||||
|
||||
self.card_IfSendErrorOnly = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="仅推送异常信息",
|
||||
content="仅在任务出现异常时推送通知",
|
||||
configItem=Config.global_config.notify_IfSendErrorOnly,
|
||||
)
|
||||
self.card_IfPushPlyer = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送系统通知",
|
||||
content="推送系统级通知,不会在通知中心停留",
|
||||
configItem=Config.global_config.notify_IfPushPlyer,
|
||||
)
|
||||
self.card_SendMail = self.SendMailSettingCard(self)
|
||||
self.card_ServerChan = self.ServerChanSettingCard(self)
|
||||
self.card_CompanyWebhookBot = self.CompanyWechatPushSettingCard(self)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfSendErrorOnly)
|
||||
Layout.addWidget(self.card_IfPushPlyer)
|
||||
Layout.addWidget(self.card_SendMail)
|
||||
Layout.addWidget(self.card_ServerChan)
|
||||
Layout.addWidget(self.card_CompanyWebhookBot)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
class SendMailSettingCard(ExpandGroupSettingCard):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"推送邮件通知",
|
||||
"通过AUTO_MAA官方通知服务邮箱推送任务结果",
|
||||
parent,
|
||||
)
|
||||
|
||||
self.card_IfSendMail = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送邮件通知",
|
||||
content="是否启用邮件通知功能",
|
||||
configItem=Config.global_config.notify_IfSendMail,
|
||||
)
|
||||
self.card_MailAddress = LineEditSettingCard(
|
||||
text="请输入邮箱地址",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="邮箱地址",
|
||||
content="接收通知的邮箱地址",
|
||||
configItem=Config.global_config.notify_MailAddress,
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_IfSendMail)
|
||||
Layout.addWidget(self.card_MailAddress)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
class ServerChanSettingCard(ExpandGroupSettingCard):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"推送ServerChan通知",
|
||||
"通过ServerChan通知推送任务结果",
|
||||
parent,
|
||||
)
|
||||
|
||||
self.card_IfServerChan = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送SeverChan通知",
|
||||
content="是否启用SeverChan通知功能",
|
||||
configItem=Config.global_config.notify_IfServerChan,
|
||||
)
|
||||
self.card_ServerChanKey = LineEditSettingCard(
|
||||
text="请输入SendKey",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="SendKey",
|
||||
content="Server酱的SendKey(SC3与SCT都可以)",
|
||||
configItem=Config.global_config.notify_ServerChanKey,
|
||||
)
|
||||
self.card_ServerChanChannel = LineEditSettingCard(
|
||||
text="请输入需要推送的Channel代码(SCT生效)",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="ServerChanChannel代码",
|
||||
content="可以留空,留空则默认。可以多个,请使用“|”隔开",
|
||||
configItem=Config.global_config.notify_ServerChanChannel,
|
||||
)
|
||||
self.card_ServerChanTag = LineEditSettingCard(
|
||||
text="请输入加入推送的Tag(SC3生效)",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="Tag内容",
|
||||
content="可以留空,留空则默认。可以多个,请使用“|”隔开",
|
||||
configItem=Config.global_config.notify_ServerChanTag,
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_IfServerChan)
|
||||
Layout.addWidget(self.card_ServerChanKey)
|
||||
Layout.addWidget(self.card_ServerChanChannel)
|
||||
Layout.addWidget(self.card_ServerChanTag)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
class CompanyWechatPushSettingCard(ExpandGroupSettingCard):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"推送企业微信机器人通知",
|
||||
"通过企业微信机器人Webhook通知推送任务结果",
|
||||
parent,
|
||||
)
|
||||
|
||||
self.card_IfCompanyWechat = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="推送企业微信机器人通知",
|
||||
content="是否启用企业微信机器人通知功能",
|
||||
configItem=Config.global_config.notify_IfCompanyWebHookBot,
|
||||
)
|
||||
self.card_CompanyWebHookBotUrl = LineEditSettingCard(
|
||||
text="请输入Webhook的Url",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="WebhookUrl",
|
||||
content="企业微信群机器人的Webhook地址",
|
||||
configItem=Config.global_config.notify_CompanyWebHookBotUrl,
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_IfCompanyWechat)
|
||||
Layout.addWidget(self.card_CompanyWebHookBotUrl)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
|
||||
class SecuritySettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("安全")
|
||||
|
||||
self.card_changePASSWORD = PushSettingCard(
|
||||
text="修改",
|
||||
icon=FluentIcon.VPN,
|
||||
title="修改管理密钥",
|
||||
content="修改用于解密用户密码的管理密钥",
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_changePASSWORD)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
|
||||
class UpdaterSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("更新")
|
||||
|
||||
self.card_IfAutoUpdate = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="自动检查更新",
|
||||
content="将在启动时自动检查AUTO_MAA是否有新版本",
|
||||
configItem=Config.global_config.update_IfAutoUpdate,
|
||||
)
|
||||
self.card_UpdateType = ComboBoxSettingCard(
|
||||
configItem=Config.global_config.update_UpdateType,
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="版本更新类别",
|
||||
content="选择AUTO_MAA的更新类别",
|
||||
texts=["稳定版", "公测版"],
|
||||
)
|
||||
self.card_CheckUpdate = PushSettingCard(
|
||||
text="检查更新",
|
||||
icon=FluentIcon.UPDATE,
|
||||
title="获取最新版本",
|
||||
content="检查AUTO_MAA是否有新版本",
|
||||
)
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfAutoUpdate)
|
||||
Layout.addWidget(self.card_UpdateType)
|
||||
Layout.addWidget(self.card_CheckUpdate)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
|
||||
class OtherSettingCard(HeaderCardWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setTitle("其他")
|
||||
|
||||
self.card_Notice = PushSettingCard(
|
||||
text="查看",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="公告",
|
||||
content="查看AUTO_MAA的最新公告",
|
||||
)
|
||||
self.card_UserDocs = HyperlinkCard(
|
||||
url="https://docs.qq.com/aio/DQ2NwUHRiWGtMWHBy",
|
||||
text="查看使用指南",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="使用指南",
|
||||
content="查看AUTO_MAA的使用教程和文档",
|
||||
)
|
||||
self.card_Association = self.AssociationSettingCard()
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_Notice)
|
||||
Layout.addWidget(self.card_UserDocs)
|
||||
Layout.addWidget(self.card_Association)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
class AssociationSettingCard(ExpandGroupSettingCard):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"AUTO_MAA官方社群",
|
||||
"加入AUTO_MAA官方社群,获取更多帮助",
|
||||
parent,
|
||||
)
|
||||
|
||||
self.card_GitHubRepository = HyperlinkCard(
|
||||
url="https://github.com/DLmaster361/AUTO_MAA",
|
||||
text="访问GitHub仓库",
|
||||
icon=FluentIcon.GITHUB,
|
||||
title="GitHub",
|
||||
content="查看AUTO_MAA的源代码,提交问题和建议,欢迎参与开发",
|
||||
)
|
||||
self.card_QQGroup = HyperlinkCard(
|
||||
url="https://qm.qq.com/q/bd9fISNoME",
|
||||
text="加入官方QQ交流群",
|
||||
icon=FluentIcon.CHAT,
|
||||
title="QQ群",
|
||||
content="与AUTO_MAA开发者和用户交流",
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_GitHubRepository)
|
||||
Layout.addWidget(self.card_QQGroup)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
|
||||
def version_text(version_numb: list) -> str:
|
||||
"""将版本号列表转为可读的文本信息"""
|
||||
|
||||
if version_numb[3] == 0:
|
||||
version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}"
|
||||
else:
|
||||
version = (
|
||||
f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}"
|
||||
)
|
||||
return version
|
||||
372
app/utils/Updater.py
Normal file
@@ -0,0 +1,372 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA更新器
|
||||
v1.1
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
import sys
|
||||
import json
|
||||
import zipfile
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QDialog,
|
||||
QVBoxLayout,
|
||||
)
|
||||
from qfluentwidgets import ProgressBar, IndeterminateProgressBar, BodyLabel
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtCore import QObject, QThread, Signal
|
||||
|
||||
|
||||
def version_text(version_numb: list) -> str:
|
||||
"""将版本号列表转为可读的文本信息"""
|
||||
|
||||
if version_numb[3] == 0:
|
||||
version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}"
|
||||
else:
|
||||
version = (
|
||||
f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}"
|
||||
)
|
||||
return version
|
||||
|
||||
|
||||
class UpdateProcess(QThread):
|
||||
|
||||
info = Signal(str)
|
||||
progress = Signal(int, int, int)
|
||||
accomplish = Signal()
|
||||
|
||||
def __init__(
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super(UpdateProcess, self).__init__()
|
||||
|
||||
self.app_path = app_path
|
||||
self.name = name
|
||||
self.main_version = main_version
|
||||
self.updater_version = updater_version
|
||||
self.download_path = app_path / "AUTO_MAA_Update.zip" # 临时下载文件的路径
|
||||
self.version_path = app_path / "resources/version.json"
|
||||
|
||||
def run(self) -> None:
|
||||
|
||||
# 清理可能存在的临时文件
|
||||
if self.download_path.exists():
|
||||
self.download_path.unlink()
|
||||
|
||||
self.info.emit("正在获取下载链接")
|
||||
url_list = self.get_download_url()
|
||||
|
||||
# 验证下载地址并获取文件大小
|
||||
for i in range(len(url_list)):
|
||||
try:
|
||||
self.info.emit(f"正在验证下载地址:{url_list[i]}")
|
||||
response = requests.get(url_list[i], stream=True)
|
||||
if response.status_code != 200:
|
||||
self.info.emit(
|
||||
f"连接失败,错误代码 {response.status_code} ,正在切换代理({i+1}/{len(url_list)})"
|
||||
)
|
||||
time.sleep(1)
|
||||
continue
|
||||
file_size = response.headers.get("Content-Length")
|
||||
break
|
||||
except requests.RequestException:
|
||||
self.info.emit(f"请求超时,正在切换代理({i+1}/{len(url_list)})")
|
||||
time.sleep(1)
|
||||
else:
|
||||
self.info.emit(f"连接失败,已尝试所有{len(url_list)}个代理")
|
||||
return None
|
||||
|
||||
if file_size is None:
|
||||
file_size = 1
|
||||
else:
|
||||
file_size = int(file_size)
|
||||
|
||||
try:
|
||||
# 下载文件
|
||||
with open(self.download_path, "wb") as f:
|
||||
|
||||
downloaded_size = 0
|
||||
last_download_size = 0
|
||||
speed = 0
|
||||
last_time = time.time()
|
||||
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
|
||||
# 写入已下载数据
|
||||
f.write(chunk)
|
||||
downloaded_size += len(chunk)
|
||||
|
||||
# 计算下载速度
|
||||
if time.time() - last_time >= 1.0:
|
||||
speed = (
|
||||
(downloaded_size - last_download_size)
|
||||
/ (time.time() - last_time)
|
||||
/ 1024
|
||||
)
|
||||
last_download_size = downloaded_size
|
||||
last_time = time.time()
|
||||
|
||||
# 更新下载进度
|
||||
if speed >= 1024:
|
||||
self.info.emit(
|
||||
f"正在下载:{self.name} 已下载:{downloaded_size / 1048576:.2f}/{file_size / 1048576:.2f} MB ({downloaded_size / file_size * 100:.2f}%) 下载速度:{speed / 1024:.2f} MB/s",
|
||||
)
|
||||
else:
|
||||
self.info.emit(
|
||||
f"正在下载:{self.name} 已下载:{downloaded_size / 1048576:.2f}/{file_size / 1048576:.2f} MB ({downloaded_size / file_size * 100:.2f}%) 下载速度:{speed:.2f} KB/s",
|
||||
)
|
||||
self.progress.emit(0, 100, int(downloaded_size / file_size * 100))
|
||||
|
||||
except Exception as e:
|
||||
e = str(e)
|
||||
e = "\n".join([e[_ : _ + 75] for _ in range(0, len(e), 75)])
|
||||
self.info.emit(f"下载{self.name}时出错:\n{e}")
|
||||
return None
|
||||
|
||||
# 解压
|
||||
try:
|
||||
|
||||
while True:
|
||||
try:
|
||||
self.info.emit("正在解压更新文件")
|
||||
self.progress.emit(0, 0, 0)
|
||||
with zipfile.ZipFile(self.download_path, "r") as zip_ref:
|
||||
zip_ref.extractall(self.app_path)
|
||||
break
|
||||
except PermissionError:
|
||||
self.info.emit("解压出错:AUTO_MAA正在运行,正在等待其关闭")
|
||||
time.sleep(1)
|
||||
|
||||
self.info.emit("正在删除临时文件")
|
||||
self.progress.emit(0, 0, 0)
|
||||
self.download_path.unlink()
|
||||
|
||||
self.info.emit(f"{self.name}更新成功!")
|
||||
self.progress.emit(0, 100, 100)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
e = str(e)
|
||||
e = "\n".join([e[_ : _ + 75] for _ in range(0, len(e), 75)])
|
||||
self.info.emit(f"解压更新时出错:\n{e}")
|
||||
return None
|
||||
|
||||
# 更新version文件
|
||||
with open(self.version_path, "r", encoding="utf-8") as f:
|
||||
version_info = json.load(f)
|
||||
if self.name == "AUTO_MAA更新器":
|
||||
version_info["updater_version"] = ".".join(map(str, self.updater_version))
|
||||
elif self.name == "AUTO_MAA主程序":
|
||||
version_info["main_version"] = ".".join(map(str, self.main_version))
|
||||
with open(self.version_path, "w", encoding="utf-8") as f:
|
||||
json.dump(version_info, f, ensure_ascii=False, indent=4)
|
||||
|
||||
# 主程序更新完成后打开AUTO_MAA
|
||||
if self.name == "AUTO_MAA主程序":
|
||||
subprocess.Popen(
|
||||
str(self.app_path / "AUTO_MAA.exe"),
|
||||
shell=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
|
||||
self.accomplish.emit()
|
||||
|
||||
def get_download_url(self) -> list:
|
||||
"""获取下载链接"""
|
||||
|
||||
try_num = 3
|
||||
for i in range(try_num):
|
||||
try:
|
||||
response = requests.get(
|
||||
"https://gitee.com/DLmaster_361/AUTO_MAA/raw/main/resources/version.json"
|
||||
)
|
||||
if response.status_code != 200:
|
||||
self.info.emit(
|
||||
f"连接失败,错误代码 {response.status_code} ,正在重试({i+1}/{try_num})"
|
||||
)
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
version_remote = response.json()
|
||||
PROXY_list = version_remote["proxy_list"]
|
||||
break
|
||||
except requests.RequestException:
|
||||
self.info.emit(f"请求超时,正在重试({i+1}/{try_num})")
|
||||
time.sleep(0.1)
|
||||
except KeyError:
|
||||
self.info.emit(f"未找到远端代理网址项,正在重试({i+1}/{try_num})")
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
self.info.emit("获取远端代理信息失败,将使用默认代理地址")
|
||||
PROXY_list = [
|
||||
"",
|
||||
"https://gitproxy.click/",
|
||||
"https://cdn.moran233.xyz/",
|
||||
"https://gh.llkk.cc/",
|
||||
"https://github.akams.cn/",
|
||||
"https://www.ghproxy.cn/",
|
||||
"https://ghfast.top/",
|
||||
]
|
||||
time.sleep(1)
|
||||
|
||||
url_list = []
|
||||
if self.name == "AUTO_MAA主程序":
|
||||
url_list.append(
|
||||
f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
|
||||
)
|
||||
for i in range(len(PROXY_list)):
|
||||
url_list.append(
|
||||
f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/AUTO_MAA_{version_text(self.main_version)}.zip"
|
||||
)
|
||||
elif self.name == "AUTO_MAA更新器":
|
||||
url_list.append(
|
||||
f"https://gitee.com/DLmaster_361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
|
||||
)
|
||||
for i in range(len(PROXY_list)):
|
||||
url_list.append(
|
||||
f"{PROXY_list[i]}https://github.com/DLmaster361/AUTO_MAA/releases/download/{version_text(self.main_version)}/Updater_{version_text(self.updater_version)}.zip"
|
||||
)
|
||||
return url_list
|
||||
|
||||
|
||||
class Updater(QObject):
|
||||
|
||||
def __init__(
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.ui = QDialog()
|
||||
self.ui.setWindowTitle("AUTO_MAA更新器")
|
||||
self.ui.resize(700, 70)
|
||||
self.ui.setWindowIcon(
|
||||
QIcon(str(app_path / "resources/icons/AUTO_MAA_Updater.ico"))
|
||||
)
|
||||
|
||||
# 创建垂直布局
|
||||
self.Layout = QVBoxLayout(self.ui)
|
||||
|
||||
self.info = BodyLabel("正在初始化", self.ui)
|
||||
self.progress_1 = IndeterminateProgressBar(self.ui)
|
||||
self.progress_2 = ProgressBar(self.ui)
|
||||
|
||||
self.update_progress(0, 0, 0)
|
||||
|
||||
self.Layout.addWidget(self.info)
|
||||
self.Layout.addStretch(1)
|
||||
self.Layout.addWidget(self.progress_1)
|
||||
self.Layout.addWidget(self.progress_2)
|
||||
self.Layout.addStretch(1)
|
||||
|
||||
self.update_process = UpdateProcess(
|
||||
app_path, name, main_version, updater_version
|
||||
)
|
||||
|
||||
self.update_process.info.connect(self.update_info)
|
||||
self.update_process.progress.connect(self.update_progress)
|
||||
|
||||
self.update_process.start()
|
||||
|
||||
def update_info(self, text: str) -> None:
|
||||
self.info.setText(text)
|
||||
|
||||
def update_progress(self, begin: int, end: int, current: int) -> None:
|
||||
if begin == 0 and end == 0:
|
||||
self.progress_2.setVisible(False)
|
||||
self.progress_1.setVisible(True)
|
||||
else:
|
||||
self.progress_1.setVisible(False)
|
||||
self.progress_2.setVisible(True)
|
||||
self.progress_2.setRange(begin, end)
|
||||
self.progress_2.setValue(current)
|
||||
|
||||
|
||||
class AUTO_MAA_Updater(QApplication):
|
||||
def __init__(
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.main = Updater(app_path, name, main_version, updater_version)
|
||||
self.main.ui.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# 获取软件自身的路径
|
||||
app_path = Path(sys.argv[0]).resolve().parent
|
||||
|
||||
# 从本地版本信息文件获取当前版本信息
|
||||
if (app_path / "resources/version.json").exists():
|
||||
with (app_path / "resources/version.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
version_current = json.load(f)
|
||||
main_version_current = list(
|
||||
map(int, version_current["main_version"].split("."))
|
||||
)
|
||||
else:
|
||||
main_version_current = [0, 0, 0, 0]
|
||||
|
||||
# 从本地配置文件获取更新类型
|
||||
if (app_path / "config/config.json").exists():
|
||||
with (app_path / "config/config.json").open(mode="r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
if "Update" in config and "UpdateType" in config["Update"]:
|
||||
update_type = config["Update"]["UpdateType"]
|
||||
else:
|
||||
update_type = "main"
|
||||
else:
|
||||
update_type = "main"
|
||||
|
||||
# 从远程服务器获取最新版本信息
|
||||
for _ in range(3):
|
||||
try:
|
||||
response = requests.get(
|
||||
f"https://gitee.com/DLmaster_361/AUTO_MAA/raw/{update_type}/resources/version.json"
|
||||
)
|
||||
version_remote = response.json()
|
||||
main_version_remote = list(
|
||||
map(int, version_remote["main_version"].split("."))
|
||||
)
|
||||
break
|
||||
except Exception as e:
|
||||
err = e
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
sys.exit(f"获取版本信息时出错:\n{err}")
|
||||
|
||||
# 启动更新线程
|
||||
if main_version_remote > main_version_current:
|
||||
app = AUTO_MAA_Updater(
|
||||
app_path,
|
||||
"AUTO_MAA主程序",
|
||||
main_version_remote,
|
||||
[],
|
||||
)
|
||||
sys.exit(app.exec())
|
||||
34
app/utils/__init__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA工具包
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
__version__ = "4.2.0"
|
||||
__author__ = "DLmaster361 <DLmaster_361@163.com>"
|
||||
__license__ = "GPL-3.0 license"
|
||||
|
||||
from .Updater import Updater
|
||||
|
||||
__all__ = ["Updater"]
|
||||
109
app/utils/package.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA打包程序
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def version_text(version_numb: list) -> str:
|
||||
"""将版本号列表转为可读的文本信息"""
|
||||
|
||||
if version_numb[3] == 0:
|
||||
version = f"v{'.'.join(str(_) for _ in version_numb[0:3])}"
|
||||
else:
|
||||
version = (
|
||||
f"v{'.'.join(str(_) for _ in version_numb[0:3])}-beta.{version_numb[3]}"
|
||||
)
|
||||
return version
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
root_path = Path(sys.argv[0]).resolve().parent
|
||||
|
||||
with (root_path / "resources/version.json").open(mode="r", encoding="utf-8") as f:
|
||||
version = json.load(f)
|
||||
|
||||
main_version_numb = list(map(int, version["main_version"].split(".")))
|
||||
updater_version_numb = list(map(int, version["updater_version"].split(".")))
|
||||
|
||||
print("Packaging AUTO_MAA main program ...")
|
||||
|
||||
os.system(
|
||||
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
|
||||
" --enable-plugins=pyside6 --windows-console-mode=disable"
|
||||
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA'"
|
||||
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
|
||||
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
||||
f" --file-version={version["main_version"]}"
|
||||
f" --product-version={version["main_version"]}"
|
||||
" --file-description='AUTO_MAA Component'"
|
||||
" --copyright='Copyright © 2024 DLmaster361'"
|
||||
" --assume-yes-for-downloads --output-filename=AUTO_MAA"
|
||||
" --remove-output main.py"
|
||||
)
|
||||
|
||||
print("AUTO_MAA main program packaging completed !")
|
||||
|
||||
shutil.copy(root_path / "app/utils/Updater.py", root_path)
|
||||
|
||||
file_content = (root_path / "Updater.py").read_text(encoding="utf-8")
|
||||
|
||||
(root_path / "Updater.py").write_text(
|
||||
file_content.replace(
|
||||
"from .version import version_text", "from app import version_text"
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
print("Packaging AUTO_MAA update program ...")
|
||||
|
||||
os.system(
|
||||
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
|
||||
" --enable-plugins=pyside6 --windows-console-mode=disable"
|
||||
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA_Updater'"
|
||||
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA_Updater.ico"
|
||||
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
||||
f" --file-version={version["updater_version"]}"
|
||||
f" --product-version={version["main_version"]}"
|
||||
" --file-description='AUTO_MAA Component'"
|
||||
" --copyright='Copyright © 2024 DLmaster361'"
|
||||
" --assume-yes-for-downloads --output-filename=Updater"
|
||||
" --remove-output Updater.py"
|
||||
)
|
||||
|
||||
print("AUTO_MAA update program packaging completed !")
|
||||
|
||||
(root_path / "Updater.py").unlink()
|
||||
|
||||
(root_path / "version_info.txt").write_text(
|
||||
f"{version_text(main_version_numb)}\n{version_text(updater_version_numb)}{version["announcement"]}",
|
||||
encoding="utf-8",
|
||||
)
|
||||
@@ -1,5 +0,0 @@
|
||||
龙门币:CE-6
|
||||
技能:CA-5
|
||||
红票:AP-5
|
||||
经验:LS-6
|
||||
剿灭模式:Annihilation
|
||||
@@ -1,3 +0,0 @@
|
||||
管理密钥是解密用户密码的唯一凭证,与数据库绑定。密钥丢失或data/key/目录下任一文件损坏都将导致解密无法正常进行。
|
||||
|
||||
本项目采用自主开发的混合加密模式,项目组也无法找回您的管理密钥或修复data/key/目录下的文件。如果不幸的事发生,建议您删除data/data.db重新录入信息。
|
||||
54
main.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
"""
|
||||
AUTO_MAA
|
||||
AUTO_MAA主程序
|
||||
v4.2
|
||||
作者:DLmaster_361
|
||||
"""
|
||||
|
||||
from loguru import logger
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtCore import Qt
|
||||
from qfluentwidgets import FluentTranslator
|
||||
import sys
|
||||
|
||||
|
||||
@logger.catch
|
||||
def main():
|
||||
|
||||
application = QApplication(sys.argv)
|
||||
QApplication.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
|
||||
|
||||
translator = FluentTranslator()
|
||||
application.installTranslator(translator)
|
||||
|
||||
from app.ui.main_window import AUTO_MAA
|
||||
|
||||
window = AUTO_MAA()
|
||||
window.show_ui("显示主窗口")
|
||||
window.start_up_task()
|
||||
sys.exit(application.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
main()
|
||||
BIN
manage.exe
470
manage.py
@@ -1,470 +0,0 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
import sqlite3
|
||||
import datetime
|
||||
import msvcrt
|
||||
import sys
|
||||
import os
|
||||
import hashlib
|
||||
import random
|
||||
import secrets
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import PKCS1_OAEP
|
||||
from Crypto.Util.Padding import pad,unpad
|
||||
|
||||
#读入密码
|
||||
def readpass(text):
|
||||
sys.stdout=sys.__stdout__
|
||||
sys.stdout.write(text)
|
||||
sys.stdout.flush()
|
||||
p=''
|
||||
while True:
|
||||
typed=msvcrt.getch()
|
||||
if len(p)!=0:
|
||||
if typed==b'\r':
|
||||
sys.stdout.write('\b*')
|
||||
sys.stdout.flush()
|
||||
break
|
||||
elif typed==b'\b':
|
||||
p=p[:-1]
|
||||
sys.stdout.write('\b \b')
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
p+=typed.decode("utf-8")
|
||||
sys.stdout.write('\b*'+typed.decode("utf-8"))
|
||||
sys.stdout.flush()
|
||||
elif typed!=b'\r' and typed!=b'\b':
|
||||
p+=typed.decode("utf-8")
|
||||
sys.stdout.write(typed.decode("utf-8"))
|
||||
sys.stdout.flush()
|
||||
print('')
|
||||
return p
|
||||
|
||||
#配置密钥
|
||||
def getPASSWORD(PASSWORD):
|
||||
#生成RSA密钥对
|
||||
key=RSA.generate(2048)
|
||||
public_key_local=key.publickey()
|
||||
private_key=key
|
||||
#保存RSA公钥
|
||||
with open('data/key/public_key.pem','wb') as f:
|
||||
f.write(public_key_local.exportKey())
|
||||
#生成密钥转换与校验随机盐
|
||||
PASSWORDsalt=secrets.token_hex(random.randint(32,1024))
|
||||
with open("data/key/PASSWORDsalt.txt","w",encoding="utf-8") as f:
|
||||
print(PASSWORDsalt,file=f)
|
||||
verifysalt=secrets.token_hex(random.randint(32,1024))
|
||||
with open("data/key/verifysalt.txt","w",encoding="utf-8") as f:
|
||||
print(verifysalt,file=f)
|
||||
#将管理密钥转化为AES-256密钥
|
||||
AES_password=hashlib.sha256((PASSWORD+PASSWORDsalt).encode("utf-8")).digest()
|
||||
#生成AES-256密钥校验哈希值并保存
|
||||
AES_password_verify=hashlib.sha256(AES_password+verifysalt.encode("utf-8")).digest()
|
||||
with open("data/key/AES_password_verify.bin","wb") as f:
|
||||
f.write(AES_password_verify)
|
||||
#AES-256加密RSA私钥并保存密文
|
||||
AES_key=AES.new(AES_password,AES.MODE_ECB)
|
||||
private_key_local=AES_key.encrypt(pad(private_key.exportKey(),32))
|
||||
with open("data/key/private_key.bin","wb") as f:
|
||||
f.write(private_key_local)
|
||||
|
||||
#加密
|
||||
def encryptx(note):
|
||||
#读取RSA公钥
|
||||
with open('data/key/public_key.pem','rb') as f:
|
||||
public_key_local=RSA.import_key(f.read())
|
||||
#使用RSA公钥对数据进行加密
|
||||
cipher=PKCS1_OAEP.new(public_key_local)
|
||||
encrypted=cipher.encrypt(note.encode("utf-8"))
|
||||
return encrypted
|
||||
|
||||
#解密
|
||||
def decryptx(note,PASSWORD):
|
||||
#读入RSA私钥密文、盐与校验哈希值
|
||||
with open("data/key/private_key.bin","rb") as f:
|
||||
private_key_local=f.read().strip()
|
||||
with open("data/key/PASSWORDsalt.txt","r",encoding="utf-8") as f:
|
||||
PASSWORDsalt=f.read().strip()
|
||||
with open("data/key/verifysalt.txt","r",encoding="utf-8") as f:
|
||||
verifysalt=f.read().strip()
|
||||
with open("data/key/AES_password_verify.bin","rb") as f:
|
||||
AES_password_verify=f.read().strip()
|
||||
#将管理密钥转化为AES-256密钥并验证
|
||||
AES_password=hashlib.sha256((PASSWORD+PASSWORDsalt).encode("utf-8")).digest()
|
||||
AES_password_SHA=hashlib.sha256(AES_password+verifysalt.encode("utf-8")).digest()
|
||||
if AES_password_SHA!=AES_password_verify:
|
||||
return "管理密钥错误"
|
||||
else:
|
||||
#AES解密RSA私钥
|
||||
AES_key=AES.new(AES_password,AES.MODE_ECB)
|
||||
private_key_pem=unpad(AES_key.decrypt(private_key_local),32)
|
||||
private_key=RSA.import_key(private_key_pem)
|
||||
#使用RSA私钥解密数据
|
||||
decrypter=PKCS1_OAEP.new(private_key)
|
||||
note=decrypter.decrypt(note)
|
||||
return note.decode("utf-8")
|
||||
|
||||
#修改管理密钥
|
||||
def changePASSWORD():
|
||||
#获取用户信息
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data=cur.fetchall()
|
||||
cur.close()
|
||||
db.close()
|
||||
data=[list(row) for row in data]
|
||||
global PASSWORD
|
||||
#验证管理密钥
|
||||
PASSWORDold=readpass("请输入旧管理密钥:")
|
||||
if len(data)==0:
|
||||
print("当前无用户,验证自动通过")
|
||||
PASSWORDnew=readpass("请输入新管理密钥:")
|
||||
getPASSWORD(PASSWORDnew)
|
||||
PASSWORD=PASSWORDnew
|
||||
return "管理密钥修改成功"
|
||||
while decryptx(data[0][6],PASSWORDold)=="管理密钥错误":
|
||||
print("管理密钥错误")
|
||||
PASSWORDold=readpass("请输入旧管理密钥:")
|
||||
print("验证通过")
|
||||
#修改管理密钥
|
||||
PASSWORDnew=readpass("请输入新管理密钥:")
|
||||
#使用旧管理密钥解密
|
||||
for i in range(len(data)):
|
||||
data[i][6]=decryptx(data[i][6],PASSWORDold)
|
||||
#使用新管理密钥重新加密
|
||||
getPASSWORD(PASSWORDnew)
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
for i in range(len(data)):
|
||||
cur.execute("UPDATE adminx SET password=? WHERE admin=?",(encryptx(data[i][6]),data[i][0]))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
PASSWORD=PASSWORDnew
|
||||
return "管理密钥修改成功"
|
||||
|
||||
#添加用户
|
||||
def add():
|
||||
adminx=input("用户名:")
|
||||
#用户名重复验证
|
||||
while search(adminx,0)=="":
|
||||
print("该用户已存在,请重新输入")
|
||||
adminx=input("用户名:")
|
||||
numberx=input("手机号码:")
|
||||
dayx=int(input("代理天数:"))
|
||||
gamex=input("关卡号:")
|
||||
passwordx=readpass("密码:")
|
||||
passwordx=encryptx(passwordx)
|
||||
#应用更新
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("INSERT INTO adminx VALUES(?,?,?,'y','2000-01-01',?,?)",(adminx,numberx,dayx,gamex,passwordx))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return "操作成功"
|
||||
|
||||
#删除用户信息
|
||||
def delete(id):
|
||||
#检查用户是否存在
|
||||
if search(id,0)!="":
|
||||
return "未找到"+id
|
||||
#应用更新
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("DELETE FROM adminx WHERE admin=?",(id,))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return "成功删除"+id
|
||||
|
||||
#检索用户信息与配置
|
||||
def search(id,book):
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
#处理启动时间查询
|
||||
if id=="time":
|
||||
cur.execute("SELECT * FROM timeset WHERE True")
|
||||
timex=cur.fetchall()
|
||||
timex=[list(row) for row in timex]
|
||||
cur.close()
|
||||
db.close()
|
||||
if len(timex)==0:
|
||||
return "启动时间未设置"
|
||||
else:
|
||||
for i in range(len(timex)):
|
||||
print(timex[i][0])
|
||||
return ""
|
||||
#处理MAA路径查询
|
||||
if id=="maa":
|
||||
cur.execute("SELECT * FROM pathset WHERE True")
|
||||
pathx=cur.fetchall()
|
||||
if len(pathx)>0:
|
||||
cur.close()
|
||||
db.close()
|
||||
return pathx[0][0]
|
||||
else:
|
||||
cur.close()
|
||||
db.close()
|
||||
return "MAA路径未设置"
|
||||
#处理用户查询与全部信息查询
|
||||
if id=="all":
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
else:
|
||||
cur.execute("SELECT * FROM adminx WHERE admin=?",(id,))
|
||||
data=cur.fetchall()
|
||||
#处理全部信息查询时的MAA路径与启动时间查询
|
||||
if id=="all":
|
||||
cur.execute("SELECT * FROM pathset WHERE True")
|
||||
pathx=cur.fetchall()
|
||||
if len(pathx)>0:
|
||||
print("\nMAA路径:"+pathx[0][0])
|
||||
else:
|
||||
print("\nMAA路径未设置")
|
||||
cur.execute("SELECT * FROM timeset WHERE True")
|
||||
timex=cur.fetchall()
|
||||
timex=[list(row) for row in timex]
|
||||
if len(timex)==0:
|
||||
print("\n启动时间未设置")
|
||||
else:
|
||||
print("启动时间:",end='')
|
||||
for i in range(len(timex)):
|
||||
print(timex[i][0],end=' ')
|
||||
print('')
|
||||
cur.close()
|
||||
db.close()
|
||||
data=[list(row) for row in data]
|
||||
if len(data)>0:
|
||||
#转译执行情况、用户状态,对全部信息查询与无输出查询隐去密码
|
||||
curdate=datetime.date.today()
|
||||
curdate=curdate.strftime('%Y-%m-%d')
|
||||
for i in range(len(data)):
|
||||
if data[i][4]==curdate:
|
||||
data[i][4]="今日已执行"
|
||||
else:
|
||||
data[i][4]="今日未执行"
|
||||
if data[i][3]=='y':
|
||||
data[i][3]="启用"
|
||||
else:
|
||||
data[i][3]="禁用"
|
||||
if id=="all" or book==0:
|
||||
data[i][6]="******"
|
||||
else:
|
||||
#解密
|
||||
global PASSWORD
|
||||
if PASSWORD==0 or decryptx(data[i][6],PASSWORD)=="管理密钥错误":
|
||||
PASSWORD=readpass("请输入管理密钥:")
|
||||
data[i][6]=decryptx(data[i][6],PASSWORD)
|
||||
#制表输出
|
||||
if book==1:
|
||||
print('')
|
||||
print(unit("用户名",15),unit("手机号码",12),unit("代理天数",8),unit("状态",4),unit("执行情况",10),unit("关卡",10),unit("密码",25))
|
||||
for i in range(len(data)):
|
||||
print(unit(data[i][0],15),unit(data[i][1],12),unit(data[i][2],8),unit(data[i][3],4),unit(data[i][4],10),unit(data[i][5],10),unit(data[i][6],25))
|
||||
return ""
|
||||
elif id=="all":
|
||||
return "\n当前没有用户记录"
|
||||
else:
|
||||
return "未找到"+id
|
||||
|
||||
#续期
|
||||
def renewal(readxx):
|
||||
#提取用户名与续期时间
|
||||
for i in range(len(readxx)):
|
||||
if readxx[i]==' ':
|
||||
id=readxx[:i]
|
||||
dayp=int(readxx[i+1:])
|
||||
break
|
||||
#检查用户是否存在
|
||||
if search(id,0)!="":
|
||||
return "未找到"+id
|
||||
#应用更新
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM adminx WHERE admin=?",(id,))
|
||||
data=cur.fetchall()
|
||||
cur.execute("UPDATE adminx SET day=? WHERE admin=?",(data[0][2]+dayp,id))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return '成功更新'+id+'的代理天数至'+str(data[0][2]+dayp)+'天'
|
||||
|
||||
#用户状态配置
|
||||
def turn(id,t):
|
||||
#检查用户是否存在
|
||||
if search(id,0)!="":
|
||||
return "未找到"+id
|
||||
#应用更新
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("UPDATE adminx SET status=? WHERE admin=?",(t,id))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
if t=='y':
|
||||
return '已启用'+id
|
||||
else:
|
||||
return '已禁用'+id
|
||||
|
||||
#修改刷取关卡
|
||||
def gameid(readxx):
|
||||
#提取用户名与修改值
|
||||
for i in range(len(readxx)):
|
||||
if readxx[i]==' ':
|
||||
id=readxx[:i]
|
||||
gamep=readxx[i+1:]
|
||||
break
|
||||
#检查用户是否存在
|
||||
if search(id,0)!="":
|
||||
return "未找到"+id
|
||||
#导入与应用特殊关卡规则
|
||||
games={}
|
||||
with open('data/gameid.txt',encoding='utf-8') as f:
|
||||
gameids=f.readlines()
|
||||
for i in range(len(gameids)):
|
||||
for j in range(len(gameids[i])):
|
||||
if gameids[i][j]==':':
|
||||
gamein=gameids[i][:j]
|
||||
gameout=gameids[i][j+1:]
|
||||
break
|
||||
games[gamein]=gameout.strip()
|
||||
if gamep in games:
|
||||
gamep=games[gamep]
|
||||
#应用更新
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("UPDATE adminx SET game=? WHERE admin=?",(gamep,id))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return '成功更新'+id+'的关卡为'+gamep
|
||||
|
||||
#设置MAA路径
|
||||
def setpath(pathx):
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM pathset WHERE True")
|
||||
pathold=cur.fetchall()
|
||||
if len(pathold)>0:
|
||||
cur.execute("UPDATE pathset SET path=? WHERE True",(pathx,))
|
||||
else:
|
||||
cur.execute("INSERT INTO pathset VALUES(?)",(pathx,))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return "MAA路径已设置为"+pathx
|
||||
|
||||
#设置启动时间
|
||||
def settime(book,timex):
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
#检查待操作对象存在情况
|
||||
cur.execute("SELECT * FROM timeset WHERE True")
|
||||
timeold=cur.fetchall()
|
||||
timeold=[list(row) for row in timeold]
|
||||
timenew=[]
|
||||
timenew.append(timex)
|
||||
#添加时间设置
|
||||
if book=='+':
|
||||
if timenew in timeold:
|
||||
cur.close()
|
||||
db.close()
|
||||
return "已存在"+timex
|
||||
else:
|
||||
cur.execute("INSERT INTO timeset VALUES(?)",(timex,))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return "已添加"+timex
|
||||
#删除时间设置
|
||||
elif book=='-':
|
||||
if timenew in timeold:
|
||||
cur.execute("DELETE FROM timeset WHERE time=?",(timex,))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return "已删除"+timex
|
||||
else:
|
||||
cur.close()
|
||||
db.close()
|
||||
return "未找到"+timex
|
||||
|
||||
#统一制表单元
|
||||
def unit(x,m):
|
||||
#字母与连接符占1位,中文占2位
|
||||
x=str(x)
|
||||
n=0
|
||||
for i in x:
|
||||
if 'a'<=i<='z' or 'A'<=i<='Z' or '0'<=i<='9' or i=='_' or i=='-':
|
||||
n+=1
|
||||
return ' '+x+' '*(m-2*len(x)+n)
|
||||
|
||||
#初期检查
|
||||
DATABASE="data/data.db"
|
||||
PASSWORD=0
|
||||
if not os.path.exists(DATABASE):
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
db.execute("CREATE TABLE adminx(admin text,number text,day int,status text,last date,game text,password byte)")
|
||||
db.execute("CREATE TABLE pathset(path text)")
|
||||
db.execute("CREATE TABLE timeset(time text)")
|
||||
readx=input("首次启动,请设置MAA路径:")
|
||||
cur.execute("INSERT INTO pathset VALUES(?)",(readx,))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
PASSWORD=readpass("请设置管理密钥(密钥与数据库绑定):")
|
||||
getPASSWORD(PASSWORD)
|
||||
|
||||
#初始界面
|
||||
print("Good evening!")
|
||||
print(search("all",1))
|
||||
|
||||
#主程序
|
||||
while True:
|
||||
read=input()
|
||||
if len(read)==0:
|
||||
print("无法识别的输入")
|
||||
elif read[0]=='+' and len(read)==1:
|
||||
print(add())
|
||||
elif read[0]=='-' and len(read)==1:
|
||||
os._exit(0)
|
||||
elif read[0]=='/':
|
||||
print(setpath(read[1:]))
|
||||
elif read[0]=='*' and len(read)==1:
|
||||
print(changePASSWORD())
|
||||
elif read[0]==':' and (read[1]=='+' or read[1]=='-'):
|
||||
print(settime(read[1],read[2:]))
|
||||
else:
|
||||
if read[-1]=='?' and read[-2]==' ':
|
||||
print(search(read[:-2],1))
|
||||
elif read[-1]=='+' and read[-2]==' ':
|
||||
print(renewal(read[:-2]))
|
||||
elif read[-1]=='-' and read[-2]==' ':
|
||||
print(delete(read[:-2]))
|
||||
elif read[-1]=='~' and read[-2]==' ':
|
||||
print(gameid(read[:-2]))
|
||||
elif (read[-1]=='y' or read[-1]=='n') and read[-2]==' ':
|
||||
print(turn(read[:-2],read[-1]))
|
||||
else:
|
||||
print("无法识别的输入")
|
||||
12
requirements.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
loguru
|
||||
plyer
|
||||
PySide6
|
||||
PySide6-Fluent-Widgets[full]
|
||||
psutil
|
||||
opencv-python
|
||||
pywin32
|
||||
pyautogui
|
||||
pycryptodome
|
||||
requests
|
||||
serverchan_sdk
|
||||
nuitka==2.6
|
||||
BIN
res/AUTO_MAA.ico
|
Before Width: | Height: | Size: 1.0 MiB |
BIN
res/AUTO_MAA.png
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 746 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 92 KiB |
43
res/info.txt
@@ -1,43 +0,0 @@
|
||||
# UTF-8
|
||||
#
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||
# Set not needed items to zero 0.
|
||||
filevers=(2, 1, 3, 0),
|
||||
prodvers=(0, 0, 0, 0),
|
||||
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||
mask=0x3f,
|
||||
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||
flags=0x0,
|
||||
# The operating system for which this file was designed.
|
||||
# 0x4 - NT and there is no need to change it.
|
||||
OS=0x4,
|
||||
# The general type of file.
|
||||
# 0x1 - the file is an application.
|
||||
fileType=0x1,
|
||||
# The function of the file.
|
||||
# 0x0 - the function is not defined for this fileType
|
||||
subtype=0x0,
|
||||
# Creation date and time stamp.
|
||||
date=(0, 0)
|
||||
),
|
||||
kids=[
|
||||
VarFileInfo([VarStruct('Translation', [0, 1200])]),
|
||||
StringFileInfo(
|
||||
[
|
||||
StringTable(
|
||||
'000004b0',
|
||||
[StringStruct('Comments', 'https://github.com/DLmaster361/AUTO_MAA/'),
|
||||
StringStruct('CompanyName', 'AUTO_MAA Team'),
|
||||
StringStruct('FileDescription', 'AUTO_MAA Component'),
|
||||
StringStruct('FileVersion', '2.1.3'),
|
||||
StringStruct('InternalName', 'AUTO_MAA'),
|
||||
StringStruct('LegalCopyright', 'Copyright © 2024 DLmaster361'),
|
||||
StringStruct('OriginalFilename', 'AUTO_MAA'),
|
||||
StringStruct('ProductName', 'AUTO_MAA'),
|
||||
StringStruct('ProductVersion', 'v2.1.3'),
|
||||
StringStruct('Assembly Version', '2.1.3.0')])
|
||||
])
|
||||
]
|
||||
)
|
||||
14
res/version.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"main_version": "4.2.0.0",
|
||||
"updater_version": "1.1.0.0",
|
||||
"announcement": "\n# 这是一个中转版本,此版本后更换程序架构方式。\n# 由于更新方法无法通用,您需要在完成本次更新后再次检查更新以获取最新版本。\n",
|
||||
"proxy_list":[
|
||||
"",
|
||||
"https://gitproxy.click/",
|
||||
"https://cdn.moran233.xyz/",
|
||||
"https://gh.llkk.cc/",
|
||||
"https://github.akams.cn/",
|
||||
"https://www.ghproxy.cn/",
|
||||
"https://ghfast.top/"
|
||||
]
|
||||
}
|
||||
45
resources/docs/MAA_config_info.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
#主界面
|
||||
"MainFunction.PostActions": "12" #完成后
|
||||
"TaskQueue.WakeUp.IsChecked": "True" #开始唤醒
|
||||
"TaskQueue.Recruiting.IsChecked": "True" #自动公招
|
||||
"TaskQueue.Base.IsChecked": "True" #基建换班
|
||||
"TaskQueue.Combat.IsChecked": "True" #刷理智
|
||||
"TaskQueue.Mission.IsChecked": "True" #领取奖励
|
||||
"TaskQueue.Mall.IsChecked": "True" #获取信用及购物
|
||||
"TaskQueue.AutoRoguelike.IsChecked": "False" #自动肉鸽
|
||||
"TaskQueue.Reclamation.IsChecked": "False" #生息演算
|
||||
#刷理智
|
||||
"MainFunction.Stage1": "" #主关卡
|
||||
"MainFunction.Stage2": "" #备选关卡1
|
||||
"MainFunction.Stage3": "" #备选关卡2
|
||||
"Fight.RemainingSanityStage": "Annihilation" #剩余理智关卡
|
||||
"MainFunction.Series.Quantity": "1" #连战次数
|
||||
"Penguin.IsDrGrandet": "True" #博朗台模式
|
||||
"GUI.CustomStageCode": "False" #手动输入关卡名
|
||||
"GUI.UseAlternateStage": "False" #使用备选关卡
|
||||
"Fight.UseRemainingSanityStage": "True" #使用剩余理智
|
||||
"GUI.AllowUseStoneSave": "False" #允许吃源石保持状态
|
||||
"Fight.UseExpiringMedicine": "False" #无限吃48小时内过期的理智药
|
||||
"GUI.HideUnavailableStage": "False" #隐藏当日不开放关卡
|
||||
"GUI.HideSeries": "False" #隐藏连战次数
|
||||
"Infrast.CustomInfrastPlanShowInFightSettings": "False" #显示基建计划
|
||||
"Penguin.EnablePenguin": "True" #上报企鹅物流
|
||||
"Yituliu.EnableYituliu": "True" #上报一图流
|
||||
#基建换班
|
||||
"Infrast.CustomInfrastEnabled": "True" #启用自定义基建配置
|
||||
"Infrast.CustomInfrastPlanIndex": "1" #自定义基建配置索引
|
||||
"Infrast.DefaultInfrast": "user_defined" #内置配置
|
||||
"Infrast.IsCustomInfrastFileReadOnly": "False" #自定义基建配置文件只读
|
||||
"Infrast.CustomInfrastFile": "" #自定义基建配置文件地址
|
||||
#设置
|
||||
"Start.ClientType": "Bilibili"、 "Official" #服务器
|
||||
G"Timer.Timer1": "False" #时间设置1
|
||||
G"VersionUpdate.ScheduledUpdateCheck": "True" #定时检查更新
|
||||
G"VersionUpdate.AutoDownloadUpdatePackage": "True" #自动下载更新包
|
||||
G"VersionUpdate.AutoInstallUpdatePackage": "True" #自动安装更新包
|
||||
G"Start.MinimizeDirectly": "True" #启动MAA后直接最小化
|
||||
"Start.RunDirectly": "True" #启动MAA后直接运行
|
||||
"Start.OpenEmulatorAfterLaunch": "True" #启动MAA后自动开启模拟器
|
||||
G"GUI.UseTray": "True" #显示托盘图标
|
||||
G"GUI.MinimizeToTray": "False" #最小化时隐藏至托盘
|
||||
"Start.EmulatorPath" #模拟器路径
|
||||
BIN
resources/icons/AUTO_MAA.ico
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
resources/icons/AUTO_MAA_Updater.ico
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
resources/images/AUTO_MAA.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
resources/images/README/MAA配置.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
resources/images/README/gameid.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
resources/images/README/payid.png
Normal file
|
After Width: | Height: | Size: 309 KiB |
14
resources/version.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"main_version": "4.2.2.2",
|
||||
"updater_version": "1.1.1.3",
|
||||
"announcement": "\n## 新增功能\n- 添加用户每日代理次数上限功能 #15\n- 新增代理成功消息推送渠道Server酱与企业微信群机器人推送\n- 添加更新类别可选项\n## 修复BUG\n- 修复自定义基建无法正常使用的问题\n- 修正人工排查文案\n- 修复高级MAA配置序号错位\n- 修复高级用户列表无法配置问题\n- 修复主调度台选项乱动问题\n- 修复更新器文件夹定位问题\n## 程序优化\n- 无",
|
||||
"proxy_list": [
|
||||
"",
|
||||
"https://gitproxy.click/",
|
||||
"https://cdn.moran233.xyz/",
|
||||
"https://gh.llkk.cc/",
|
||||
"https://github.akams.cn/",
|
||||
"https://www.ghproxy.cn/",
|
||||
"https://ghfast.top/"
|
||||
]
|
||||
}
|
||||
178
run.py
@@ -1,178 +0,0 @@
|
||||
# <AUTO_MAA:A MAA Multi Account Management and Automation Tool>
|
||||
# Copyright © <2024> <DLmaster361>
|
||||
|
||||
# This file is part of AUTO_MAA.
|
||||
|
||||
# AUTO_MAA is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
|
||||
# AUTO_MAA is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
# the GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with AUTO_MAA. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# DLmaster_361@163.com
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import atexit
|
||||
import sqlite3
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
from termcolor import colored
|
||||
|
||||
#执行MAA任务
|
||||
def runmaa(id,tel,game,num=3):
|
||||
#配置MAA运行参数
|
||||
with open(setpath,"r",encoding="utf-8") as f:
|
||||
data=json.load(f)
|
||||
data["Configurations"]["Default"]["Start.AccountName"]=tel[:3]+"****"+tel[7:]
|
||||
data["Configurations"]["Default"]["MainFunction.Stage1"]="Annihilation"
|
||||
data["Configurations"]["Default"]["Fight.RemainingSanityStage"]=game
|
||||
data["Configurations"]["Default"]["Fight.UseRemainingSanityStage"]="True"
|
||||
data["Configurations"]["Default"]["GUI.CustomStageCode"]="True"
|
||||
with open(setpath,"w",encoding="utf-8") as f:
|
||||
json.dump(data,f)
|
||||
#开始运行
|
||||
for i in range(num):
|
||||
global idnew,idold,idfail,idall,logx,logi
|
||||
#创建MAA任务
|
||||
time.sleep(10)
|
||||
maa=subprocess.Popen([maapath])
|
||||
maapid=maa.pid
|
||||
#等待MAA启动
|
||||
idsuccess=idnew+idold
|
||||
idwait=[idx for idx in idall if not idx in idsuccess+idfail+[id]]
|
||||
os.system('cls')
|
||||
if i==0:
|
||||
print(colored("正在代理:",'white')+colored(id,'blue'))
|
||||
else:
|
||||
print(colored("正在代理:",'white')+colored(id,'light_blue'))
|
||||
print(colored("等待代理:",'white')+colored(','.join(idwait),'yellow'))
|
||||
print(colored("代理成功:",'white')+colored(','.join(idsuccess),'green'))
|
||||
print(colored("代理失败:",'white')+colored(','.join(idfail),'red'))
|
||||
print(colored("运行日志:",'white')+colored("等待MAA初始化",'light_green'))
|
||||
time.sleep(60)
|
||||
#监测MAA运行状态
|
||||
while True:
|
||||
#打印基本信息
|
||||
os.system('cls')
|
||||
if i==0:
|
||||
print(colored("正在代理:",'white')+colored(id,'blue'))
|
||||
else:
|
||||
print(colored("正在代理:",'white')+colored(id,'light_blue'))
|
||||
print(colored("等待代理:",'white')+colored(','.join(idwait),'yellow'))
|
||||
print(colored("代理成功:",'white')+colored(','.join(idsuccess),'green'))
|
||||
print(colored("代理失败:",'white')+colored(','.join(idfail),'red'))
|
||||
print(colored("运行日志:",'white'))
|
||||
#读取并保存MAA日志
|
||||
with open(logpath,'r',encoding='utf-8') as f:
|
||||
logs=f.readlines()[-1:-11:-1]
|
||||
print(colored(''.join(logs[::-1]),'light_green'),end='')
|
||||
log=''.join(logs)
|
||||
logx[logi]=log
|
||||
logi=(logi+1) % len(logx)
|
||||
#判断MAA程序运行状态
|
||||
if ("任务已全部完成!" in log):
|
||||
return True
|
||||
elif ("请检查连接设置或尝试重启模拟器与 ADB 或重启电脑" in log) or ("已停止" in log) or ("MaaAssistantArknights GUI exited" in log) or timeout():
|
||||
os.system('taskkill /F /T /PID '+str(maapid))
|
||||
break
|
||||
time.sleep(10)
|
||||
return False
|
||||
|
||||
#检查是否超时
|
||||
def timeout():
|
||||
global logx
|
||||
log0=logx[0]
|
||||
for i in range(len(logx)):
|
||||
if logx[i]!=log0:
|
||||
return False
|
||||
return True
|
||||
|
||||
#更新已完成用户的数据
|
||||
def updata(id):
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM adminx WHERE admin=?",(id,))
|
||||
info=cur.fetchall()
|
||||
cur.execute("UPDATE adminx SET day=? WHERE admin=?",(info[0][2]-1,id))
|
||||
db.commit()
|
||||
cur.execute("UPDATE adminx SET last=? WHERE admin=?",(curdate,id))
|
||||
db.commit()
|
||||
cur.close()
|
||||
db.close()
|
||||
return 0
|
||||
|
||||
#资源回收
|
||||
def cleanup():
|
||||
if os.path.exists("state/RUNNING"):
|
||||
os.remove("state/RUNNING")
|
||||
|
||||
#读取运行情况
|
||||
if os.path.exists("state/RUNNING"):
|
||||
os._exit(1)
|
||||
#标记当前正在运行
|
||||
with open("state/RUNNING","w",encoding="utf-8") as f:
|
||||
print("RUNNING",file=f)
|
||||
#设置回调函数
|
||||
atexit.register(cleanup)
|
||||
#获取PATH与用户数据
|
||||
DATABASE="data/data.db"
|
||||
db=sqlite3.connect(DATABASE)
|
||||
cur=db.cursor()
|
||||
cur.execute("SELECT * FROM pathset WHERE True")
|
||||
path=cur.fetchall()
|
||||
path=str(path[0][0])
|
||||
setpath=path+"/config/gui.json"
|
||||
logpath=path+"/debug/gui.log"
|
||||
maapath=path+"/MAA.exe"
|
||||
cur.execute("SELECT * FROM adminx WHERE True")
|
||||
data=cur.fetchall()
|
||||
data=[list(row) for row in data]
|
||||
cur.close()
|
||||
db.close()
|
||||
#开始执行
|
||||
curdate=datetime.date.today().strftime('%Y-%m-%d')
|
||||
begintime=datetime.datetime.now().strftime("%H:%M")
|
||||
idnew=[]
|
||||
idold=[]
|
||||
idfail=[]
|
||||
idall=[data[i][0] for i in range(len(data))]
|
||||
LOGXLEN=60
|
||||
logx=['' for i in range(LOGXLEN)]
|
||||
logi=0
|
||||
for i in range(len(data)):
|
||||
if data[i][3]=='y' and data[i][4]!=curdate and data[i][2]>0:
|
||||
book=runmaa(data[i][0],data[i][1],data[i][5])
|
||||
if book:
|
||||
updata(data[i][0])
|
||||
idnew.append(data[i][0])
|
||||
else:
|
||||
idfail.append(data[i][0])
|
||||
for i in range(len(data)):
|
||||
if data[i][3]=='y' and data[i][4]==curdate and data[i][2]>0:
|
||||
book=runmaa(data[i][0],data[i][1],data[i][5])
|
||||
if book:
|
||||
idold.append(data[i][0])
|
||||
else:
|
||||
idall.remove(data[i][0])
|
||||
endtime=datetime.datetime.now().strftime("%H:%M")
|
||||
with open("log.txt","w",encoding="utf-8") as f:
|
||||
print("任务开始时间:"+begintime+",结束时间:"+endtime,file=f)
|
||||
print("已完成数:"+str(len(idnew))+",未完成数:"+str(len(idfail))+",重复执行数:"+str(len(idold)),file=f)
|
||||
if len(idfail)!=0:
|
||||
print("代理未完成的用户:",file=f)
|
||||
for i in range(len(idfail)):
|
||||
print(idfail[i],file=f)
|
||||
if os.path.exists("state/BEGIN"):
|
||||
with open("state/END","w",encoding="utf-8") as f:
|
||||
print("END",file=f)
|
||||
sys.exit(0)
|
||||
@@ -1 +0,0 @@
|
||||
此文件夹内文件用于AUTO_MAA组件间的信息传递,如果遇到run.exe闪退或AUTO_MAA.exe一直显示“正在运行代理”,请尝试删除本文件夹下的所有文件。
|
||||