mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-07-03 21:43:30 +00:00
Compare commits
346 Commits
nonebot2-b
...
QQGuildBot
Author | SHA1 | Date | |
---|---|---|---|
474939801d | |||
fdef61bc2f | |||
27f17f9d1b | |||
da02c9e3fe | |||
38bcf9ab98 | |||
6308f39ef1 | |||
b0e35e906f | |||
97c55ba2b4 | |||
5c452b364f | |||
0a2427f931 | |||
b4b21e14c1 | |||
1df91e9512 | |||
3802371d69 | |||
8d8533044e | |||
77d70775de | |||
22096c3d02 | |||
c3cf59f518 | |||
e39c9ccee6 | |||
8bf3f51820 | |||
57ae879057 | |||
ec459237da | |||
1518a69102 | |||
21777d971c | |||
719b3992dc | |||
1b8328de1d | |||
865df9fbcd | |||
fc7e384367 | |||
cfbc21401b | |||
003fe8a3a3 | |||
0b738d4ff5 | |||
a7a8f67a23 | |||
6d26f12e7f | |||
3e13a0974c | |||
3193b8462f | |||
dbf7221609 | |||
0d7d6ec518 | |||
c7c555d644 | |||
fce2348971 | |||
4ad951e319 | |||
f1c92e2a9e | |||
ce67787c62 | |||
1f5edb77f4 | |||
61e356fe06 | |||
06bb055aab | |||
fafdbe4cc6 | |||
4f9b1a547c | |||
25228518af | |||
8272a1d45b | |||
607585c65d | |||
5449566357 | |||
a06c8a29ee | |||
14ce0dcbb4 | |||
31f08c16bb | |||
ebcdaa07a9 | |||
12d3d27f65 | |||
ab6cad2dc3 | |||
03dc27609e | |||
99fbf9d0dc | |||
1b4e3df777 | |||
2b9484e0d3 | |||
45455388e2 | |||
a9d4914de3 | |||
a05a922e8e | |||
e2c8edacc2 | |||
e4a12b2d5f | |||
8180f8dd5f | |||
dbcf214d3a | |||
0bb40319a1 | |||
f3771c1950 | |||
0a8a5cf9da | |||
fe183d3a89 | |||
cb24cdbf23 | |||
118cfc68b1 | |||
986125af32 | |||
0c3b8fc58e | |||
e4b191c932 | |||
f0d5a3e371 | |||
f07450bfd8 | |||
3c7bd4ce35 | |||
06cca70bd5 | |||
7c0cfaeb64 | |||
043e626a07 | |||
c6e51ecfeb | |||
06ab2d9ed3 | |||
257f4c7d94 | |||
b602b99e82 | |||
4755e86c97 | |||
8777c730e1 | |||
f2157be829 | |||
cd48c8deae | |||
ec89590c9c | |||
74ad0be66b | |||
32e9ddef2d | |||
594344a0c1 | |||
7d85d89107 | |||
711d9a372f | |||
952f2abe65 | |||
717f776b02 | |||
6911eaa1d3 | |||
be3084074c | |||
f651e2060c | |||
d50dcf6134 | |||
8eeede0b49 | |||
9af6a68ffe | |||
1b25add056 | |||
98f3744543 | |||
58614e6e94 | |||
d149b8a0be | |||
7629559f17 | |||
82481d5f09 | |||
559906b742 | |||
0d91bcbfd3 | |||
b216323c75 | |||
e27960af15 | |||
91e34b7684 | |||
17453d5cb3 | |||
35623949ae | |||
c3cc0e6c2d | |||
41ab9e1133 | |||
da7f8ac510 | |||
f0c183501b | |||
9cd467cbf5 | |||
e0c1fc2f59 | |||
0a1892eee8 | |||
81cbd547a6 | |||
b3adee4e8d | |||
e3cbebbdec | |||
57440fad9e | |||
9329f1f723 | |||
4ec7b16fec | |||
94607ece00 | |||
52b989eef6 | |||
23b63da70b | |||
219cba148d | |||
c45f546c2c | |||
a585f95128 | |||
5e2406c88c | |||
3eddb06f7b | |||
001ac794af | |||
c0a60845ab | |||
7fe880a7a0 | |||
6f22de7623 | |||
5f51e378b5 | |||
397ecbf569 | |||
6241be4224 | |||
0413311345 | |||
63aec98647 | |||
7273c07a9c | |||
a2e053c279 | |||
c88037d9ae | |||
a8ccab1a3e | |||
4a6ec9f718 | |||
1eea39e759 | |||
3b543f9bed | |||
24dc256989 | |||
04540b4dbd | |||
5d3c481437 | |||
89c60337b7 | |||
cbae225225 | |||
a6a842bf0e | |||
2e5668b77b | |||
0b6e7146ab | |||
f03ec2a4ef | |||
0936856218 | |||
37cdbb9a26 | |||
9fd1c725d0 | |||
843e821bc6 | |||
9ced17a1a5 | |||
8ee92d0d2d | |||
7fa86be495 | |||
8f817050a7 | |||
edc76d974e | |||
ee4200e093 | |||
e9490d9a3b | |||
f17bc36b12 | |||
34d2af332f | |||
16bec27e27 | |||
256d264d7f | |||
403c6ddadd | |||
ddce7c0857 | |||
4c68c1bb45 | |||
58aab2821f | |||
95e47679d4 | |||
09a34d90f8 | |||
cc4c17bebe | |||
2470732df2 | |||
d96458d143 | |||
768d706144 | |||
5f120c2bb5 | |||
cb9f19c79d | |||
95d74dc76d | |||
de414301d9 | |||
5b0b1bc74f | |||
9e37ccbc4e | |||
461215a2d5 | |||
58debfb018 | |||
86ef61a916 | |||
ad6e3f6355 | |||
6456f6970c | |||
f4290334f3 | |||
7d0c79bd52 | |||
5f038227b0 | |||
7ea12afee9 | |||
e9228b447c | |||
806e2f4b29 | |||
f9a33c680d | |||
3be0a04a35 | |||
73c0744b0d | |||
f6f169428e | |||
580631d11d | |||
94a5449e10 | |||
b23f4cf42f | |||
9f9dca5b96 | |||
4d06e056f0 | |||
8a7b35fcfa | |||
3ce77fbd74 | |||
3790c79a59 | |||
2da7d63257 | |||
3cb7a5c34b | |||
5174db4b95 | |||
f7b217f0f7 | |||
306c9603b1 | |||
3e14aaad20 | |||
fc8bdd7f25 | |||
55506601a4 | |||
47b047d87c | |||
86bcd7dcf4 | |||
56d8d965d5 | |||
3bbbc899cc | |||
8e27c9804a | |||
9ec921835e | |||
5c252f79ca | |||
cc9ff70dba | |||
ff887b7b07 | |||
952324f86c | |||
6509db7e6e | |||
f27ce031b3 | |||
d4c0f9486d | |||
8c9ff9a303 | |||
cefccc4595 | |||
f5e1c13b37 | |||
0aa10fbbfb | |||
cad0fd83e5 | |||
8c6146dc5f | |||
76094023cd | |||
7ee8e9d92e | |||
c3b218e742 | |||
444be35fae | |||
8bb217b559 | |||
6357c14884 | |||
ff919b723f | |||
7f7ef72279 | |||
cec1ed59bc | |||
de0fe54ea1 | |||
aef1e35e2d | |||
a891201bdd | |||
06bb43c060 | |||
3bd88688f2 | |||
c1efb28ac6 | |||
188feaa476 | |||
a0e6aa8398 | |||
c935cdfd77 | |||
344ff332e7 | |||
bfeb2562f0 | |||
66dcfed64f | |||
d83554128b | |||
af6cb81ebb | |||
50110742f8 | |||
cc5a77bac3 | |||
7eeb22bff8 | |||
5d620fff37 | |||
6ee27b6136 | |||
1f5e9a8e30 | |||
a79130e5af | |||
b83d786bde | |||
a6727600e8 | |||
7e290406d0 | |||
9667d1aa07 | |||
9be3895215 | |||
e4fce7c075 | |||
e18b444d2a | |||
580db9060d | |||
15ccb8e214 | |||
f229b881bc | |||
13cf46cf43 | |||
ae61435334 | |||
42c255640c | |||
1b3b1d3779 | |||
2b81ccc4d4 | |||
c33bb130ab | |||
a05f856a8e | |||
6e1b20fcfb | |||
dce3fede2a | |||
9167581122 | |||
029a2b4e7d | |||
b014dd8218 | |||
dd42b5b6b6 | |||
65cd3e0852 | |||
1ee60b2c17 | |||
9a4123db14 | |||
f7eba39657 | |||
67d3a0be02 | |||
b8f295a78d | |||
4f76dcb9ff | |||
f5b9a0b985 | |||
d2ab169128 | |||
97260c8696 | |||
1b14f7986d | |||
2a8e54d1f0 | |||
6e92ed1daf | |||
d3c69bf2b1 | |||
93eba1e036 | |||
4d911c31ec | |||
d81d3db719 | |||
e9d4ae58be | |||
2c7148410f | |||
0a8d936839 | |||
64915421eb | |||
3ca8a28a02 | |||
711a7ed943 | |||
56ad8f5f33 | |||
3f5cf907d3 | |||
56e99ec00c | |||
b32ff63d6e | |||
88f2f66377 | |||
5fd0bbf27a | |||
29567d22ee | |||
0462f28d76 | |||
644c825e2f | |||
1e89b72e0d | |||
f8a7e1c34b | |||
ed7e5c5b79 | |||
82ad1efb19 | |||
fb555a9595 | |||
9a5fdd6690 | |||
8c8cb29cc4 | |||
012981f566 | |||
fb43d02c5a | |||
ac6631b9cd | |||
5ac8e61da1 | |||
b7e7a4e5e9 | |||
39c1ee24c7 | |||
60523102d2 | |||
035496965f | |||
f9701195a0 | |||
0ecb4b4b26 |
54
.github/workflows/pre-commit.yml
vendored
Normal file
54
.github/workflows/pre-commit.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: Pre Commit
|
||||
on:
|
||||
- pull_request
|
||||
jobs:
|
||||
Pre-Commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.10"
|
||||
architecture: "x64"
|
||||
|
||||
- name: Setup pre-commit and actions-toolkit
|
||||
run: "python3 -m pip install pre-commit actions-toolkit"
|
||||
|
||||
- name: Run pre-commit
|
||||
run: python3 -c "import os;os.system('python3 -m pre_commit run --color never -a > result.txt')"
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email github-actions[bot]@users.noreply.github.com
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m ":rotating_light: auto fix by pre-commit"
|
||||
git push
|
||||
|
||||
- name: Read result
|
||||
id: rr
|
||||
run: python3 -c "from pathlib import Path;from actions_toolkit.core import set_output;comment=Path('./result.txt').read_text();set_output('comment', comment)"
|
||||
|
||||
- name: Find Comment
|
||||
uses: peter-evans/find-comment@v2
|
||||
id: fc
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: "github-actions[bot]"
|
||||
body-includes: "pre-commit"
|
||||
|
||||
- name: Create or update comment
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
with:
|
||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
pre-commit output:
|
||||
```
|
||||
${{ steps.rr.outputs.COMMENT }}
|
||||
```
|
||||
edit-mode: replace
|
42
.github/workflows/unittest.yml
vendored
42
.github/workflows/unittest.yml
vendored
@ -1,42 +0,0 @@
|
||||
name: Unittest
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- nonebot2-beta1
|
||||
pull_request:
|
||||
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
strategy:
|
||||
matrix:
|
||||
version: ["3.8", "3.9", "3.10", "3.11"]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
shell: bash
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.version }}
|
||||
architecture: "x64"
|
||||
cache: "poetry"
|
||||
|
||||
- name: Install dependencies
|
||||
run: poetry install --with test --without dev
|
||||
shell: bash
|
||||
|
||||
- name: Run Pytest
|
||||
run: |
|
||||
cd tests
|
||||
poetry run pytest
|
@ -1,7 +1,5 @@
|
||||
ci:
|
||||
autofix_commit_msg: ":rotating_light: auto fix by pre-commit-ci"
|
||||
skip:
|
||||
- "poetry-lock"
|
||||
autofix_prs: true
|
||||
autoupdate_branch: master
|
||||
autoupdate_schedule: monthly
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -7,8 +7,6 @@
|
||||
"genshin",
|
||||
"genshinuid",
|
||||
"minigg",
|
||||
"nonebot",
|
||||
"nonebug",
|
||||
"weapontype"
|
||||
],
|
||||
"[python]": {
|
||||
|
@ -1,25 +1,42 @@
|
||||
from pathlib import Path
|
||||
from pkgutil import iter_modules
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot import require, load_all_plugins, get_plugin_by_module_name
|
||||
|
||||
from .config import config as _config
|
||||
|
||||
require('nonebot_plugin_apscheduler')
|
||||
|
||||
# from .utils.nonebot2.send import patch_send
|
||||
|
||||
# patch_send()
|
||||
if get_plugin_by_module_name("GenshinUID"):
|
||||
logger.info("推荐直接加载 GenshinUID 仓库文件夹")
|
||||
load_all_plugins(
|
||||
[
|
||||
f"GenshinUID.{module.name}"
|
||||
for module in iter_modules([str(Path(__file__).parent)])
|
||||
if module.ispkg
|
||||
and (
|
||||
(name := module.name[11:]) == "meta"
|
||||
or name not in _config.disabled_plugins
|
||||
)
|
||||
# module.name[:11] == genshinuid_
|
||||
'GenshinUID.genshinuid_abyss',
|
||||
'GenshinUID.genshinuid_adv',
|
||||
'GenshinUID.genshinuid_ann',
|
||||
'GenshinUID.genshinuid_gcg',
|
||||
'GenshinUID.genshinuid_xkdata',
|
||||
'GenshinUID.genshinuid_check',
|
||||
'GenshinUID.genshinuid_collection',
|
||||
'GenshinUID.genshinuid_config',
|
||||
'GenshinUID.genshinuid_enka',
|
||||
'GenshinUID.genshinuid_etcimg',
|
||||
'GenshinUID.genshinuid_eventlist',
|
||||
'GenshinUID.genshinuid_gachalog',
|
||||
'GenshinUID.genshinuid_guide',
|
||||
'GenshinUID.genshinuid_help',
|
||||
'GenshinUID.genshinuid_map',
|
||||
'GenshinUID.genshinuid_meta',
|
||||
'GenshinUID.genshinuid_mhybbscoin',
|
||||
'GenshinUID.genshinuid_mys',
|
||||
'GenshinUID.genshinuid_note',
|
||||
'GenshinUID.genshinuid_resin',
|
||||
'GenshinUID.genshinuid_resource',
|
||||
'GenshinUID.genshinuid_roleinfo',
|
||||
'GenshinUID.genshinuid_signin',
|
||||
'GenshinUID.genshinuid_user',
|
||||
'GenshinUID.genshinuid_wikitext',
|
||||
'GenshinUID.genshinuid_webconsole',
|
||||
'GenshinUID.genshinuid_update',
|
||||
],
|
||||
[],
|
||||
)
|
||||
|
@ -1,15 +1,5 @@
|
||||
from typing import Set
|
||||
|
||||
from nonebot import get_driver
|
||||
from pydantic import Field, BaseModel
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
disabled_plugins: Set[str] = Field(
|
||||
default_factory=set, alias="genshinuid_disabled_plugins"
|
||||
)
|
||||
priority: int = Field(2, alias="genshinuid_priority")
|
||||
|
||||
|
||||
config = Config.parse_obj(get_driver().config)
|
||||
priority = config.priority
|
||||
config = get_driver().config
|
||||
SUPERUSERS = {int(x) for x in config.superusers}
|
||||
priority = 2
|
||||
|
@ -1,18 +1,15 @@
|
||||
from typing import Any, Tuple, Union
|
||||
from typing import Any, Tuple
|
||||
|
||||
from nonebot import on_regex
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, RegexGroup
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from .draw_abyss_card import draw_abyss_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.mhy_api.convert_mysid_to_uid import convert_mysid
|
||||
@ -34,29 +31,26 @@ get_abyss_info = on_regex(
|
||||
'查询(@某人)(上期)深渊(xx层)',
|
||||
'查询你的或者指定人的深渊战绩',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(125,125,125)>(上期)</ft>'
|
||||
'<ft color=(238,120,0)>深渊</ft>'
|
||||
'<ft color=(125,125,125)>(xx层)</ft>\n'
|
||||
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
||||
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>查询深渊</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789上期深渊</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft> '
|
||||
'<ft color=(238,120,0)>查询深渊</ft>;\n'
|
||||
'<ft color=(238,120,0)>uid123456789上期深渊</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft> '
|
||||
'<ft color=(238,120,0)>上期深渊12层</ft>'
|
||||
),
|
||||
)
|
||||
async def send_abyss_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
@ -64,11 +58,11 @@ async def send_abyss_info(
|
||||
logger.info('开始执行[查询深渊信息]')
|
||||
logger.info(f'[查询深渊信息]参数: {args}')
|
||||
at = custom.get_first_at()
|
||||
qid = at or event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
if args[2] == 'mys':
|
||||
uid = await convert_mysid(args[3])
|
||||
elif args[3] is None:
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
uid = str(uid)
|
||||
elif len(args[3]) != 9:
|
||||
return
|
||||
@ -97,6 +91,6 @@ async def send_abyss_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -2,7 +2,7 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.onebot.v11 import Message
|
||||
from nonebot.adapters.qqguild import Message
|
||||
|
||||
from ..config import priority
|
||||
from .get_achi_desc import get_achi, get_daily_achi
|
||||
|
@ -23,17 +23,15 @@ get_weapon_adv = on_regex(
|
||||
'xx用什么',
|
||||
'查询角色武器/圣遗物推荐配置',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[角色名][用什么/能用啥/怎么养]</ft>\n'
|
||||
' \n'
|
||||
'可以查询某角色的武器/圣遗物推荐配置\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||
'<ft color=(238,120,0)>{用什么|能用啥|怎么养}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>钟离用什么</ft>\n'
|
||||
'- <ft color=(238,120,0)>公子怎么养</ft>'
|
||||
'<ft color=(238,120,0)>钟离用什么</ft>;\n'
|
||||
'<ft color=(238,120,0)>公子怎么养</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char_adv(
|
||||
@ -51,17 +49,15 @@ async def send_char_adv(
|
||||
'xx能给谁',
|
||||
'查询某武器/圣遗物能给谁用',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[角色名][能给谁/给谁用/要给谁/谁能用]</ft>\n'
|
||||
' \n'
|
||||
'可以通过武器/圣遗物名反查适用的角色\n'
|
||||
'支持部分别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[武器名]</ft>'
|
||||
'<ft color=(238,120,0)>{能给谁|给谁用|要给谁|谁能用}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>四风原典能给谁</ft>\n'
|
||||
'- <ft color=(238,120,0)>千岩给谁用</ft>'
|
||||
'<ft color=(238,120,0)>四风原典能给谁</ft>;\n'
|
||||
'<ft color=(238,120,0)>千岩给谁用</ft>'
|
||||
),
|
||||
)
|
||||
async def send_weapon_adv(
|
||||
|
@ -7,18 +7,14 @@ from nonebot.params import CommandArg
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Message,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
|
||||
from .util import black_ids
|
||||
from ..config import priority
|
||||
from .main import ann, consume_remind
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..genshinuid_config.default_config import string_config
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -49,31 +45,31 @@ async def send_ann_pic(
|
||||
|
||||
if not ann_id:
|
||||
img = await ann_list_card()
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
||||
if not ann_id.isdigit():
|
||||
raise Exception("公告ID不正确")
|
||||
|
||||
img = await ann_detail_card(int(ann_id))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
||||
|
||||
@reg_ann.handle()
|
||||
@handle_exception('设置原神公告', '设置原神公告失败')
|
||||
async def send_reg_ann(
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
await matcher.finish(sub_ann(event.group_id))
|
||||
await matcher.finish(sub_ann(event.channel_id))
|
||||
|
||||
|
||||
@unreg_ann.handle()
|
||||
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
||||
async def send_unreg_ann(
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
await matcher.finish(unsub_ann(event.group_id))
|
||||
await matcher.finish(unsub_ann(event.channel_id))
|
||||
|
||||
|
||||
@consume_ann.handle()
|
||||
@ -82,7 +78,7 @@ async def send_consume_ann(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = event.user_id
|
||||
qid = str(cast_to_int(event.author))
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
if '未找到绑定的UID' in uid:
|
||||
@ -128,9 +124,9 @@ async def check_ann_state():
|
||||
for group in sub_list:
|
||||
try:
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=group,
|
||||
message=MessageSegment.image(img),
|
||||
api='_post_messages',
|
||||
channel_id=group,
|
||||
content=img,
|
||||
)
|
||||
await asyncio.sleep(random.uniform(1, 3))
|
||||
except Exception as e:
|
||||
|
@ -1,17 +1,11 @@
|
||||
import random
|
||||
import asyncio
|
||||
from typing import Union
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from .backup_data import data_backup
|
||||
@ -19,11 +13,6 @@ from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_cache_and_check import check_db, check_stoken_db
|
||||
from ..utils.db_operation.db_operation import delete_cookies, get_all_push_list
|
||||
from ..utils.message.get_cqhttp_data import (
|
||||
get_all_friend_list,
|
||||
get_group_member_list,
|
||||
)
|
||||
|
||||
backup = on_command('gs清除缓存', rule=FullCommand(), priority=priority)
|
||||
check = on_command('校验全部Cookies', rule=FullCommand(), priority=priority)
|
||||
@ -42,22 +31,9 @@ async def daily_refresh_charData():
|
||||
|
||||
@backup.handle()
|
||||
@handle_exception('清除缓存', '清除缓存错误')
|
||||
@register_menu(
|
||||
'清除缓存',
|
||||
'清除缓存',
|
||||
'清除插件产生的缓存数据',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'备份一份插件数据库后清除插件产生的文件与数据库缓存\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>清除缓存</ft>'
|
||||
),
|
||||
)
|
||||
async def send_backup_msg(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
@ -66,52 +42,6 @@ async def send_backup_msg(
|
||||
await matcher.finish('操作成功完成!')
|
||||
|
||||
|
||||
@remove_invalid_user.handle()
|
||||
@handle_exception('清除无效用户', '清除无效用户错误')
|
||||
@register_menu(
|
||||
'清除无效用户',
|
||||
'清除无效用户',
|
||||
'清除非好友或非推送群成员的数据',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'从数据库中删除掉 开启了私聊推送但不是Bot好友的用户 '
|
||||
'以及 开启了群聊推送但不在推送目标群的用户 的数据\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>清除无效用户</ft>'
|
||||
),
|
||||
)
|
||||
async def send_remove_invalid_user_msg(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
im_list = []
|
||||
invalid_user = {}
|
||||
invalid_uid_list = []
|
||||
user_list = await get_all_push_list()
|
||||
friend_list = await get_all_friend_list(bot)
|
||||
for user in user_list:
|
||||
if user['StatusA'] == 'on':
|
||||
if user['QID'] not in friend_list:
|
||||
invalid_user['qid'] = user['UID']
|
||||
invalid_uid_list.append(user['UID'])
|
||||
else:
|
||||
group_member_list = await get_group_member_list(
|
||||
bot, int(user['StatusA'])
|
||||
)
|
||||
if user['QID'] not in group_member_list:
|
||||
invalid_user['qid'] = user['UID']
|
||||
invalid_uid_list.append(user['UID'])
|
||||
for uid in invalid_uid_list:
|
||||
im_list.append(await delete_cookies(str(uid)))
|
||||
logger.warning(f'无效UID已被删除: {uid}')
|
||||
await matcher.finish(f'已清理失效用户{len(im_list)}个!')
|
||||
|
||||
|
||||
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
||||
@check.handle()
|
||||
@handle_exception('Cookie校验', 'Cookie校验错误')
|
||||
@ -119,14 +49,14 @@ async def send_remove_invalid_user_msg(
|
||||
'校验全部Cookies',
|
||||
'校验全部Cookies',
|
||||
'校验数据库内所有Cookies是否正常',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Cookies</ft>的'
|
||||
'<ft color=(238,120,0)>C</ft>为大写'
|
||||
'<ft color=(238,120,0)>C</ft>为大写\n'
|
||||
' \n'
|
||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除'
|
||||
),
|
||||
)
|
||||
async def send_check_cookie(bot: Bot, matcher: Matcher):
|
||||
@ -156,13 +86,13 @@ async def send_check_cookie(bot: Bot, matcher: Matcher):
|
||||
'校验全部Stoken',
|
||||
'校验全部Stoken',
|
||||
'校验数据库内所有Stoken是否正常',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写'
|
||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除'
|
||||
),
|
||||
)
|
||||
async def send_check_stoken(bot: Bot, matcher: Matcher):
|
||||
|
@ -1,19 +1,13 @@
|
||||
from typing import Union
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.data_convert.get_uid import get_uid
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .draw_collection_card import draw_explora_img, draw_collection_img
|
||||
@ -29,27 +23,24 @@ get_explora_info = on_command('查询探索', aliases={'探索', 'ts'}, block=Tr
|
||||
'查询(@某人)收集',
|
||||
'查询你的或者指定人的宝箱收集度',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(238,120,0)>[收集/宝箱/sj/bx]</ft>\n'
|
||||
' \n'
|
||||
'可以用来查看你的或者指定人的宝箱收集度\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(238,120,0)>{收集|宝箱|sj|bx}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>查询收集</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789宝箱</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi'
|
||||
'<ft color=(238,120,0)>查询收集</ft>;\n'
|
||||
'<ft color=(238,120,0)>uid123456789宝箱</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi'
|
||||
'</ft> <ft color=(238,120,0)>bx</ft>'
|
||||
),
|
||||
)
|
||||
async def send_collection_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
@ -58,14 +49,11 @@ async def send_collection_info(
|
||||
logger.info('[查询收集信息]参数: {}'.format(args))
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
else:
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
# 获取uid
|
||||
uid = await get_uid(qid, raw_mes)
|
||||
logger.info('[查询角色面板]uid: {}'.format(uid))
|
||||
logger.info('[查询收集信息]uid: {}'.format(uid))
|
||||
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
@ -74,7 +62,7 @@ async def send_collection_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
@ -82,7 +70,7 @@ async def send_collection_info(
|
||||
@get_explora_info.handle()
|
||||
@handle_exception('查询探索信息')
|
||||
async def send_explora_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
@ -91,14 +79,11 @@ async def send_explora_info(
|
||||
logger.info('[查询探索信息]参数: {}'.format(args))
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
else:
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
# 获取uid
|
||||
uid = await get_uid(qid, raw_mes)
|
||||
logger.info('[查询角色面板]uid: {}'.format(uid))
|
||||
logger.info('[查询探索信息]uid: {}'.format(uid))
|
||||
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
@ -107,6 +92,6 @@ async def send_explora_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -1,21 +1,15 @@
|
||||
from typing import Any, Tuple, Union
|
||||
from typing import Any, Tuple
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import Depends, CommandArg, RegexGroup
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from .draw_config_card import draw_config_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from .set_config import set_push_value, set_config_func
|
||||
@ -38,18 +32,6 @@ config_card = on_command('gs配置')
|
||||
|
||||
@config_card.handle()
|
||||
@handle_exception('发送配置表')
|
||||
@register_menu(
|
||||
'发送配置表',
|
||||
'gs配置',
|
||||
'查看插件当前配置项开关情况',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看插件当前配置项开关情况\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs配置</ft>'
|
||||
),
|
||||
)
|
||||
async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
||||
if args:
|
||||
await matcher.finish()
|
||||
@ -58,41 +40,23 @@ async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@push_config.handle()
|
||||
@handle_exception('设置推送服务')
|
||||
@register_menu(
|
||||
'设置推送阈值',
|
||||
'gs设置xx(@某人)',
|
||||
'设置自己或指定人的推送服务阈值',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'设置某人的推送服务阈值\n'
|
||||
'超级用户可以设置他人的推送服务阈值\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs设置</ft>'
|
||||
'<ft color=(0,148,200)>[服务名称][阈值]</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>gs设置推送140</ft>'
|
||||
),
|
||||
)
|
||||
async def send_config_msg(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[设置阈值信息]')
|
||||
logger.info('[设置阈值信息]参数: {}'.format(args))
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
at = custom.get_first_at()
|
||||
|
||||
if at and await SUPERUSER(bot, event):
|
||||
@ -102,7 +66,7 @@ async def send_config_msg(
|
||||
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
||||
|
||||
try:
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
except TypeError:
|
||||
await matcher.finish(UID_HINT)
|
||||
|
||||
@ -121,34 +85,16 @@ async def send_config_msg(
|
||||
|
||||
# 开启 自动签到 和 推送树脂提醒 功能
|
||||
@open_and_close_switch.handle()
|
||||
@register_menu(
|
||||
'开关推送服务',
|
||||
'gs{开启|关闭}xx(@某人)',
|
||||
'开关自己或指定人的推送服务状态',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'设置某人的推送服务开关状态\n'
|
||||
'超级用户可以设置他人的推送服务状态\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs{开启|关闭}</ft>'
|
||||
'<ft color=(0,148,200)>[服务名称]</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>gs开启推送</ft>'
|
||||
),
|
||||
)
|
||||
async def open_switch_func(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
at: ImageAndAt = Depends(),
|
||||
):
|
||||
qid = event.user_id
|
||||
atqq = at.get_first_at() if at else None
|
||||
|
||||
qid = cast_to_int(event.author)
|
||||
if at:
|
||||
at = at.get_first_at() # type: ignore
|
||||
config_name = args[4]
|
||||
|
||||
logger.info(f'[{qid}]尝试[{args[3]}]了[{config_name}]功能')
|
||||
@ -164,20 +110,20 @@ async def open_switch_func(
|
||||
query = 'CLOSED'
|
||||
gid = 'off'
|
||||
is_admin = await SUPERUSER(bot, event)
|
||||
if atqq:
|
||||
if is_admin:
|
||||
qid = atqq
|
||||
elif atqq != qid:
|
||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
||||
if at and is_admin:
|
||||
qid = at
|
||||
elif at and at != qid:
|
||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
||||
|
||||
uid = await select_db(qid, mode='uid')
|
||||
if uid is None or not isinstance(uid, str) or not uid.isdecimal():
|
||||
try:
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
except TypeError:
|
||||
await matcher.finish(UID_HINT)
|
||||
|
||||
im = await set_config_func(
|
||||
config_name=config_name,
|
||||
uid=uid,
|
||||
qid=str(qid),
|
||||
uid=uid, # type: ignore
|
||||
qid=qid, # type: ignore
|
||||
option=gid,
|
||||
query=query,
|
||||
is_admin=is_admin,
|
||||
|
@ -5,7 +5,7 @@ from ..utils.download_resource.RESOURCE_PATH import MAIN_PATH
|
||||
from ..utils.db_operation.db_operation import get_all_bind, get_user_bind_data
|
||||
|
||||
DATA_PATH = MAIN_PATH / 'v3_data.json'
|
||||
BOT_ID = 'onebot'
|
||||
BOT_ID = 'qqguild'
|
||||
RECOGNIZE_SERVER = {
|
||||
'1': 'cn_gf01',
|
||||
'2': 'cn_gf01',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import re
|
||||
import random
|
||||
import asyncio
|
||||
from typing import Tuple, Union
|
||||
from typing import Tuple
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
@ -9,20 +9,14 @@ from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
from .get_enka_img import draw_enka_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_char_rank import draw_cahrcard_list
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.enka_api.get_enka_data import switch_api
|
||||
from ..utils.enka_api.enka_to_card import enka_to_card
|
||||
from ..utils.enka_api.enka_to_data import enka_to_data
|
||||
@ -32,7 +26,7 @@ from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_operation import select_db, get_all_uid
|
||||
|
||||
refresh = on_command('强制刷新')
|
||||
original_pic = on_command('原图', rule=FullCommand())
|
||||
original_pic = on_command('原图')
|
||||
change_api = on_command('切换api')
|
||||
get_charcard_list = on_command('毕业度统计')
|
||||
get_char_info = on_command(
|
||||
@ -46,21 +40,9 @@ refresh_scheduler = scheduler
|
||||
|
||||
@change_api.handle()
|
||||
@handle_exception('切换api')
|
||||
@register_menu(
|
||||
'切换API',
|
||||
'切换api',
|
||||
'切换获取角色面板时使用的API',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'切换获取角色面板时使用的Enka Network API\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>切换api</ft>'
|
||||
),
|
||||
)
|
||||
async def send_change_api_info(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
@ -73,30 +55,18 @@ async def send_change_api_info(
|
||||
|
||||
@original_pic.handle()
|
||||
@handle_exception('原图')
|
||||
@register_menu(
|
||||
'查看面板原图',
|
||||
'原图',
|
||||
'查看角色面板中原随机图',
|
||||
trigger_method='回复+指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看开启随机图功能时角色面板中角色位置的原图,需要回复要查看原图的面板图片消息\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>原图</ft>'
|
||||
),
|
||||
)
|
||||
async def send_original_pic(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if event.reply:
|
||||
msg_id = event.reply.message_id
|
||||
ev = event.__dict__
|
||||
if 'message_reference' in ev:
|
||||
msg_id = ev['message_reference'].__dict__['message_id']
|
||||
path = TEMP_PATH / f'{msg_id}.jpg'
|
||||
if path.exists():
|
||||
logger.info('[原图]访问图片: {}'.format(path))
|
||||
with open(path, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
await matcher.finish(MessageSegment.file_image(f.read()))
|
||||
|
||||
|
||||
@get_char_info.handle()
|
||||
@ -106,48 +76,23 @@ async def send_original_pic(
|
||||
'查询(@某人)角色名',
|
||||
'查询你的或者指定人的已缓存展柜角色的面板',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(238,120,0)>角色名</ft>\n'
|
||||
' \n'
|
||||
'可以用来查看你的或者指定人的已缓存展柜角色的面板\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(0,148,200)>[角色名]</ft>\n'
|
||||
'后面可以跟 '
|
||||
'<ft color=(238,120,0)>换</ft>'
|
||||
'<ft color=(125,125,125)>(精{一|二|三|四|五})</ft>'
|
||||
'<ft color=(0,148,200)>[武器名]</ft> '
|
||||
'来更换展示的武器\n'
|
||||
'可以跟 '
|
||||
'<ft color=(125,125,125)>(成长)</ft><ft color=(238,120,0)>曲线</ft> '
|
||||
'来查询该角色成长曲线\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>查询宵宫</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询绫华换精五雾切</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询一斗成长曲线</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>'
|
||||
'<ft color=(238,120,0)>查询宵宫</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft>'
|
||||
' <ft color=(238,120,0)>公子</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'查询展柜角色',
|
||||
'查询展柜角色',
|
||||
'查询插件已缓存的展柜角色列表',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询插件当前已缓存的展柜角色列表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>查询展柜角色</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
@ -156,15 +101,13 @@ async def send_char_info(
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
if not name:
|
||||
return
|
||||
|
||||
logger.info('开始执行[查询角色面板]')
|
||||
at = custom.get_first_at()
|
||||
img = custom.get_first_image()
|
||||
|
||||
if at:
|
||||
qid = at
|
||||
else:
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
||||
|
||||
# 获取uid
|
||||
@ -179,13 +122,17 @@ async def send_char_info(
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
|
||||
im = await draw_enka_img(raw_mes, uid, img)
|
||||
# 获取角色名
|
||||
msg = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
im = await draw_enka_img(msg, uid, img)
|
||||
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, Tuple):
|
||||
req = await matcher.send(MessageSegment.image(im[0]))
|
||||
msg_id = req['message_id']
|
||||
if isinstance(im[0], str):
|
||||
await matcher.finish(im[0])
|
||||
req = await matcher.send(MessageSegment.file_image(im[0]))
|
||||
msg_id = req.id
|
||||
if im[1]:
|
||||
with open(TEMP_PATH / f'{msg_id}.jpg', 'wb') as f:
|
||||
f.write(im[1])
|
||||
@ -245,14 +192,14 @@ async def daily_refresh_charData():
|
||||
async def send_card_info(
|
||||
bot: Bot,
|
||||
matcher: Matcher,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
args: Message = CommandArg(),
|
||||
event: MessageEvent,
|
||||
custom: ImageAndAt = Depends(),
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
uid = re.findall(r'\d+', message) # str
|
||||
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
qid = event.user_id
|
||||
qid = str(cast_to_int(event.author))
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
@ -273,13 +220,10 @@ async def send_card_info(
|
||||
if not uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
im = await enka_to_card(uid)
|
||||
|
||||
logger.info(f'UID{uid}获取角色数据成功!')
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
|
||||
|
||||
@get_charcard_list.handle()
|
||||
@ -301,13 +245,13 @@ async def send_card_info(
|
||||
),
|
||||
)
|
||||
async def send_charcard_list(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
qid = event.user_id
|
||||
qid = str(cast_to_int(event.author))
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
@ -320,10 +264,14 @@ async def send_charcard_list(
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
|
||||
im = await draw_cahrcard_list(str(uid), qid)
|
||||
if event.author and event.author.avatar:
|
||||
avatar = event.author.avatar
|
||||
else:
|
||||
avatar = '3399214199'
|
||||
|
||||
im = await draw_cahrcard_list(str(uid), avatar)
|
||||
|
||||
logger.info(f'UID{uid}获取角色数据成功!')
|
||||
if isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish(str(im))
|
||||
|
@ -5,7 +5,7 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
||||
|
||||
from ..version import Genshin_version
|
||||
from ..genshinuid_meta import register_menu
|
||||
@ -25,16 +25,15 @@ IMG_PATH = Path(__file__).parent / 'img_data'
|
||||
'版本规划(版本号)',
|
||||
'发送一张指定版本的原石规划图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>版本规划</ft>'
|
||||
'<ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
' \n'
|
||||
'发送一张指定版本的原石规划图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>版本规划</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
'- <ft color=(238,120,0)>原石预估</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>版本规划</ft>\n'
|
||||
'- <ft color=(238,120,0)>版本规划3.0</ft>'
|
||||
'<ft color=(238,120,0)>版本规划</ft>;\n'
|
||||
'<ft color=(238,120,0)>版本规划3.0</ft>'
|
||||
),
|
||||
)
|
||||
async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
||||
@ -49,62 +48,38 @@ async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
||||
else:
|
||||
img = f'{Genshin_version[:3]}.png'
|
||||
primogems_img = PRIMOGEMS_DATA_PATH / img
|
||||
if primogems_img.exists():
|
||||
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
||||
with open(primogems_img, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
else:
|
||||
await matcher.finish()
|
||||
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
||||
await matcher.finish(MessageSegment.file_image(primogems_img))
|
||||
|
||||
|
||||
@get_img_data.handle()
|
||||
@handle_exception('杂图')
|
||||
@register_menu(
|
||||
'伤害乘区图',
|
||||
'(查询)伤害乘区',
|
||||
'伤害乘区',
|
||||
'发送一张理论伤害计算公式图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张理论伤害计算公式图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>伤害乘区</ft>'
|
||||
'指令:' '<ft color=(238,120,0)>伤害乘区</ft>\n' ' \n' '发送一张理论伤害计算公式图'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物血量表',
|
||||
'(查询)血量表',
|
||||
'血量表',
|
||||
'发送一张原神怪物血量表图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物血量表图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量表</ft>'
|
||||
),
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>血量表</ft>\n' ' \n' '发送一张原神怪物血量表图'),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物抗性表',
|
||||
'(查询)抗性表',
|
||||
'抗性表',
|
||||
'发送一张原神怪物抗性表图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物抗性表图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>抗性表</ft>'
|
||||
),
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>抗性表</ft>\n' ' \n' '发送一张原神怪物抗性表图'),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物血量排行',
|
||||
'(查询)血量排行',
|
||||
'血量排行',
|
||||
'发送一张原神怪物血量排行图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物血量排行图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量排行</ft>'
|
||||
'指令:' '<ft color=(238,120,0)>血量排行</ft>\n' ' \n' '发送一张原神怪物血量排行图'
|
||||
),
|
||||
)
|
||||
async def send_img_data(
|
||||
@ -114,5 +89,4 @@ async def send_img_data(
|
||||
logger.info('[图片][杂图]参数: {}'.format(args))
|
||||
img = IMG_PATH / f'{args[1]}.jpg'
|
||||
if img.exists():
|
||||
with open(img, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
@ -1,16 +1,14 @@
|
||||
from nonebot import on_command
|
||||
from nonebot import on_regex
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_event_img import get_event_img, get_all_event_img
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_event = on_command('活动列表', priority=priority, rule=FullCommand())
|
||||
get_gacha = on_command('卡池列表', priority=priority, rule=FullCommand())
|
||||
get_event = on_regex(r'^活动列表$')
|
||||
get_gacha = on_regex(r'^卡池列表$')
|
||||
|
||||
|
||||
@scheduler.scheduled_job('cron', hour='2')
|
||||
@ -24,33 +22,21 @@ async def draw_event():
|
||||
'活动列表',
|
||||
'活动列表',
|
||||
'查询当前版本活动日程表',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询当前版本活动日程表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>活动列表</ft>'
|
||||
),
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>活动列表</ft>\n' ' \n' '查询当前版本活动日程表'),
|
||||
)
|
||||
async def send_events(matcher: Matcher):
|
||||
img = await get_event_img('EVENT')
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
||||
|
||||
@get_gacha.handle()
|
||||
@handle_exception('活动')
|
||||
@handle_exception('卡池')
|
||||
@register_menu(
|
||||
'卡池列表',
|
||||
'卡池列表',
|
||||
'查询当前版本卡池列表',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询当前版本卡池列表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>卡池列表</ft>'
|
||||
),
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>卡池列表</ft>\n' ' \n' '查询当前版本卡池列表'),
|
||||
)
|
||||
async def send_gachas(matcher: Matcher):
|
||||
img = await get_event_img('GACHA')
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
@ -1,20 +1,14 @@
|
||||
from typing import Union
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_notice, on_command
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
NoticeEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
|
||||
from .get_gachalogs import save_gachalogs
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_gachalogs import draw_gachalogs_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .export_and_import import export_gachalogs, import_gachalogs
|
||||
@ -27,26 +21,14 @@ export_gacha_log = on_command('导出抽卡记录', rule=FullCommand())
|
||||
|
||||
@export_gacha_log.handle()
|
||||
@handle_exception('导出抽卡记录')
|
||||
@register_menu(
|
||||
'导出抽卡记录',
|
||||
'导出抽卡记录',
|
||||
'导出符合UIGF规范的抽卡记录',
|
||||
trigger_method='群聊指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'导出UIGF格式规范的json格式抽卡记录上传到群文件\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>导出抽卡记录</ft>'
|
||||
),
|
||||
)
|
||||
async def export_gacha_log_info(
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
|
||||
logger.info('开始执行[导出抽卡记录]')
|
||||
qid = event.user_id
|
||||
gid = event.group_id
|
||||
qid = str(str(cast_to_int(event.author)))
|
||||
gid = event.channel_id
|
||||
uid = await select_db(qid, mode='uid')
|
||||
bot = get_bot()
|
||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||
@ -68,20 +50,7 @@ async def export_gacha_log_info(
|
||||
|
||||
@import_gacha_log.handle()
|
||||
@handle_exception('导入抽卡记录')
|
||||
@register_menu(
|
||||
'导入抽卡记录',
|
||||
'json格式文件',
|
||||
'导入符合UIGF规范的抽卡记录',
|
||||
trigger_method='私聊离线文件',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'导入UIGF格式规范的json格式抽卡记录到插件本地缓存\n'
|
||||
' \n'
|
||||
'触发方式:\n'
|
||||
'- <ft color=(238,120,0)>私聊发送json格式的离线文件</ft>'
|
||||
),
|
||||
)
|
||||
async def import_gacha_log_info(event: NoticeEvent, matcher: Matcher):
|
||||
async def import_gacha_log_info(event: MessageEvent, matcher: Matcher):
|
||||
args = event.dict()
|
||||
if args['notice_type'] != 'offline_file':
|
||||
await matcher.finish()
|
||||
@ -105,25 +74,28 @@ async def import_gacha_log_info(event: NoticeEvent, matcher: Matcher):
|
||||
'抽卡记录',
|
||||
'查询你的原神抽卡记录',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询你的原神抽卡记录\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>抽卡记录</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'<ft color=(238,120,0)>抽卡记录</ft>'
|
||||
'查询你的原神抽卡记录\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
||||
),
|
||||
)
|
||||
async def send_gacha_log_card_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[抽卡记录]')
|
||||
|
||||
uid = await select_db(event.user_id, mode='uid')
|
||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
||||
if event.author and event.author.avatar:
|
||||
avatar = event.author.avatar
|
||||
else:
|
||||
avatar = '3399214199'
|
||||
if isinstance(uid, str):
|
||||
im = await draw_gachalogs_img(uid, event.user_id)
|
||||
im = await draw_gachalogs_img(uid, avatar) # type: ignore
|
||||
if isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
@ -137,23 +109,22 @@ async def send_gacha_log_card_info(
|
||||
'刷新抽卡记录',
|
||||
'刷新你的原神抽卡记录本地缓存',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'刷新你的原神抽卡记录本地缓存\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>刷新抽卡记录</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>刷新抽卡记录</ft>'
|
||||
'刷新你的原神抽卡记录本地缓存\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
||||
),
|
||||
)
|
||||
async def send_daily_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[刷新抽卡记录]')
|
||||
uid = await select_db(event.user_id, mode='uid')
|
||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
||||
if isinstance(uid, str):
|
||||
is_force = False
|
||||
if event.raw_message.startswith('强制'):
|
||||
if event.content and event.content.startswith('强制'):
|
||||
is_force = True
|
||||
im = await save_gachalogs(uid, None, is_force)
|
||||
await matcher.finish(im)
|
||||
|
@ -1,43 +0,0 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
|
||||
|
||||
from .gacha_url import post_url
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_gacha_url = on_command(
|
||||
'获取抽卡记录链接', aliases={'抽卡链接', '抽卡记录链接'}, rule=FullCommand()
|
||||
)
|
||||
|
||||
|
||||
@get_gacha_url.handle()
|
||||
@handle_exception('获取抽卡记录链接')
|
||||
@register_menu(
|
||||
'获取抽卡记录链接',
|
||||
'获取抽卡记录链接',
|
||||
'获取用户的抽卡记录链接',
|
||||
trigger_method='群聊指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'导出抽卡记录的链接以用于原神小程序\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>抽卡链接</ft>'
|
||||
),
|
||||
)
|
||||
async def _(
|
||||
bot: Bot,
|
||||
event: GroupMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
await get_gacha_url.send("正在获取抽卡记录链接")
|
||||
logger.info('开始执行[获取抽卡记录链接]')
|
||||
uid = await select_db(event.user_id, mode='uid')
|
||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
await post_url(bot, uid, str(event.group_id), str(event.user_id))
|
@ -1,53 +0,0 @@
|
||||
import time
|
||||
from urllib.parse import quote
|
||||
|
||||
from nonebot.adapters.onebot.v11 import Bot
|
||||
|
||||
from ..utils.message.error_reply import SK_HINT
|
||||
from ..utils.message.send_msg import send_forward_msg
|
||||
from ..utils.mhy_api.get_mhy_data import get_authkey_by_cookie
|
||||
|
||||
|
||||
async def post_url(bot: Bot, uid: str, group_id: str, qid: str):
|
||||
async def send_group_msg(msg: str):
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=group_id,
|
||||
message=msg,
|
||||
)
|
||||
return ''
|
||||
|
||||
authkey = await get_authkey_by_cookie(uid)
|
||||
if authkey == {}:
|
||||
return await send_group_msg(SK_HINT)
|
||||
authkey = authkey['data']['authkey']
|
||||
now = time.time()
|
||||
region = ""
|
||||
if uid[0] == "1" or uid[0] == "2":
|
||||
region = 'cn_gf01'
|
||||
elif uid[0] == "5":
|
||||
region = "'cn_qd01'"
|
||||
elif uid[0] == "6":
|
||||
region = "'os_usa'"
|
||||
elif uid[0] == "7":
|
||||
region = "'os_euro'"
|
||||
elif uid[0] == "8":
|
||||
region = "'os_asia'"
|
||||
elif uid[0] == "9":
|
||||
region = "'os_cht'"
|
||||
else:
|
||||
region = 'cn_gf01'
|
||||
msgs = []
|
||||
msgs.append(f"uid:{uid}的抽卡记录链接为:")
|
||||
url = (
|
||||
f"https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?"
|
||||
f"authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&"
|
||||
f"gacha_id=fecafa7b6560db5f3182222395d88aaa6aaac1bc"
|
||||
f"×tamp={str(int(now))}"
|
||||
f"&lang=zh-cn&device_type=mobile&plat_type=ios®ion={region}"
|
||||
f"&authkey={quote(authkey,'utf-8')}"
|
||||
f"&game_biz=hk4e_cn&gacha_type=301&page=1&size=5&end_id=0"
|
||||
)
|
||||
msgs.append(url)
|
||||
await send_forward_msg(bot, group_id, "抽卡链接", qid, msgs)
|
||||
return "成功执行"
|
@ -4,10 +4,11 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
from .draw_gcginfo import draw_gcg_info
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||
@ -32,10 +33,9 @@ async def send_gcg_pic(
|
||||
at = custom.get_first_at()
|
||||
logger.info('开始执行[七圣召唤]')
|
||||
|
||||
if at:
|
||||
qid = at
|
||||
else:
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
||||
|
||||
# 获取uid
|
||||
@ -55,6 +55,6 @@ async def send_gcg_pic(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -7,12 +7,7 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
||||
|
||||
from .get_card import get_gs_card
|
||||
from .get_guide import get_gs_guide
|
||||
@ -27,7 +22,6 @@ get_bluekun_pic = on_command('参考面板')
|
||||
get_card = on_command('原牌')
|
||||
get_abyss = on_command('版本深渊')
|
||||
|
||||
|
||||
IMG_PATH = Path(__file__).parent / 'img'
|
||||
|
||||
|
||||
@ -38,17 +32,15 @@ IMG_PATH = Path(__file__).parent / 'img'
|
||||
'xx攻略',
|
||||
'发送一张对应角色的西风驿站攻略图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>角色名[推荐/攻略]</ft>\n'
|
||||
' \n'
|
||||
'发送一张对应角色的米游社西风驿站攻略图\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||
'<ft color=(238,120,0)>{推荐|攻略}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>钟离推荐</ft>\n'
|
||||
'- <ft color=(238,120,0)>公子攻略</ft>'
|
||||
'<ft color=(238,120,0)>钟离推荐</ft>;\n'
|
||||
'<ft color=(238,120,0)>公子攻略</ft>'
|
||||
),
|
||||
)
|
||||
async def send_guide_pic(
|
||||
@ -60,7 +52,8 @@ async def send_guide_pic(
|
||||
im = await get_gs_guide(name)
|
||||
if im:
|
||||
logger.info('获得{}攻略成功!'.format(name))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
print('gg')
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
logger.warning('未找到{}攻略图片'.format(name))
|
||||
|
||||
@ -72,17 +65,15 @@ async def send_guide_pic(
|
||||
'参考面板[角色名/元素名]',
|
||||
'发送一张对应角色/元素的参考面板图',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>参考面板[角色名/元素名]</ft>\n'
|
||||
' \n'
|
||||
'发送一张对应角色/元素的参考面板图\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>参考面板</ft>'
|
||||
'<ft color=(0,148,200)>[角色名/元素名]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>参考面板火</ft>\n'
|
||||
'- <ft color=(238,120,0)>参考面板公子</ft>'
|
||||
'<ft color=(238,120,0)>参考面板火</ft>;\n'
|
||||
'<ft color=(238,120,0)>参考面板公子</ft>'
|
||||
),
|
||||
)
|
||||
async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
@ -92,10 +83,8 @@ async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
name = await alias_to_char_name(str(args[0]))
|
||||
img = IMG_PATH / '{}.jpg'.format(name)
|
||||
if img.exists():
|
||||
with open(img, 'rb') as f:
|
||||
im = MessageSegment.image(f.read())
|
||||
logger.info('获得{}参考面板图片成功!'.format(name))
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
else:
|
||||
logger.warning('未找到{}参考面板图片'.format(name))
|
||||
|
||||
@ -109,16 +98,14 @@ async def send_gscard_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
im = await get_gs_card(name)
|
||||
if im:
|
||||
logger.info('获得{}原牌成功!'.format(name))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
logger.warning('未找到{}原牌图片'.format(name))
|
||||
|
||||
|
||||
@get_abyss.handle()
|
||||
@handle_exception('原牌')
|
||||
@handle_exception('版本深渊')
|
||||
async def send_abyss_review(
|
||||
bot: Bot,
|
||||
event: GroupMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
@ -128,26 +115,12 @@ async def send_abyss_review(
|
||||
version = str(args[0])
|
||||
im = await get_review(version)
|
||||
if isinstance(im, List):
|
||||
mes = []
|
||||
for msg in im:
|
||||
mes.append(
|
||||
{
|
||||
'type': 'node',
|
||||
'data': {
|
||||
'name': '小仙',
|
||||
'uin': '3399214199',
|
||||
'content': msg,
|
||||
},
|
||||
}
|
||||
)
|
||||
await bot.call_api(
|
||||
'send_group_forward_msg', group_id=event.group_id, messages=mes
|
||||
)
|
||||
await matcher.finish()
|
||||
im = '\n'.join(im)
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
139
GenshinUID/genshinuid_guild/__init__.py
Normal file
139
GenshinUID/genshinuid_guild/__init__.py
Normal file
@ -0,0 +1,139 @@
|
||||
import asyncio
|
||||
from typing import List
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.message import event_preprocessor
|
||||
from nonebot.adapters.qqguild.message import Text
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
from nonebot.adapters.qqguild.api.model import DMS, Guild, MessageMarkdown
|
||||
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
_md = '''## 这是一个自定义MD文本
|
||||
'''
|
||||
|
||||
guild_detail = on_command('频道统计', block=True, rule=FullCommand())
|
||||
get_dirct_msg = on_command(
|
||||
'给我发消息',
|
||||
aliases={'给我发私信', '给我发短信', '给我发信息'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
get_markdown_msg = on_command(
|
||||
'给我发md',
|
||||
aliases={'给我发markdown'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
|
||||
|
||||
@get_markdown_msg.handle()
|
||||
@handle_exception('发md')
|
||||
async def send_markdown_msg(bot: Bot, event: MessageEvent, matcher: Matcher):
|
||||
if not event.author:
|
||||
return
|
||||
|
||||
await bot.call_api(
|
||||
'post_markdown_message',
|
||||
channel_id=str(event.channel_id),
|
||||
content=_md,
|
||||
)
|
||||
|
||||
await matcher.finish('已发送消息!')
|
||||
|
||||
|
||||
@get_dirct_msg.handle()
|
||||
@handle_exception('发私信')
|
||||
async def send_dirct_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not event.author:
|
||||
return
|
||||
|
||||
dms: DMS = await bot.call_api(
|
||||
'post_dms',
|
||||
recipient_id=str(event.author.id),
|
||||
source_guild_id=str(event.guild_id),
|
||||
)
|
||||
|
||||
await bot.call_api(
|
||||
'post_dms_messages',
|
||||
guild_id=dms.guild_id,
|
||||
content='一条消息!',
|
||||
)
|
||||
|
||||
await matcher.finish('已发送消息!')
|
||||
|
||||
|
||||
@event_preprocessor
|
||||
async def _(event: MessageEvent):
|
||||
msg = event.get_message().extract_content()
|
||||
msg = msg.replace(' ', '').replace('/', '')
|
||||
r_msg = None
|
||||
new_msg = []
|
||||
for i in event._message: # type: ignore
|
||||
if isinstance(i, Text):
|
||||
i.data['text'] = msg
|
||||
if '毕业都统计' in i.data['text']:
|
||||
i.data['text'].replace('都', '度')
|
||||
|
||||
if r_msg:
|
||||
new_msg.insert(0, r_msg)
|
||||
event._message = new_msg
|
||||
|
||||
if event.content:
|
||||
event.content = event.content.replace(' ', '').replace('/', '')
|
||||
|
||||
|
||||
@guild_detail.handle()
|
||||
@handle_exception('频道统计')
|
||||
async def send_create_map_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.info('[频道统计]正在执行...')
|
||||
await matcher.send('频道统计正在执行...可能需要较长时间!')
|
||||
|
||||
# 初始化最后的计数
|
||||
ALL_MEMBER = 0
|
||||
HIDE = 0
|
||||
|
||||
# 开始分页
|
||||
after = None
|
||||
# 初始化频道列表
|
||||
guild_list = []
|
||||
# 开始循环
|
||||
while True:
|
||||
# 本次获取的频道列表
|
||||
new_guild_list: List[Guild] = await bot.call_api(
|
||||
'guilds', before=None, after=after, limit=None
|
||||
)
|
||||
# 遍历频道列表
|
||||
for guild in new_guild_list:
|
||||
# 如果该频道人数展示
|
||||
if guild.member_count:
|
||||
# 总人数加上该频道的人数
|
||||
ALL_MEMBER += guild.member_count
|
||||
else:
|
||||
HIDE += 1
|
||||
logger.info(f'频道{guild.id}隐藏频道人数信息,已跳过计算...')
|
||||
# 重新设定拉取值
|
||||
after = guild.id
|
||||
# 把本次拉取的频道列表 合并到总频道列表
|
||||
guild_list.extend(new_guild_list)
|
||||
logger.info(f'当前页gid={after}')
|
||||
# 如果已经拉取不到频道了,就退出循环
|
||||
if new_guild_list == []:
|
||||
break
|
||||
await asyncio.sleep(0.5)
|
||||
im = f'当前Bot加入频道数{len(guild_list)}\n总人数为{ALL_MEMBER}\n隐藏人数频道数量{HIDE}!'
|
||||
await matcher.finish(im)
|
@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
|
||||
from .draw_help_card import draw_help_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
@ -22,15 +22,12 @@ HELP_IMG = Path(__file__).parent / 'help.png'
|
||||
'插件帮助',
|
||||
'gs帮助',
|
||||
'查看插件功能帮助图',
|
||||
detail_des=(
|
||||
'介绍:\n' '查看插件功能帮助图\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs帮助</ft>'
|
||||
),
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>gs帮助</ft>\n' ' \n' '查看插件功能帮助图'),
|
||||
)
|
||||
async def send_guide_pic(matcher: Matcher):
|
||||
logger.info('获得gs帮助图片成功!')
|
||||
if HELP_IMG.exists():
|
||||
with open(HELP_IMG, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
await matcher.finish(MessageSegment.file_image(HELP_IMG))
|
||||
else:
|
||||
await matcher.finish('帮助图不存在!')
|
||||
|
||||
|
@ -129,7 +129,6 @@ async def send_find_map_msg(
|
||||
logger.info('本地未缓存,正在渲染...')
|
||||
im = await draw_genshin_map(name, map_id, map_name)
|
||||
if isinstance(im, str):
|
||||
# 如果无结果,直接不返回
|
||||
await matcher.finish()
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
|
@ -12,17 +12,8 @@ __plugin_meta__ = PluginMetadata(
|
||||
'<ft color=(0,148,200)>[序号]</ft> '
|
||||
'指令获取某功能详细介绍\n'
|
||||
' \n'
|
||||
'菜单描述中的指令:\n'
|
||||
'<ft color=(0,148,200)>[中括号及其中的内容]</ft>,'
|
||||
'或<ft color=(0,148,200)>用“xx”代表的内容</ft> '
|
||||
'为<ft color=(238,120,0)>必选</ft>的参数,'
|
||||
'请将它们替换为适当的值;\n'
|
||||
'<ft color=(125,125,125)>(小括号及其中的内容)</ft> '
|
||||
'为<ft color=(238,120,0)>可选</ft>参数,'
|
||||
'可以省略;\n'
|
||||
'<ft color=(238,120,0)>{大括号及其中的内容}</ft> '
|
||||
'为<ft color=(238,120,0)>选择其一</ft>参数,'
|
||||
'请将它们替换为用 <ft color=(238,120,0)>|</ft> 分割后括号中内容的其中一个值'
|
||||
'示例指令小括号中的内容为可选参数,可以省略;\n'
|
||||
'中括号中的内容或者用“xx”代表的内容为必选参数,请将它们替换为对应的参数'
|
||||
),
|
||||
extra={'menu_data': sub_menus, 'menu_template': 'default'},
|
||||
)
|
||||
|
@ -6,12 +6,10 @@ from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..config import SUPERUSERS, priority
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.nonebot2.utils import get_superusers
|
||||
from ..utils.db_operation.db_operation import config_check
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .daily_mihoyo_bbs_coin import mihoyo_coin, all_daily_mihoyo_bbs_coin
|
||||
@ -27,39 +25,15 @@ all_bbscoin_recheck = on_command(
|
||||
# 获取米游币
|
||||
@get_mihoyo_coin.handle()
|
||||
@handle_exception('获取米游币')
|
||||
@register_menu(
|
||||
'手动获取米游币',
|
||||
'开始获取米游币',
|
||||
'手动触发米游社米游币任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动触发米游社获取米游币的任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>开始获取米游币</ft>'
|
||||
),
|
||||
)
|
||||
async def send_mihoyo_coin(event: MessageEvent, matcher: Matcher):
|
||||
await matcher.send('开始操作……', at_sender=True)
|
||||
qid = event.user_id
|
||||
qid = int(event.sender.user_id) # type: ignore
|
||||
im = await mihoyo_coin(qid)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
|
||||
|
||||
@all_bbscoin_recheck.handle()
|
||||
@handle_exception('米游币全部重获取')
|
||||
@register_menu(
|
||||
'重新获取米游币',
|
||||
'全部重获取',
|
||||
'重新运行所有自动获取米游币的任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'重新运行所有自动获取米游币的任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>全部重获取</ft>'
|
||||
),
|
||||
)
|
||||
async def bbs_recheck(
|
||||
matcher: Matcher,
|
||||
):
|
||||
@ -85,7 +59,7 @@ async def send_daily_mihoyo_bbs_sign():
|
||||
)
|
||||
await asyncio.sleep(5 + random.randint(1, 3))
|
||||
if await config_check('PrivateReport'):
|
||||
for qid in get_superusers():
|
||||
for qid in SUPERUSERS:
|
||||
await bot.call_api(api='send_private_msg', user_id=qid, message=im)
|
||||
await asyncio.sleep(5 + random.randint(1, 3))
|
||||
logger.info('米游币获取已结束。')
|
||||
|
@ -5,19 +5,14 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
from .get_lots_data import get_lots_msg
|
||||
from .get_meme_card import get_meme_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from .get_mys_data import get_task_detail
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .get_mys_data import get_region_task, get_task_detail
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_task_adv = on_regex(
|
||||
@ -29,32 +24,15 @@ get_lots = on_command('御神签', priority=priority, rule=FullCommand())
|
||||
|
||||
@get_task_adv.handle()
|
||||
@handle_exception('任务攻略')
|
||||
@register_menu(
|
||||
'任务攻略',
|
||||
'任务xx',
|
||||
'查询某任务的攻略',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询指定任务或指定地区的攻略\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{原神任务|任务|任务详情|任务攻略}</ft>'
|
||||
'<ft color=(238,120,0)>{</ft>'
|
||||
'<ft color=(0,148,200)>[任务名]</ft>'
|
||||
'<ft color=(238,120,0)>|须弥|层岩|海岛}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>任务神樱大祓</ft>\n'
|
||||
'- <ft color=(238,120,0)>任务须弥</ft>'
|
||||
),
|
||||
)
|
||||
async def send_task_adv(
|
||||
bot: Bot,
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
):
|
||||
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
||||
pass
|
||||
'''
|
||||
im = await get_region_task(str(args[2]))
|
||||
for i in im:
|
||||
await bot.call_api(
|
||||
@ -62,6 +40,7 @@ async def send_task_adv(
|
||||
)
|
||||
await asyncio.sleep(1)
|
||||
await matcher.finish()
|
||||
'''
|
||||
else:
|
||||
im = await get_task_detail(str(args[2]))
|
||||
await matcher.finish(im)
|
||||
@ -69,36 +48,16 @@ async def send_task_adv(
|
||||
|
||||
@get_meme.handle()
|
||||
@handle_exception('抽表情')
|
||||
@register_menu(
|
||||
'抽表情',
|
||||
'抽表情',
|
||||
'随机发送一张札记角色表情',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'随机发送一张札记角色表情\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>抽表情</ft>'
|
||||
),
|
||||
)
|
||||
async def send_meme_card(matcher: Matcher):
|
||||
logger.info('开始执行[抽表情]')
|
||||
img = await get_meme_img()
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
|
||||
|
||||
@get_lots.handle()
|
||||
@handle_exception('御神签')
|
||||
@register_menu(
|
||||
'御神签',
|
||||
'御神签',
|
||||
'鸣神大社御神签',
|
||||
detail_des=(
|
||||
'介绍:\n' '抽一签鸣神大社御神签\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>御神签</ft>'
|
||||
),
|
||||
)
|
||||
async def send_lots_data(matcher: Matcher, event: MessageEvent):
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('开始执行[御神签]')
|
||||
im = await get_lots_msg(qid)
|
||||
await matcher.finish(im)
|
||||
|
@ -1,13 +1,13 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
|
||||
from .note_text import award
|
||||
from ..config import priority
|
||||
from .draw_note_card import draw_note_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -21,20 +21,13 @@ get_genshin_info = on_command(
|
||||
# 群聊内 每月统计 功能
|
||||
@monthly_data.handle()
|
||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||
@register_menu(
|
||||
'文字札记',
|
||||
'每月统计',
|
||||
'文字形式米游社札记',
|
||||
detail_des=(
|
||||
'介绍:\n' '文字形式米游社札记\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>每月统计</ft>'
|
||||
),
|
||||
)
|
||||
async def send_monthly_data(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = event.user_id
|
||||
uid = await select_db(qid, mode='uid')
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('[每月统计]QQ号: {}'.format(qid))
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
if isinstance(uid, str):
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
@ -47,26 +40,13 @@ async def send_monthly_data(
|
||||
# 群聊内 每月统计 功能
|
||||
@get_genshin_info.handle()
|
||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||
@register_menu(
|
||||
'图片札记',
|
||||
'当前信息',
|
||||
'图片形式米游社札记',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'图片形式米游社札记\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>当前信息</ft>\n'
|
||||
'- <ft color=(125,125,125)>(原石)</ft><ft color=(238,120,0)>札记</ft>\n'
|
||||
'- <ft color=(238,120,0)>zj</ft>'
|
||||
),
|
||||
)
|
||||
async def send_monthly_pic(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = event.user_id
|
||||
uid = await select_db(qid, mode='uid')
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('[原石札记]QQ号: {}'.format(qid))
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
if isinstance(uid, str):
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
@ -77,6 +57,6 @@ async def send_monthly_pic(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -1,23 +1,18 @@
|
||||
import asyncio
|
||||
from typing import Union
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.params import Depends
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
|
||||
from .notice import get_notice_list
|
||||
from .resin_text import get_resin_text
|
||||
from .draw_resin_card import get_resin_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -34,27 +29,15 @@ get_daily_info = on_command('当前状态', rule=FullCommand())
|
||||
|
||||
@get_daily_info.handle()
|
||||
@handle_exception('每日信息文字版')
|
||||
@register_menu(
|
||||
'文字实时便笺',
|
||||
'当前信息',
|
||||
'米游社实时便笺文字版',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'米游社实时便笺文字版\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>当前状态</ft>'
|
||||
),
|
||||
)
|
||||
async def send_daily_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[每日信息文字版]')
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
||||
@ -102,39 +85,23 @@ async def notice_job():
|
||||
|
||||
@get_resin_info.handle()
|
||||
@handle_exception('每日信息')
|
||||
@register_menu(
|
||||
'图片实时便笺',
|
||||
'每日',
|
||||
'图片形式米游社实时便笺',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'图片形式米游社实时便笺\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>每日</ft>\n'
|
||||
'- <ft color=(238,120,0)>mr</ft>\n'
|
||||
'- <ft color=(238,120,0)>状态</ft>\n'
|
||||
'- <ft color=(125,125,125)>(实时)</ft><ft color=(238,120,0)>便笺</ft>\n'
|
||||
'- <ft color=(238,120,0)>便签</ft>'
|
||||
),
|
||||
)
|
||||
async def send_uid_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[每日信息]')
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = event.user_id
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
logger.info('[每日信息]QQ号: {}'.format(qid))
|
||||
|
||||
qid = int(qid)
|
||||
im = await get_resin_img(qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -1,18 +1,12 @@
|
||||
import asyncio
|
||||
import threading
|
||||
from typing import Union
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.download_resource.download_all_resource import (
|
||||
@ -24,22 +18,9 @@ download_resource = on_command('下载全部资源', rule=FullCommand())
|
||||
|
||||
@download_resource.handle()
|
||||
@handle_exception('下载全部资源', '资源下载错误')
|
||||
@register_menu(
|
||||
'下载全部资源',
|
||||
'下载全部资源',
|
||||
'手动下载插件运行所需的资源',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动下载插件正常运行所需的资源(一般每次启动会自动检查并下载)\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>下载全部资源</ft>'
|
||||
),
|
||||
)
|
||||
async def send_download_resource_msg(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
|
@ -1,22 +1,16 @@
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
|
||||
from .get_regtime import calc_reg_time
|
||||
from .draw_roleinfo_card import draw_pic
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -29,31 +23,8 @@ get_reg_time = on_command(
|
||||
|
||||
@get_role_info.handle()
|
||||
@handle_exception('查询角色信息')
|
||||
@register_menu(
|
||||
'查询帐号信息',
|
||||
'查询',
|
||||
'帐号基础数据与角色信息总览',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询帐号探索度、声望、宝箱收集、角色总览等等基础数据\n'
|
||||
'未绑定CK时最多只能查询8个角色信息\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询|uid}</ft>'
|
||||
'<ft color=(125,125,125)>({@某人|[UID]})</ft>\n'
|
||||
'- <ft color=(238,120,0)>mys</ft>'
|
||||
'<ft color=(125,125,125)>({@某人|[米游社ID]})</ft>\n'
|
||||
'- <ft color=(238,120,0)>直接发送九位数UID</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>查询</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789</ft>\n'
|
||||
'- <ft color=(238,120,0)>123456789</ft>'
|
||||
),
|
||||
)
|
||||
async def send_role_info(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
@ -62,10 +33,12 @@ async def send_role_info(
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
if name:
|
||||
return
|
||||
qid = event.user_id
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = str(qid)
|
||||
|
||||
# 获取uid
|
||||
uid = re.findall(r'\d+', raw_mes)
|
||||
@ -74,8 +47,8 @@ async def send_role_info(
|
||||
else:
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
|
||||
logger.info('开始执行[查询角色信息]')
|
||||
|
||||
logger.info('[查询角色信息]参数: {}'.format(args))
|
||||
logger.info('[查询角色信息]uid: {}'.format(uid))
|
||||
|
||||
@ -87,21 +60,22 @@ async def send_role_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@get_reg_time.handle()
|
||||
async def regtime(
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
qid = event.user_id
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = str(qid)
|
||||
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
|
@ -5,7 +5,8 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
|
||||
from ..config import priority
|
||||
|
||||
@ -14,10 +15,8 @@ try:
|
||||
except ImportError:
|
||||
from .sign import sign_in, daily_sign
|
||||
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_operation import select_db, config_check
|
||||
|
||||
@ -39,26 +38,14 @@ async def sign_at_night():
|
||||
# 群聊内 签到 功能
|
||||
@get_sign.handle()
|
||||
@handle_exception('签到')
|
||||
@register_menu(
|
||||
'手动米游社原神签到',
|
||||
'签到',
|
||||
'手动触发米游社原神签到任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动触发米游社原神签到任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>签到</ft>'
|
||||
),
|
||||
)
|
||||
async def get_sign_func(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[签到]')
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('[签到]QQ号: {}'.format(qid))
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
logger.info('[签到]UID: {}'.format(uid))
|
||||
im = await sign_in(uid)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
@ -66,18 +53,6 @@ async def get_sign_func(
|
||||
|
||||
@all_recheck.handle()
|
||||
@handle_exception('全部重签')
|
||||
@register_menu(
|
||||
'米游社原神重签到',
|
||||
'全部重签',
|
||||
'重新运行所有自动米游社原神签到任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'重新运行所有自动米游社原神签到任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>全部重签</ft>'
|
||||
),
|
||||
)
|
||||
async def recheck(matcher: Matcher):
|
||||
logger.info('开始执行[全部重签]')
|
||||
await matcher.send('已开始执行')
|
||||
|
@ -4,26 +4,22 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot import get_bot, on_regex, get_driver, on_command
|
||||
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, MessageSegment
|
||||
from nonebot import get_bot, on_regex, get_driver
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_update_log import draw_update_log_img
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from .restart import restart_message, restart_genshinuid
|
||||
|
||||
gs_restart = on_command('gs重启', rule=FullCommand())
|
||||
get_update_log = on_command('更新记录', rule=FullCommand())
|
||||
gs_restart = on_regex(r'^(gs)(重启)$')
|
||||
get_update_log = on_regex(r'更新记录')
|
||||
gs_update = on_regex(
|
||||
r'^(gs)(强行)?(强制)?(更新)$',
|
||||
block=True,
|
||||
)
|
||||
|
||||
|
||||
driver = get_driver()
|
||||
|
||||
|
||||
@driver.on_bot_connect
|
||||
@get_driver().on_bot_connect
|
||||
async def _():
|
||||
logger.info('检查遗留信息...')
|
||||
bot = get_bot()
|
||||
@ -45,42 +41,7 @@ async def _():
|
||||
logger.info('遗留信息检查完毕!')
|
||||
|
||||
|
||||
@get_update_log.handle()
|
||||
@register_menu(
|
||||
'更新记录',
|
||||
'更新记录',
|
||||
'查看插件最近的更新记录',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看插件最近的有效Git更新记录\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>更新记录</ft>'
|
||||
),
|
||||
)
|
||||
async def send_updatelog_msg(
|
||||
matcher: Matcher,
|
||||
):
|
||||
im = await draw_update_log_img(is_update=False)
|
||||
logger.info('正在执行[更新记录]...')
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@gs_restart.handle()
|
||||
@register_menu(
|
||||
'重启Bot',
|
||||
'gs重启',
|
||||
'重启Bot框架',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n' '重启Bot框架\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs重启</ft>'
|
||||
),
|
||||
)
|
||||
async def send_restart_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
@ -89,34 +50,27 @@ async def send_restart_msg(
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.warning('开始执行[重启]')
|
||||
qid = event.user_id
|
||||
if len(event.get_session_id().split('_')) == 3:
|
||||
send_id = event.get_session_id().split('_')[1]
|
||||
send_type = 'group'
|
||||
else:
|
||||
send_id = qid
|
||||
send_type = 'private'
|
||||
send_id = cast_to_int(event.author)
|
||||
send_type = 'group'
|
||||
await matcher.send('正在执行[gs重启]...')
|
||||
await restart_genshinuid(send_type, str(send_id))
|
||||
|
||||
|
||||
@get_update_log.handle()
|
||||
async def send_updatelog_msg(
|
||||
matcher: Matcher,
|
||||
):
|
||||
im = await draw_update_log_img(is_update=False)
|
||||
logger.info('正在执行[更新记录]...')
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@gs_update.handle()
|
||||
@register_menu(
|
||||
'更新插件',
|
||||
'gs更新',
|
||||
'手动更新插件',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动更新插件(执行 git pull)\n'
|
||||
'每加上一个可选参数,执行等级加1\n'
|
||||
'当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs</ft>'
|
||||
'<ft color=(125,125,125)>(强行)(强制)</ft>'
|
||||
'<ft color=(238,120,0)>更新</ft>'
|
||||
),
|
||||
)
|
||||
async def send_update_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
@ -138,6 +92,6 @@ async def send_update_msg(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from typing import Any, Tuple
|
||||
|
||||
from nonebot.log import logger
|
||||
@ -5,27 +6,20 @@ from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
PRIVATE_FRIEND,
|
||||
Bot,
|
||||
Message,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
|
||||
from .topup import topup_
|
||||
from ..config import priority
|
||||
from .qrlogin import qrcode_login
|
||||
from ..utils.nonebot2.perm import DIRECT
|
||||
from .get_ck_help_msg import get_ck_help
|
||||
from .draw_user_card import get_user_card
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .add_ck import deal_ck, get_ck_by_stoken, get_ck_by_all_stoken
|
||||
from ..utils.db_operation.db_operation import bind_db, delete_db, switch_db
|
||||
|
||||
add_cookie = on_command('添加', permission=PRIVATE_FRIEND)
|
||||
add_cookie = on_command('添加', permission=DIRECT)
|
||||
get_ck_msg = on_command(
|
||||
'绑定ck说明',
|
||||
aliases={'ck帮助', '绑定ck'},
|
||||
@ -56,21 +50,9 @@ bind = on_regex(
|
||||
get_qrcode_login = on_command(
|
||||
'扫码登录',
|
||||
aliases={'扫码登陆', '扫码登入'},
|
||||
permission=DIRECT,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
get_topup = on_command('gsrc', priority=priority, block=True, aliases={'原神充值'})
|
||||
|
||||
|
||||
@get_topup.handle()
|
||||
async def send_topup(bot: Bot, event: GroupMessageEvent):
|
||||
qid = event.user_id
|
||||
goods_id = event.raw_message.replace('原神充值', '').replace('gsrc', '')
|
||||
if goods_id == "":
|
||||
goods_id = 0
|
||||
else:
|
||||
goods_id = int(goods_id)
|
||||
group_id = event.group_id
|
||||
await topup_(bot, qid, group_id, goods_id)
|
||||
|
||||
|
||||
@refresh_all_ck.handle()
|
||||
@ -90,135 +72,70 @@ async def send_refresh_ck_msg(
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[刷新CK]')
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
im = await get_ck_by_stoken(qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
|
||||
|
||||
@get_qrcode_login.handle()
|
||||
async def send_qrcode_login(
|
||||
bot: Bot,
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[扫码登陆]')
|
||||
qid = event.user_id
|
||||
groupid = event.group_id
|
||||
im = await qrcode_login(bot, groupid, qid)
|
||||
qid = cast_to_int(event.author)
|
||||
im = await qrcode_login(matcher, qid)
|
||||
if not im:
|
||||
return
|
||||
im = await deal_ck(im, qid)
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
|
||||
|
||||
@bind_info.handle()
|
||||
@register_menu(
|
||||
'绑定状态',
|
||||
'绑定信息',
|
||||
'查询你绑定UID的绑定和推送状态',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询你绑定的UID列表以及它们的CK、SK绑定状态和推送设置\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>绑定信息</ft>'
|
||||
),
|
||||
)
|
||||
async def send_bind_card(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[查询用户绑定状态]')
|
||||
qid = event.user_id
|
||||
im = await get_user_card(qid)
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
im = await get_user_card(str(qid))
|
||||
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
|
||||
|
||||
@add_cookie.handle()
|
||||
@handle_exception('Cookie', '校验失败!请输入正确的Cookies!')
|
||||
@register_menu(
|
||||
'绑定CK、SK',
|
||||
'添加[CK或SK]',
|
||||
'绑定你的Cookies以及Stoken',
|
||||
trigger_method='好友私聊指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'绑定你的Cookies以及Stoken\n'
|
||||
'Cookies (CK):米游社Cookies;Stoken (SK):米哈游通行证Cookies\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>添加</ft><ft color=(0,148,200)>[CK或SK]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_add_ck_msg(
|
||||
event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
|
||||
):
|
||||
mes = args.extract_plain_text().strip().replace(' ', '')
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
qid = str(qid)
|
||||
im = await deal_ck(mes, qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
|
||||
|
||||
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
||||
@bind.handle()
|
||||
@handle_exception('绑定ID', '绑定ID异常')
|
||||
@register_menu(
|
||||
'绑定UID',
|
||||
'绑定xx',
|
||||
'绑定原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'绑定原神UID或米游社UID\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>绑定'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'解绑UID',
|
||||
'解绑xx',
|
||||
'解绑原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'解绑原神UID或米游社UID\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{解绑|删除}'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'切换UID',
|
||||
'切换xx',
|
||||
'切换当前原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'切换当前原神UID或米游社UID\n'
|
||||
'绑定一个UID的情况下无法切换\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>切换'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
async def send_link_uid_msg(
|
||||
event: MessageEvent, matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
||||
):
|
||||
logger.info('开始执行[绑定/解绑用户信息]')
|
||||
logger.info('[绑定/解绑]参数: {}'.format(args))
|
||||
qid = event.user_id
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
||||
|
||||
if args[0] in ('绑定'):
|
||||
@ -226,30 +143,22 @@ async def send_link_uid_msg(
|
||||
await matcher.finish('请输入正确的uid或者mysid!')
|
||||
|
||||
if args[1] in ('uid', 'UID'):
|
||||
im = await bind_db(qid, args[2])
|
||||
im = await bind_db(str(qid), args[2])
|
||||
else:
|
||||
im = await bind_db(qid, None, args[2])
|
||||
im = await bind_db(str(qid), None, args[2])
|
||||
elif args[0] in ('切换'):
|
||||
im = await switch_db(qid, args[2])
|
||||
im = await switch_db(str(qid), args[2])
|
||||
else:
|
||||
if args[1] in ('uid', 'UID'):
|
||||
im = await delete_db(qid, {'UID': args[2]})
|
||||
im = await delete_db(str(qid), {'UID': args[2]})
|
||||
else:
|
||||
im = await delete_db(qid, {'MYSID': args[2]})
|
||||
im = await delete_db(str(qid), {'MYSID': args[2]})
|
||||
await matcher.finish(im, at_sender=True)
|
||||
|
||||
|
||||
@get_ck_msg.handle()
|
||||
async def send_ck_help(bot: Bot, event: GroupMessageEvent):
|
||||
async def send_ck_help(matcher: Matcher):
|
||||
msg_list = await get_ck_help()
|
||||
forward_msg = []
|
||||
for msg in msg_list:
|
||||
forward_msg.append(
|
||||
{
|
||||
"type": "node",
|
||||
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
||||
}
|
||||
)
|
||||
await bot.call_api(
|
||||
'send_group_forward_msg', group_id=event.group_id, messages=forward_msg
|
||||
)
|
||||
await matcher.send(msg)
|
||||
await asyncio.sleep(0.5)
|
||||
|
@ -29,7 +29,7 @@ gs_font_15 = genshin_font_origin(15)
|
||||
gs_font_26 = genshin_font_origin(26)
|
||||
|
||||
|
||||
async def get_user_card(qid: int) -> bytes:
|
||||
async def get_user_card(qid: str) -> bytes:
|
||||
uid_list: List = await select_db(qid, 'list') # type: ignore
|
||||
w, h = 500, len(uid_list) * 210 + 330
|
||||
img = await get_simple_bg(w, h)
|
||||
@ -38,7 +38,7 @@ async def get_user_card(qid: int) -> bytes:
|
||||
uid_title = Image.open(TEXT_PATH / 'uid_title.png')
|
||||
uid_title_draw = ImageDraw.Draw(uid_title)
|
||||
uid_title_draw.text(
|
||||
(47, 70), f'QQ号{str(qid)}', (106, 100, 89), font=gs_font_26
|
||||
(47, 70), f'频道ID {str(qid)}', (106, 100, 89), font=gs_font_26
|
||||
)
|
||||
img.paste(uid_title, (0, 50), uid_title)
|
||||
img.paste(uid_hint, (0, 145 + len(uid_list) * 210), uid_hint)
|
||||
|
@ -7,17 +7,15 @@ from typing import Any, Tuple, Union, Literal
|
||||
|
||||
import qrcode
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from qrcode.constants import ERROR_CORRECT_L
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
|
||||
from ..utils.message.send_msg import send_forward_msg
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.mhy_api.get_mhy_data import (
|
||||
check_qrcode,
|
||||
get_cookie_token,
|
||||
create_qrcode_url,
|
||||
get_mihoyo_bbs_info,
|
||||
get_stoken_by_game_token,
|
||||
get_cookie_token_by_stoken,
|
||||
)
|
||||
|
||||
disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
||||
@ -68,32 +66,17 @@ async def refresh(
|
||||
return True, json.loads(status_data['data']['payload']['raw'])
|
||||
|
||||
|
||||
async def qrcode_login(bot, group_id, user_id) -> str:
|
||||
async def send_group_msg(msg: str):
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=group_id,
|
||||
message=msg,
|
||||
)
|
||||
return ''
|
||||
|
||||
async def qrcode_login(matcher: Matcher, user_id) -> str:
|
||||
code_data = await create_qrcode_url()
|
||||
try:
|
||||
im = []
|
||||
im.append('请使用米游社扫描下方二维码登录:')
|
||||
im.append(
|
||||
f'[CQ:image,file=base64://{get_qrcode_base64(code_data["url"])}]'
|
||||
await matcher.send(
|
||||
MessageSegment.file_image(get_qrcode_base64(code_data["url"])) # type: ignore
|
||||
)
|
||||
im.append(
|
||||
'免责声明:您将通过扫码完成获取米游社sk以及ck。\n'
|
||||
'本Bot将不会保存您的登录状态。\n'
|
||||
'我方仅提供米游社查询及相关游戏内容服务,\n'
|
||||
'若您的账号封禁、被盗等处罚与我方无关。\n'
|
||||
'害怕风险请勿扫码~'
|
||||
)
|
||||
await send_forward_msg(bot, group_id, "扫码小助手", str(user_id), im)
|
||||
except Exception:
|
||||
logger.warning(f'[扫码登录] {user_id} 图片发送失败')
|
||||
await matcher.send('请绑定UID之后使用米游社扫描上方二维码登录')
|
||||
await matcher.send(disnote)
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
logger.warning('[扫码登录] {user_id} 图片发送失败')
|
||||
status, game_token_data = await refresh(code_data)
|
||||
if status:
|
||||
assert game_token_data is not None # 骗过 pyright
|
||||
@ -103,48 +86,15 @@ async def qrcode_login(bot, group_id, user_id) -> str:
|
||||
account_id=int(game_token_data['uid']),
|
||||
game_token=game_token_data['token'],
|
||||
)
|
||||
account_id = game_token_data['uid']
|
||||
stoken = stoken_data['data']['token']['token']
|
||||
mid = stoken_data['data']['user_info']['mid']
|
||||
app_cookie = f'stuid={account_id};stoken={stoken};mid={mid}'
|
||||
ck = await get_cookie_token_by_stoken(stoken, account_id, app_cookie)
|
||||
ck = ck['data']['cookie_token']
|
||||
cookie_check = f'account_id={account_id};cookie_token={ck}'
|
||||
get_uid = await get_mihoyo_bbs_info(account_id, cookie_check)
|
||||
# 剔除除了原神之外的其他游戏
|
||||
im = None
|
||||
if get_uid:
|
||||
for i in get_uid['data']['list']:
|
||||
if i['game_id'] == 2:
|
||||
uid_check = i['game_role_id']
|
||||
break
|
||||
else:
|
||||
im = f'你的米游社账号{account_id}尚未绑定原神账号,请前往米游社操作!'
|
||||
return await send_group_msg(im)
|
||||
else:
|
||||
im = '请求失败, 请稍后再试...'
|
||||
return await send_group_msg(im)
|
||||
|
||||
uid_bind = await select_db(user_id, mode='uid')
|
||||
# 没有在gsuid绑定uid的情况
|
||||
if uid_bind == "未找到绑定的UID~":
|
||||
logger.warning('game_token获取失败')
|
||||
im = '你还没有绑定uid,请输入[绑定uid123456]绑定你的uid,再发送[扫码登录]进行绑定'
|
||||
return await send_group_msg(im)
|
||||
# 比对gsuid数据库和扫码登陆获取到的uid
|
||||
if str(uid_bind) == uid_check or str(uid_bind) == account_id:
|
||||
return SimpleCookie(
|
||||
{
|
||||
'stoken_v2': stoken_data['data']['token']['token'],
|
||||
'stuid': stoken_data['data']['user_info']['aid'],
|
||||
'mid': stoken_data['data']['user_info']['mid'],
|
||||
'cookie_token': cookie_token['data']['cookie_token'],
|
||||
}
|
||||
).output(header='', sep=';')
|
||||
else:
|
||||
logger.warning('game_token获取失败')
|
||||
im = 'game_token获取失败:被非绑定指定uid用户扫取,取消绑定,请重新发送[扫码登录]登录账号'
|
||||
return SimpleCookie(
|
||||
{
|
||||
'stoken_v2': stoken_data['data']['token']['token'],
|
||||
'stuid': stoken_data['data']['user_info']['aid'],
|
||||
'mid': stoken_data['data']['user_info']['mid'],
|
||||
'cookie_token': cookie_token['data']['cookie_token'],
|
||||
}
|
||||
).output(header='', sep=';')
|
||||
else:
|
||||
logger.warning('game_token获取失败')
|
||||
im = 'game_token获取失败:二维码已过期'
|
||||
return await send_group_msg(im)
|
||||
await matcher.send('game_token获取失败:二维码已过期')
|
||||
return ''
|
||||
|
@ -1,93 +0,0 @@
|
||||
import io
|
||||
import base64
|
||||
import asyncio
|
||||
import traceback
|
||||
|
||||
import qrcode
|
||||
from nonebot.log import logger
|
||||
from qrcode.constants import ERROR_CORRECT_L
|
||||
|
||||
from ..utils.message.send_msg import send_forward_msg
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.mhy_api.get_mhy_data import topup, checkorder, fetchgoods
|
||||
|
||||
disnote = '''免责声明:
|
||||
该充值接口由米游社提供,不对充值结果负责。
|
||||
请在充值前仔细阅读米哈游的充值条款。
|
||||
'''
|
||||
|
||||
|
||||
def get_qrcode_base64(url):
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
error_correction=ERROR_CORRECT_L,
|
||||
box_size=10,
|
||||
border=4,
|
||||
)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
img = qr.make_image(fill_color="black", back_color="white")
|
||||
img_byte = io.BytesIO()
|
||||
img.save(img_byte, format="PNG") # type: ignore
|
||||
img_byte = img_byte.getvalue()
|
||||
return base64.b64encode(img_byte).decode()
|
||||
|
||||
|
||||
async def refresh(order, uid):
|
||||
times = 0
|
||||
while True:
|
||||
await asyncio.sleep(5)
|
||||
order_status = await checkorder(order, uid)
|
||||
if order_status != 900:
|
||||
pass
|
||||
else:
|
||||
return "支付成功"
|
||||
times += 1
|
||||
if times > 60:
|
||||
return "支付超时"
|
||||
|
||||
|
||||
async def topup_(bot, qid, group_id, goods_id):
|
||||
async def send_group_msg(msg: str):
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=group_id,
|
||||
message=msg,
|
||||
)
|
||||
return ''
|
||||
|
||||
uid = await select_db(qid, mode="uid")
|
||||
if uid is None:
|
||||
await send_group_msg("未绑定米游社账号")
|
||||
return
|
||||
fetchgoods_data = await fetchgoods()
|
||||
try:
|
||||
goods_data = fetchgoods_data[goods_id]
|
||||
except Exception:
|
||||
await send_group_msg("商品不存在,最大为" + str(len(fetchgoods_data) - 1))
|
||||
return
|
||||
try:
|
||||
order = await topup(uid, goods_data)
|
||||
except Exception:
|
||||
await send_group_msg("出错了,可能是cookie过期或接口出错")
|
||||
logger.warning(f"[充值] {group_id} {qid}")
|
||||
return
|
||||
try:
|
||||
im = []
|
||||
b64_data = get_qrcode_base64(order["encode_order"])
|
||||
qrc = f'[CQ:image,file=base64://{b64_data}]'
|
||||
im.append(f"充值uid:{uid}")
|
||||
im.append(
|
||||
f"商品名称:{goods_data['goods_name']}×{str(goods_data['goods_unit'])}"
|
||||
if int(goods_data['goods_unit']) > 0
|
||||
else goods_data["goods_name"],
|
||||
)
|
||||
im.append(f'商品价格:{int(order["amount"])/100}')
|
||||
im.append(f"订单号:{order['order_no']}")
|
||||
im.append(disnote)
|
||||
im.append(qrc)
|
||||
await send_forward_msg(bot, group_id, "小助手", str(qid), im)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
logger.warning(f"[充值] {group_id} 图片发送失败")
|
||||
await send_group_msg(await refresh(order, uid))
|
@ -64,7 +64,6 @@ footer_html = f'''
|
||||
</p>
|
||||
'''
|
||||
|
||||
|
||||
# 还原高版本的注册按钮丢失
|
||||
@overrides(user_auth_admin.UserLoginFormAdmin)
|
||||
async def get_form(self, request: Request) -> Form:
|
||||
|
@ -3,15 +3,9 @@ import re
|
||||
from nonebot import on_command
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
Message,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .get_wiki_text import (
|
||||
char_wiki,
|
||||
@ -28,28 +22,14 @@ get_cost = on_command('材料', priority=priority)
|
||||
get_polar = on_command('命座', priority=priority)
|
||||
get_talents = on_command('天赋', priority=priority)
|
||||
get_enemies = on_command('原魔', priority=priority)
|
||||
get_audio = on_command('语音', priority=priority)
|
||||
# get_audio = on_command('语音', priority=priority)
|
||||
get_artifacts = on_command('圣遗物', priority=priority)
|
||||
get_food = on_command('食物', priority=priority)
|
||||
|
||||
|
||||
'''频道无法使用语音相关
|
||||
@get_audio.handle()
|
||||
@handle_exception('语音', '语音发送失败,可能是FFmpeg环境未配置。')
|
||||
@register_menu(
|
||||
'角色语音',
|
||||
'语音[ID]',
|
||||
'获取角色语音',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色语音\n'
|
||||
'获取语言ID列表请使用指令 <ft color=(238,120,0)>语音列表</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>语音{列表|</ft>'
|
||||
'<ft color=(0,148,200)>[语音ID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -61,22 +41,11 @@ async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
await matcher.finish(MessageSegment.record(im))
|
||||
'''
|
||||
|
||||
|
||||
@get_enemies.handle()
|
||||
@handle_exception('怪物')
|
||||
@register_menu(
|
||||
'怪物图鉴',
|
||||
'怪物xx',
|
||||
'获取怪物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取怪物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>怪物</ft><ft color=(0,148,200)>[怪物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await enemies_wiki(message)
|
||||
@ -85,18 +54,6 @@ async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_food.handle()
|
||||
@handle_exception('食物')
|
||||
@register_menu(
|
||||
'食物图鉴',
|
||||
'食物xx',
|
||||
'获取食物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取食物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>食物</ft><ft color=(0,148,200)>[食物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await foods_wiki(message)
|
||||
@ -105,18 +62,6 @@ async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_artifacts.handle()
|
||||
@handle_exception('圣遗物')
|
||||
@register_menu(
|
||||
'圣遗物图鉴',
|
||||
'圣遗物xx',
|
||||
'获取怪物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取圣遗物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>圣遗物</ft><ft color=(0,148,200)>[圣遗物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await artifacts_wiki(message)
|
||||
@ -125,23 +70,6 @@ async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_weapon.handle()
|
||||
@handle_exception('武器')
|
||||
@register_menu(
|
||||
'武器图鉴',
|
||||
'武器xx',
|
||||
'获取武器Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取武器Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>武器</ft><ft color=(0,148,200)>[武器名称]</ft>'
|
||||
'<ft color=(125,125,125)>(级数)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>武器雾切</ft>\n'
|
||||
'- <ft color=(238,120,0)>武器无工之剑90</ft>'
|
||||
),
|
||||
)
|
||||
async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -153,27 +81,12 @@ async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||
await matcher.finish(im)
|
||||
|
||||
|
||||
'''频道无法发送合并转发消息
|
||||
@get_talents.handle()
|
||||
@handle_exception('天赋')
|
||||
@register_menu(
|
||||
'天赋效果',
|
||||
'天赋[角色][天赋序号]',
|
||||
'查询角色天赋技能效果',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询角色天赋技能效果\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>天赋</ft>'
|
||||
'<ft color=(0,148,200)>[角色名称][天赋序号]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>天赋绫华2</ft>'
|
||||
),
|
||||
)
|
||||
async def send_talents(
|
||||
bot: Bot,
|
||||
event: GroupMessageEvent,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
@ -191,27 +104,11 @@ async def send_talents(
|
||||
else:
|
||||
im = '参数不正确。'
|
||||
await matcher.finish(im)
|
||||
'''
|
||||
|
||||
|
||||
@get_char.handle()
|
||||
@handle_exception('角色')
|
||||
@register_menu(
|
||||
'角色图鉴',
|
||||
'角色xx',
|
||||
'获取角色Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>角色</ft><ft color=(0,148,200)>[角色名称]</ft>'
|
||||
'<ft color=(125,125,125)>(等级)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>角色可莉</ft>\n'
|
||||
'- <ft color=(238,120,0)>角色可莉90</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -225,18 +122,6 @@ async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_cost.handle()
|
||||
@handle_exception('材料')
|
||||
@register_menu(
|
||||
'材料图鉴',
|
||||
'材料xx',
|
||||
'获取材料Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取材料Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>材料</ft><ft color=(0,148,200)>[材料名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await char_wiki(message, 'costs')
|
||||
@ -245,22 +130,6 @@ async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_polar.handle()
|
||||
@handle_exception('命座')
|
||||
@register_menu(
|
||||
'角色命座图鉴',
|
||||
'命座[角色][等级]',
|
||||
'获取角色命座Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色命座Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>命座</ft>'
|
||||
'<ft color=(0,148,200)>[角色名称][命座等级]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>命座胡桃1</ft>'
|
||||
),
|
||||
)
|
||||
async def send_polar(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
num = int(re.findall(r'\d+', message)[0]) # str
|
||||
|
@ -6,7 +6,7 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
|
||||
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -26,8 +26,7 @@ async def scheduled_draw_abyss():
|
||||
async def send_guide_pic(matcher: Matcher):
|
||||
if TOTAL_IMG.exists():
|
||||
logger.info('获得深渊概览成功!')
|
||||
with open(TOTAL_IMG, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
await matcher.finish(MessageSegment.file_image(TOTAL_IMG))
|
||||
else:
|
||||
await matcher.finish('深渊概览图不存在!')
|
||||
|
||||
|
@ -17,10 +17,7 @@ path = Path(__file__).parents[1] / 'genshinuid_adv'
|
||||
wb = load_workbook(str(path / 'Genshin All Char.xlsx'))
|
||||
ws = wb.active
|
||||
for char_i in range(2, 336, 5): # 角色行
|
||||
char = ws.cell(char_i, 1).value
|
||||
if not isinstance(char, str):
|
||||
continue
|
||||
char_name = char.replace('\n', '')
|
||||
char_name = ws.cell(char_i, 1).value.replace('\n', '') # type: ignore
|
||||
char_sample = copy.deepcopy(sample)
|
||||
for i in range(5):
|
||||
row = i + char_i
|
||||
|
@ -251,7 +251,7 @@ class CookiesDAL:
|
||||
await self.db_session.flush()
|
||||
return True
|
||||
|
||||
async def add_cookie_db(self, userid: int, uid: str, cookies: str) -> bool:
|
||||
async def add_cookie_db(self, userid: str, uid: str, cookies: str) -> bool:
|
||||
"""
|
||||
:说明:
|
||||
绑定Cookies
|
||||
|
@ -11,7 +11,7 @@ class UidDataDAL:
|
||||
def __init__(self, db_session: Session):
|
||||
self.db_session = db_session
|
||||
|
||||
async def get_user_data(self, userid: int) -> Optional[UidData]:
|
||||
async def get_user_data(self, userid: str) -> Optional[UidData]:
|
||||
"""
|
||||
:说明:
|
||||
获取用户的绑定信息
|
||||
@ -37,7 +37,7 @@ class UidDataDAL:
|
||||
bind_list.append(item.__dict__)
|
||||
return bind_list
|
||||
|
||||
async def user_exists(self, userid: int) -> bool:
|
||||
async def user_exists(self, userid: str) -> bool:
|
||||
"""
|
||||
:说明:
|
||||
是否存在用户的绑定信息
|
||||
@ -67,7 +67,7 @@ class UidDataDAL:
|
||||
uid_list.extend(item.UID.split("_"))
|
||||
return uid_list
|
||||
|
||||
async def get_uid_list(self, userid: int) -> List[str]:
|
||||
async def get_uid_list(self, userid: str) -> List[str]:
|
||||
"""
|
||||
:说明:
|
||||
获得用户的绑定UID列表
|
||||
@ -83,7 +83,7 @@ class UidDataDAL:
|
||||
return uid_list
|
||||
return []
|
||||
|
||||
async def get_uid(self, userid: int) -> str:
|
||||
async def get_uid(self, userid: str) -> str:
|
||||
"""
|
||||
:说明:
|
||||
获得用户绑定的UID
|
||||
@ -98,7 +98,7 @@ class UidDataDAL:
|
||||
else:
|
||||
return '未找到绑定的UID~'
|
||||
|
||||
async def switch_uid(self, userid: int, uid: Optional[str] = None) -> str:
|
||||
async def switch_uid(self, userid: str, uid: Optional[str] = None) -> str:
|
||||
"""
|
||||
:说明:
|
||||
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
||||
@ -126,7 +126,7 @@ class UidDataDAL:
|
||||
else:
|
||||
return '你还没有绑定过UID噢~'
|
||||
|
||||
async def get_mysid_list(self, userid: int) -> List[str]:
|
||||
async def get_mysid_list(self, userid: str) -> List[str]:
|
||||
"""
|
||||
:说明:
|
||||
获得用户的绑定MYSID列表
|
||||
@ -142,7 +142,7 @@ class UidDataDAL:
|
||||
return mys_list
|
||||
return []
|
||||
|
||||
async def get_mysid(self, userid: int) -> str:
|
||||
async def get_mysid(self, userid: str) -> str:
|
||||
"""
|
||||
:说明:
|
||||
获得用户绑定的MYSID
|
||||
@ -157,7 +157,7 @@ class UidDataDAL:
|
||||
else:
|
||||
return "未找到绑定的MYSID~"
|
||||
|
||||
async def get_anyid(self, userid: int) -> str:
|
||||
async def get_anyid(self, userid: str) -> str:
|
||||
"""
|
||||
:说明:
|
||||
获得用户绑定的ID信息
|
||||
@ -176,12 +176,12 @@ class UidDataDAL:
|
||||
else:
|
||||
return '未找到绑定的ID信息~'
|
||||
|
||||
async def bind_db(self, userid: int, data: dict) -> str:
|
||||
async def bind_db(self, userid: str, data: dict) -> str:
|
||||
"""
|
||||
:说明:
|
||||
绑定UID或者MYSID
|
||||
:参数:
|
||||
* userid (int): QQ号。
|
||||
* userid (str): 频道用户 ID。
|
||||
* data (dict): 绑定的UID或者MYSID, 至少填写一项。
|
||||
data = {'UID': UID, 'MYSID': MYSID}
|
||||
:返回:
|
||||
@ -229,7 +229,7 @@ class UidDataDAL:
|
||||
await self.db_session.flush() # type: ignore
|
||||
return _bind
|
||||
|
||||
async def delete_db(self, userid: int, data: Optional[dict]) -> str:
|
||||
async def delete_db(self, userid: str, data: Optional[dict]) -> str:
|
||||
"""
|
||||
:说明:
|
||||
删除用户的绑定UID或者MYSID
|
||||
@ -284,7 +284,7 @@ class UidDataDAL:
|
||||
|
||||
async def update_db(
|
||||
self,
|
||||
userid: int,
|
||||
userid: str,
|
||||
data: Optional[dict],
|
||||
):
|
||||
"""
|
||||
|
@ -33,7 +33,10 @@ class PushData(SQLModel, table=True):
|
||||
|
||||
class UidData(SQLModel, table=True):
|
||||
__table_args__ = {'keep_existing': True}
|
||||
USERID: int = Field(default=100000000, primary_key=True, title='QQ号')
|
||||
ID: int = Field(
|
||||
default=1, primary_key=True, sa_column_kwargs={"autoincrement": 1}
|
||||
)
|
||||
USERID: str = Field(default="100000000", primary_key=True, title='QQ号')
|
||||
UID: Optional[str] = Field(title='UID')
|
||||
MYSID: Optional[str] = Field(title='米游社通行证(废弃)')
|
||||
|
||||
@ -42,7 +45,7 @@ class NewCookiesTable(SQLModel, table=True):
|
||||
__table_args__ = {'keep_existing': True}
|
||||
UID: int = Field(default=100000000, primary_key=True, title='UID')
|
||||
Cookies: str = Field(title='CK')
|
||||
QID: int = Field(title='QQ号')
|
||||
QID: str = Field(title='QQ号')
|
||||
StatusA: str = Field(title='全局推送开关')
|
||||
StatusB: str = Field(title='自动签到')
|
||||
StatusC: str = Field(title='自动米游币')
|
||||
|
@ -9,7 +9,7 @@ from .database.db_config import async_session
|
||||
|
||||
|
||||
async def get_push_status(uid, func) -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
push_dict = await PushData.get_user_data(uid)
|
||||
@ -23,7 +23,7 @@ async def get_push_status(uid, func) -> List:
|
||||
|
||||
|
||||
async def update_push_status(uid: int, func: str, status: str) -> bool:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -32,7 +32,7 @@ async def update_push_status(uid: int, func: str, status: str) -> bool:
|
||||
|
||||
|
||||
async def update_push_value(uid: int, func: str, value: int) -> bool:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -43,7 +43,7 @@ async def update_push_value(uid: int, func: str, value: int) -> bool:
|
||||
async def update_is_pushed(
|
||||
uid: int, func: str, is_pushed: str = 'off'
|
||||
) -> bool:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -52,7 +52,7 @@ async def update_is_pushed(
|
||||
|
||||
|
||||
async def bind_db(userid, uid=None, mys=None):
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.bind_db(userid, {'UID': uid, 'MYSID': mys})
|
||||
@ -68,7 +68,7 @@ async def get_all_bind() -> List[Dict]:
|
||||
|
||||
|
||||
async def get_all_uid() -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
lst = await UidData.get_all_uid_list()
|
||||
@ -76,7 +76,7 @@ async def get_all_uid() -> List:
|
||||
|
||||
|
||||
async def get_all_cookie() -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_all_cookie_list()
|
||||
@ -84,16 +84,14 @@ async def get_all_cookie() -> List:
|
||||
|
||||
|
||||
async def get_all_stoken() -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_all_stoken_list()
|
||||
return lst
|
||||
|
||||
|
||||
async def select_db(
|
||||
userid: int, mode: str = 'auto'
|
||||
) -> Union[List[str], str, None]:
|
||||
async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
||||
"""
|
||||
:说明:
|
||||
选择绑定uid/mys库
|
||||
@ -110,7 +108,7 @@ async def select_db(
|
||||
其他情况下data[0]为需要的uid/mysid
|
||||
data[1]表示data[0]是`uid` or `mysid`
|
||||
"""
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
if mode == 'auto':
|
||||
@ -126,7 +124,7 @@ async def select_db(
|
||||
return im
|
||||
|
||||
|
||||
async def switch_db(userid: int, uid: Optional[str] = None) -> str:
|
||||
async def switch_db(userid: str, uid: Optional[str] = None) -> str:
|
||||
"""
|
||||
:说明:
|
||||
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
||||
@ -137,14 +135,14 @@ async def switch_db(userid: int, uid: Optional[str] = None) -> str:
|
||||
:返回:
|
||||
* im (str): 回调信息。
|
||||
"""
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.switch_uid(userid, uid)
|
||||
return im
|
||||
|
||||
|
||||
async def delete_db(userid: int, data: dict) -> str:
|
||||
async def delete_db(userid: str, data: dict) -> str:
|
||||
"""
|
||||
:说明:
|
||||
删除当前绑定的UID信息
|
||||
@ -155,15 +153,15 @@ async def delete_db(userid: int, data: dict) -> str:
|
||||
:返回:
|
||||
* im (str): 回调信息。
|
||||
"""
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.delete_db(userid, data)
|
||||
return im
|
||||
|
||||
|
||||
async def cookies_db(uid: str, cookies: str, qid: int):
|
||||
async with async_session() as session:
|
||||
async def cookies_db(uid: str, cookies: str, qid: str):
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_cookie_db(qid, uid, cookies)
|
||||
@ -171,7 +169,7 @@ async def cookies_db(uid: str, cookies: str, qid: int):
|
||||
|
||||
|
||||
async def error_db(cookies: str, error: str):
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_error_db(cookies, error)
|
||||
@ -179,7 +177,7 @@ async def error_db(cookies: str, error: str):
|
||||
|
||||
|
||||
async def owner_cookies(uid: str) -> str:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
owner_ck = await Cookies.get_user_ck(uid)
|
||||
@ -191,7 +189,7 @@ async def owner_cookies(uid: str) -> str:
|
||||
|
||||
|
||||
async def delete_cookies(uid: str) -> str:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
result = await Cookies.delete_user(uid)
|
||||
@ -202,7 +200,7 @@ async def delete_cookies(uid: str) -> str:
|
||||
|
||||
|
||||
async def get_stoken(uid: str) -> str:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
stoken = await Cookies.get_user_stoken(uid)
|
||||
@ -210,7 +208,7 @@ async def get_stoken(uid: str) -> str:
|
||||
|
||||
|
||||
async def get_user_bind_data(uid: str) -> dict:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_user_data_dict(uid)
|
||||
@ -218,7 +216,7 @@ async def get_user_bind_data(uid: str) -> dict:
|
||||
|
||||
|
||||
async def stoken_db(s_cookies: str, uid: str) -> str:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_stoken_db(uid, s_cookies)
|
||||
@ -226,7 +224,7 @@ async def stoken_db(s_cookies: str, uid: str) -> str:
|
||||
|
||||
|
||||
async def open_push(uid, qid, status, func):
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.update_user_status(
|
||||
@ -243,7 +241,7 @@ async def empty_cache():
|
||||
|
||||
|
||||
async def config_check(func, mode='CHECK') -> bool:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Config = ConfigDAL(session)
|
||||
im = False
|
||||
@ -257,7 +255,7 @@ async def config_check(func, mode='CHECK') -> bool:
|
||||
|
||||
|
||||
async def get_all_signin_list() -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.get_status_list('StatusB')
|
||||
@ -265,7 +263,7 @@ async def get_all_signin_list() -> List:
|
||||
|
||||
|
||||
async def get_all_push_list() -> List:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.get_status_list('StatusA')
|
||||
@ -273,7 +271,7 @@ async def get_all_push_list() -> List:
|
||||
|
||||
|
||||
async def get_push_data(uid: int) -> dict:
|
||||
async with async_session() as session:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
push_data = await PushData.get_user_data(uid)
|
||||
|
7
GenshinUID/utils/message/cast_type.py
Normal file
7
GenshinUID/utils/message/cast_type.py
Normal file
@ -0,0 +1,7 @@
|
||||
from typing import Optional, cast
|
||||
|
||||
from nonebot.adapters.qqguild.api.model import User
|
||||
|
||||
|
||||
def cast_to_int(user: Optional[User]) -> int:
|
||||
return cast(int, cast(User, user).id)
|
@ -1,21 +0,0 @@
|
||||
from typing import List
|
||||
|
||||
from nonebot.adapters.onebot.v11 import Bot
|
||||
|
||||
|
||||
async def get_all_friend_list(bot: Bot) -> List[int]:
|
||||
friend_list = []
|
||||
friend_dict_list = await bot.call_api('get_friend_list')
|
||||
for friend in friend_dict_list:
|
||||
friend_list.append(friend['user_id'])
|
||||
return friend_list
|
||||
|
||||
|
||||
async def get_group_member_list(bot: Bot, group_id: int) -> List[int]:
|
||||
member_list = []
|
||||
group_member_list = await bot.call_api(
|
||||
'get_group_member_list', group_id=group_id
|
||||
)
|
||||
for group_member in group_member_list:
|
||||
member_list.append(group_member['user_id'])
|
||||
return member_list
|
@ -1,6 +1,6 @@
|
||||
from typing import Union
|
||||
from typing import Optional
|
||||
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
|
||||
|
||||
# https://v2.nonebot.dev/docs/advanced/di/dependency-injection#class-%E4%BD%9C%E4%B8%BA%E4%BE%9D%E8%B5%96
|
||||
@ -8,15 +8,11 @@ class ImageAndAt:
|
||||
def __init__(self, event: MessageEvent):
|
||||
self.images = []
|
||||
self.at = []
|
||||
for i in event.message:
|
||||
if i.type == "image":
|
||||
data = i.data
|
||||
if url := data.get("url"):
|
||||
self.images.append(url)
|
||||
else:
|
||||
continue
|
||||
elif i.type == "at":
|
||||
self.at.append(i.data["qq"])
|
||||
for i in event.get_message():
|
||||
if i.type == "attachment":
|
||||
self.images.append(i.data["url"])
|
||||
elif i.type == "mention_user":
|
||||
self.at.append(i.data["user_id"])
|
||||
|
||||
def get_at(self):
|
||||
return self.at
|
||||
@ -24,14 +20,8 @@ class ImageAndAt:
|
||||
def get_image(self):
|
||||
return self.images
|
||||
|
||||
def get_first_image(self) -> Union[str, None]:
|
||||
try:
|
||||
return self.images[0]
|
||||
except IndexError:
|
||||
return None
|
||||
def get_first_image(self) -> Optional[str]:
|
||||
return self.images[0] if len(self.images) else None
|
||||
|
||||
def get_first_at(self) -> Union[int, None]:
|
||||
try:
|
||||
return self.at[0]
|
||||
except IndexError:
|
||||
return None
|
||||
def get_first_at(self) -> Optional[str]:
|
||||
return self.at[0] if len(self.at) else None
|
||||
|
@ -1,12 +1,12 @@
|
||||
from typing import List
|
||||
|
||||
from nonebot.adapters.onebot.v11 import Bot
|
||||
from nonebot.adapters.qqguild import Bot
|
||||
|
||||
|
||||
# 发送聊天记录
|
||||
async def send_forward_msg(
|
||||
bot: Bot,
|
||||
groupid: int,
|
||||
userid: int,
|
||||
name: str,
|
||||
uin: str,
|
||||
msgs: List[str],
|
||||
@ -19,5 +19,5 @@ async def send_forward_msg(
|
||||
|
||||
messages = [to_json(msg) for msg in msgs]
|
||||
await bot.call_api(
|
||||
"send_group_forward_msg", group_id=groupid, messages=messages
|
||||
"send_private_forward_msg", user_id=userid, messages=messages
|
||||
)
|
||||
|
@ -17,7 +17,6 @@ from ..mhy_api.mhy_api_tools import (
|
||||
random_hex,
|
||||
random_text,
|
||||
get_ds_token,
|
||||
gen_payment_sign,
|
||||
generate_passport_ds,
|
||||
generate_dynamic_secret,
|
||||
old_version_get_ds_token,
|
||||
@ -57,9 +56,6 @@ from ..mhy_api.mhy_api import ( # noqa
|
||||
MIHOYO_BBS_PLAYER_INFO_URL,
|
||||
MIHOYO_BBS_PLAYER_INFO_URL_OS,
|
||||
GET_COOKIE_TOKEN_BY_GAME_TOKEN,
|
||||
CheckOrderurl,
|
||||
CreateOrderurl,
|
||||
fetchGoodsurl,
|
||||
)
|
||||
|
||||
PROXY_URL = string_config.get_config('proxy')
|
||||
@ -549,7 +545,7 @@ async def get_gcg_info(uid: str):
|
||||
|
||||
async def create_qrcode_url():
|
||||
device_id: str = ''.join(random.choices(ascii_letters + digits, k=64))
|
||||
app_id: str = '8'
|
||||
app_id: str = '4'
|
||||
data = await _mhy_request(
|
||||
CREATE_QRCODE,
|
||||
'POST',
|
||||
@ -858,77 +854,3 @@ async def get_regtime_data(uid: str) -> Any:
|
||||
use_proxy=True,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
async def fetchgoods():
|
||||
data = {
|
||||
"released_flag": True,
|
||||
"game": "hk4e_cn",
|
||||
"region": "cn_gf01",
|
||||
"uid": "1",
|
||||
"account": "1",
|
||||
}
|
||||
goodslist = await _mhy_request(
|
||||
url=fetchGoodsurl,
|
||||
method='POST',
|
||||
data=data,
|
||||
)
|
||||
# print(json.dumps(goodslist.json(),indent=4,ensure_ascii=False))
|
||||
return goodslist["data"]["goods_list"]
|
||||
|
||||
|
||||
async def topup(uid, goods):
|
||||
device_id = str(uuid.uuid4())
|
||||
HEADER = copy.deepcopy(_HEADER)
|
||||
HEADER["Cookie"] = await owner_cookies(uid)
|
||||
account = HEADER["Cookie"].split("account_id=")[1].split(";")[0]
|
||||
order = {
|
||||
"account": str(account),
|
||||
"region": "cn_gf01",
|
||||
"uid": uid,
|
||||
"delivery_url": "",
|
||||
"device": device_id,
|
||||
"channel_id": 1,
|
||||
"client_ip": "",
|
||||
"client_type": 4,
|
||||
"game": "hk4e_cn",
|
||||
"amount": goods["price"],
|
||||
# "amount": 600,
|
||||
"goods_num": 1,
|
||||
"goods_id": goods["goods_id"],
|
||||
"goods_title": f"{goods['goods_name']}×{str(goods['goods_unit'])}"
|
||||
if int(goods['goods_unit']) > 0
|
||||
else goods["goods_name"],
|
||||
"price_tier": goods["tier_id"],
|
||||
# "price_tier": "Tier_1",
|
||||
"currency": "CNY",
|
||||
"pay_plat": "alipay",
|
||||
}
|
||||
data = {"order": order, "sign": gen_payment_sign(order)}
|
||||
HEADER["x-rpc-device_id"] = device_id
|
||||
HEADER["x-rpc-client_type"] = "4"
|
||||
order = await _mhy_request(
|
||||
url=CreateOrderurl,
|
||||
method='POST',
|
||||
header=HEADER,
|
||||
data=data,
|
||||
)
|
||||
return order["data"]
|
||||
|
||||
|
||||
async def checkorder(order, uid):
|
||||
HEADER = copy.deepcopy(_HEADER)
|
||||
HEADER["Cookie"] = await owner_cookies(uid)
|
||||
data = {
|
||||
"order_no": order["order_no"],
|
||||
"game": "hk4e_cn",
|
||||
"region": "cn_gf01",
|
||||
"uid": uid,
|
||||
}
|
||||
order = await _mhy_request(
|
||||
url=CheckOrderurl,
|
||||
method='GET',
|
||||
header=HEADER,
|
||||
params=data,
|
||||
)
|
||||
return order["data"]["status"]
|
||||
|
@ -115,9 +115,3 @@ bbs_Listurl = (
|
||||
bbs_Detailurl = BBS_URL + '/post/api/getPostFull?post_id={}'
|
||||
bbs_Shareurl = BBS_URL + '/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
||||
bbs_Likeurl = f'{BBS_URL}/apihub/sapi/upvotePost'
|
||||
|
||||
# 原神充值中心
|
||||
fetchGoodsurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/fetchGoods"
|
||||
CreateOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/createOrder"
|
||||
CheckOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/checkOrder"
|
||||
PriceTierurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/listPriceTier"
|
||||
|
@ -1,4 +1,3 @@
|
||||
import hmac
|
||||
import json
|
||||
import time
|
||||
import random
|
||||
@ -76,17 +75,3 @@ def generate_passport_ds(q: str = '', b: Optional[Dict[str, Any]] = None):
|
||||
return _random_str_ds(
|
||||
"JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS", string.ascii_letters, True, q, b
|
||||
)
|
||||
|
||||
|
||||
def HMCASHA256(data, key):
|
||||
key = key.encode('utf-8')
|
||||
message = data.encode('utf-8')
|
||||
sign = hmac.new(key, message, digestmod=hashlib.sha256).digest()
|
||||
return sign.hex()
|
||||
|
||||
|
||||
def gen_payment_sign(data):
|
||||
data = dict(sorted(data.items(), key=lambda x: x[0]))
|
||||
value = "".join([str(i) for i in data.values()])
|
||||
sign = HMCASHA256(value, "6bdc3982c25f3f3c38668a32d287d16b")
|
||||
return sign
|
||||
|
9
GenshinUID/utils/nonebot2/perm.py
Normal file
9
GenshinUID/utils/nonebot2/perm.py
Normal file
@ -0,0 +1,9 @@
|
||||
from nonebot.permission import Permission
|
||||
from nonebot.adapters.qqguild.event import DirectMessageCreateEvent
|
||||
|
||||
|
||||
async def is_direct(_: DirectMessageCreateEvent) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
DIRECT = Permission(is_direct)
|
@ -1,6 +1,6 @@
|
||||
from nonebot.rule import Rule
|
||||
from nonebot.adapters.qqguild import Message
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.onebot.v11 import Message
|
||||
|
||||
|
||||
async def full_command(arg: Message = CommandArg()) -> bool:
|
||||
|
154
GenshinUID/utils/nonebot2/send.py
Normal file
154
GenshinUID/utils/nonebot2/send.py
Normal file
@ -0,0 +1,154 @@
|
||||
import json
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Union, Optional
|
||||
|
||||
from nonebot.log import logger
|
||||
from aiohttp import ClientSession
|
||||
from nonebot.drivers import Request
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters.qqguild.bot import Bot
|
||||
from pydantic import BaseModel, parse_obj_as
|
||||
from nonebot.adapters.qqguild.adapter import Adapter
|
||||
from nonebot.adapters.qqguild.api.request import _request
|
||||
from nonebot.adapters.qqguild.api.handle import API_HANDLERS
|
||||
from nonebot.adapters.qqguild.api.model import Message as APIMessage
|
||||
from nonebot.adapters.qqguild.message import Message, MessageSegment
|
||||
from nonebot.adapters.qqguild.event import (
|
||||
Event,
|
||||
MessageEvent,
|
||||
DirectMessageCreateEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild.api.model import (
|
||||
MessageArk,
|
||||
MessageEmbed,
|
||||
MessageMarkdown,
|
||||
MessageReference,
|
||||
)
|
||||
|
||||
|
||||
class LocalImage(MessageSegment):
|
||||
@overrides(MessageSegment)
|
||||
def __str__(self) -> str:
|
||||
return "<local_image>"
|
||||
|
||||
|
||||
def local_image(data: Union[str, Path, bytes, BytesIO]) -> LocalImage:
|
||||
if isinstance(data, (str, Path)):
|
||||
with open(data, "rb") as f:
|
||||
b = f.read()
|
||||
elif isinstance(data, BytesIO):
|
||||
b = data.getvalue()
|
||||
else:
|
||||
b = data
|
||||
return LocalImage("local_image", data={"content": b})
|
||||
|
||||
|
||||
class MessageSend(BaseModel):
|
||||
content: Optional[str] = None
|
||||
embed: Optional[MessageEmbed] = None
|
||||
ark: Optional[MessageArk] = None
|
||||
markdown: Optional[MessageMarkdown] = None
|
||||
message_reference: Optional[MessageReference] = None
|
||||
image: Optional[str] = None
|
||||
msg_id: Optional[str] = None
|
||||
|
||||
|
||||
def patch_send():
|
||||
logger.info("注入本地图片发送猴子补丁")
|
||||
|
||||
@overrides(Bot)
|
||||
async def send(
|
||||
self,
|
||||
event: Event,
|
||||
message: Union[str, Message, MessageSegment],
|
||||
**kwargs,
|
||||
) -> Any:
|
||||
if (
|
||||
not isinstance(event, MessageEvent)
|
||||
or not event.channel_id
|
||||
or not event.id
|
||||
):
|
||||
raise RuntimeError("Event cannot be replied to!")
|
||||
message = (
|
||||
MessageSegment.text(message)
|
||||
if isinstance(message, str)
|
||||
else message
|
||||
)
|
||||
|
||||
message = message if isinstance(message, Message) else Message(message)
|
||||
content = message.extract_content() or None
|
||||
guild_id = None
|
||||
if isinstance(event, DirectMessageCreateEvent):
|
||||
event_dict = event.__dict__
|
||||
guild_id = event_dict['guild_id']
|
||||
if embed := (message["embed"] or None):
|
||||
embed = embed[-1].data["embed"]
|
||||
if ark := (message["ark"] or None):
|
||||
ark = ark[-1].data["ark"]
|
||||
if image := (message["attachment"] or None):
|
||||
image = image[-1].data["url"]
|
||||
if local_image := (message["local_image"] or None):
|
||||
local_image = local_image[-1].data["content"]
|
||||
if markdown := (message["markdown"] or None):
|
||||
markdown = markdown[-1].data["markdown"]
|
||||
return await self.post_messages(
|
||||
channel_id=event.channel_id,
|
||||
guild_id=guild_id,
|
||||
msg_id=event.id,
|
||||
content=content,
|
||||
embed=embed,
|
||||
ark=ark,
|
||||
markdown=markdown,
|
||||
image=image,
|
||||
file_image=local_image,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
Bot.send = send
|
||||
|
||||
async def post_messages(
|
||||
adapter: Adapter, bot: Bot, channel_id: int, guild_id: int, **data
|
||||
) -> Union[APIMessage, List[APIMessage]]:
|
||||
headers = {"Authorization": adapter.get_authorization(bot.bot_info)}
|
||||
model_data = MessageSend(**data).dict(exclude_none=True)
|
||||
d_api = adapter.get_api_base() / f"channels/{channel_id}/messages"
|
||||
if guild_id:
|
||||
d_api = adapter.get_api_base() / f"dms/{guild_id}/messages"
|
||||
if "file_image" in model_data.keys() and (
|
||||
file_image := model_data.pop("file_image")
|
||||
):
|
||||
new_data: Dict[str, Union[BytesIO, str]] = {
|
||||
"file_image": BytesIO(file_image)
|
||||
}
|
||||
for k, v in model_data.items():
|
||||
# 当字段类型为对象或数组时需要将字段序列化为 JSON 字符串后进行调用
|
||||
# https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html#form-data-%E6%A0%BC%E5%BC%8F%E7%A4%BA%E4%BE%8B
|
||||
if isinstance(v, BaseModel):
|
||||
new_data[k] = v.json()
|
||||
elif isinstance(v, (list, dict)):
|
||||
new_data[k] = json.dumps(v)
|
||||
|
||||
else:
|
||||
new_data[k] = v
|
||||
async with ClientSession(headers=headers) as session:
|
||||
req = await session.post(
|
||||
d_api,
|
||||
data=new_data,
|
||||
)
|
||||
data = await req.json()
|
||||
else:
|
||||
request = Request(
|
||||
"POST",
|
||||
d_api,
|
||||
json=model_data,
|
||||
headers=headers,
|
||||
)
|
||||
data = await _request(adapter, bot, request)
|
||||
if guild_id:
|
||||
return parse_obj_as(List[APIMessage], data)
|
||||
else:
|
||||
return parse_obj_as(APIMessage, data)
|
||||
|
||||
API_HANDLERS["post_messages"] = post_messages
|
||||
logger.success("本地图片发送猴子补丁已注入")
|
97
poetry.lock
generated
97
poetry.lock
generated
@ -1174,79 +1174,6 @@ files = [
|
||||
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "msgpack"
|
||||
version = "1.0.5"
|
||||
description = "MessagePack serializer"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "msgpack-1.0.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:525228efd79bb831cf6830a732e2e80bc1b05436b086d4264814b4b2955b2fa9"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4f8d8b3bf1ff2672567d6b5c725a1b347fe838b912772aa8ae2bf70338d5a198"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cdc793c50be3f01106245a61b739328f7dccc2c648b501e237f0699fe1395b81"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5cb47c21a8a65b165ce29f2bec852790cbc04936f502966768e4aae9fa763cb7"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e42b9594cc3bf4d838d67d6ed62b9e59e201862a25e9a157019e171fbe672dd3"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:55b56a24893105dc52c1253649b60f475f36b3aa0fc66115bffafb624d7cb30b"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:1967f6129fc50a43bfe0951c35acbb729be89a55d849fab7686004da85103f1c"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20a97bf595a232c3ee6d57ddaadd5453d174a52594bf9c21d10407e2a2d9b3bd"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d25dd59bbbbb996eacf7be6b4ad082ed7eacc4e8f3d2df1ba43822da9bfa122a"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-win32.whl", hash = "sha256:382b2c77589331f2cb80b67cc058c00f225e19827dbc818d700f61513ab47bea"},
|
||||
{file = "msgpack-1.0.5-cp310-cp310-win_amd64.whl", hash = "sha256:4867aa2df9e2a5fa5f76d7d5565d25ec76e84c106b55509e78c1ede0f152659a"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9f5ae84c5c8a857ec44dc180a8b0cc08238e021f57abdf51a8182e915e6299f0"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9e6ca5d5699bcd89ae605c150aee83b5321f2115695e741b99618f4856c50898"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5494ea30d517a3576749cad32fa27f7585c65f5f38309c88c6d137877fa28a5a"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ab2f3331cb1b54165976a9d976cb251a83183631c88076613c6c780f0d6e45a"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28592e20bbb1620848256ebc105fc420436af59515793ed27d5c77a217477705"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe5c63197c55bce6385d9aee16c4d0641684628f63ace85f73571e65ad1c1e8d"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ed40e926fa2f297e8a653c954b732f125ef97bdd4c889f243182299de27e2aa9"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:b2de4c1c0538dcb7010902a2b97f4e00fc4ddf2c8cda9749af0e594d3b7fa3d7"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:bf22a83f973b50f9d38e55c6aade04c41ddda19b00c4ebc558930d78eecc64ed"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-win32.whl", hash = "sha256:c396e2cc213d12ce017b686e0f53497f94f8ba2b24799c25d913d46c08ec422c"},
|
||||
{file = "msgpack-1.0.5-cp311-cp311-win_amd64.whl", hash = "sha256:6c4c68d87497f66f96d50142a2b73b97972130d93677ce930718f68828b382e2"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a2b031c2e9b9af485d5e3c4520f4220d74f4d222a5b8dc8c1a3ab9448ca79c57"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4f837b93669ce4336e24d08286c38761132bc7ab29782727f8557e1eb21b2080"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1d46dfe3832660f53b13b925d4e0fa1432b00f5f7210eb3ad3bb9a13c6204a6"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:366c9a7b9057e1547f4ad51d8facad8b406bab69c7d72c0eb6f529cf76d4b85f"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:4c075728a1095efd0634a7dccb06204919a2f67d1893b6aa8e00497258bf926c"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:f933bbda5a3ee63b8834179096923b094b76f0c7a73c1cfe8f07ad608c58844b"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:36961b0568c36027c76e2ae3ca1132e35123dcec0706c4b7992683cc26c1320c"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-win32.whl", hash = "sha256:b5ef2f015b95f912c2fcab19c36814963b5463f1fb9049846994b007962743e9"},
|
||||
{file = "msgpack-1.0.5-cp36-cp36m-win_amd64.whl", hash = "sha256:288e32b47e67f7b171f86b030e527e302c91bd3f40fd9033483f2cacc37f327a"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:137850656634abddfb88236008339fdaba3178f4751b28f270d2ebe77a563b6c"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0c05a4a96585525916b109bb85f8cb6511db1c6f5b9d9cbcbc940dc6b4be944b"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56a62ec00b636583e5cb6ad313bbed36bb7ead5fa3a3e38938503142c72cba4f"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ef8108f8dedf204bb7b42994abf93882da1159728a2d4c5e82012edd92c9da9f"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1835c84d65f46900920b3708f5ba829fb19b1096c1800ad60bae8418652a951d"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:e57916ef1bd0fee4f21c4600e9d1da352d8816b52a599c46460e93a6e9f17086"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:17358523b85973e5f242ad74aa4712b7ee560715562554aa2134d96e7aa4cbbf"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-win32.whl", hash = "sha256:cb5aaa8c17760909ec6cb15e744c3ebc2ca8918e727216e79607b7bbce9c8f77"},
|
||||
{file = "msgpack-1.0.5-cp37-cp37m-win_amd64.whl", hash = "sha256:ab31e908d8424d55601ad7075e471b7d0140d4d3dd3272daf39c5c19d936bd82"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b72d0698f86e8d9ddf9442bdedec15b71df3598199ba33322d9711a19f08145c"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:379026812e49258016dd84ad79ac8446922234d498058ae1d415f04b522d5b2d"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:332360ff25469c346a1c5e47cbe2a725517919892eda5cfaffe6046656f0b7bb"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:476a8fe8fae289fdf273d6d2a6cb6e35b5a58541693e8f9f019bfe990a51e4ba"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9985b214f33311df47e274eb788a5893a761d025e2b92c723ba4c63936b69b1"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:48296af57cdb1d885843afd73c4656be5c76c0c6328db3440c9601a98f303d87"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:addab7e2e1fcc04bd08e4eb631c2a90960c340e40dfc4a5e24d2ff0d5a3b3edb"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:916723458c25dfb77ff07f4c66aed34e47503b2eb3188b3adbec8d8aa6e00f48"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:821c7e677cc6acf0fd3f7ac664c98803827ae6de594a9f99563e48c5a2f27eb0"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-win32.whl", hash = "sha256:1c0f7c47f0087ffda62961d425e4407961a7ffd2aa004c81b9c07d9269512f6e"},
|
||||
{file = "msgpack-1.0.5-cp38-cp38-win_amd64.whl", hash = "sha256:bae7de2026cbfe3782c8b78b0db9cbfc5455e079f1937cb0ab8d133496ac55e1"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:20c784e66b613c7f16f632e7b5e8a1651aa5702463d61394671ba07b2fc9e025"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:266fa4202c0eb94d26822d9bfd7af25d1e2c088927fe8de9033d929dd5ba24c5"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:18334484eafc2b1aa47a6d42427da7fa8f2ab3d60b674120bce7a895a0a85bdd"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57e1f3528bd95cc44684beda696f74d3aaa8a5e58c816214b9046512240ef437"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:586d0d636f9a628ddc6a17bfd45aa5b5efaf1606d2b60fa5d87b8986326e933f"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a740fa0e4087a734455f0fc3abf5e746004c9da72fbd541e9b113013c8dc3282"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3055b0455e45810820db1f29d900bf39466df96ddca11dfa6d074fa47054376d"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:a61215eac016f391129a013c9e46f3ab308db5f5ec9f25811e811f96962599a8"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:362d9655cd369b08fda06b6657a303eb7172d5279997abe094512e919cf74b11"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-win32.whl", hash = "sha256:ac9dd47af78cae935901a9a500104e2dea2e253207c924cc95de149606dc43cc"},
|
||||
{file = "msgpack-1.0.5-cp39-cp39-win_amd64.whl", hash = "sha256:06f5174b5f8ed0ed919da0e62cbd4ffde676a374aba4020034da05fab67b9164"},
|
||||
{file = "msgpack-1.0.5.tar.gz", hash = "sha256:c075544284eadc5cddc70f4757331d99dcbc16b2bbd4849d15f8aae4cf36d31c"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multidict"
|
||||
version = "6.0.4"
|
||||
@ -1359,20 +1286,20 @@ files = [
|
||||
setuptools = "*"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot-adapter-onebot"
|
||||
version = "2.2.1"
|
||||
description = "OneBot(CQHTTP) adapter for nonebot2"
|
||||
name = "nonebot-adapter-qqguild"
|
||||
version = "0.2.1"
|
||||
description = "QQ Guild adapter for nonebot2"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.8,<4.0"
|
||||
files = [
|
||||
{file = "nonebot_adapter_onebot-2.2.1-py3-none-any.whl", hash = "sha256:db22c92a541f243ef427a7080096fb28751fec213bc75b111e2c9ed89e121d94"},
|
||||
{file = "nonebot_adapter_onebot-2.2.1.tar.gz", hash = "sha256:2f77ff2345cc98e493c3bf00a5fd7112cf20e66ebeac062bbb8de56b4d07040e"},
|
||||
{file = "nonebot_adapter_qqguild-0.2.1-py3-none-any.whl", hash = "sha256:0f0d195ef6f27b99727a0d5cedb007833ac31d483f200bb0defc704bbb54616b"},
|
||||
{file = "nonebot_adapter_qqguild-0.2.1.tar.gz", hash = "sha256:bbde4260206663a67bfdccf76c7e062432af1d344ee80652c1d439eecca93bba"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
msgpack = ">=1.0.3,<2.0.0"
|
||||
nonebot2 = ">=2.0.0-beta.3,<3.0.0"
|
||||
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
|
||||
pydantic = ">=1.9.0,<2.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot-plugin-apscheduler"
|
||||
@ -1420,20 +1347,20 @@ websockets = ["websockets (>=10.0,<11.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "nonebug"
|
||||
version = "0.3.1"
|
||||
version = "0.2.3"
|
||||
description = "nonebot2 test framework"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.8,<4.0"
|
||||
files = [
|
||||
{file = "nonebug-0.3.1-py3-none-any.whl", hash = "sha256:b33e93d486e3f187e890a516ad8d9432ea736e50b0270341ddc78fecfe080d5f"},
|
||||
{file = "nonebug-0.3.1.tar.gz", hash = "sha256:96637bbdc406e7673e625492fbe928a9db467cd630d6fd04cfde0999f58f9a7a"},
|
||||
{file = "nonebug-0.2.3-py3-none-any.whl", hash = "sha256:5c83bd885899b2857323fa19eff6bbc3f160729453b2f289d8305a99b7b95fc9"},
|
||||
{file = "nonebug-0.2.3.tar.gz", hash = "sha256:3e59757b32b6b96cd8c36c4c9fd6050e611b1ffad058ec5fa82cba3f86495c61"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
asgiref = ">=3.4.0,<4.0.0"
|
||||
async-asgi-testclient = ">=1.4.8,<2.0.0"
|
||||
nonebot2 = ">=2.0.0-rc.2,<3.0.0"
|
||||
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
|
||||
pytest = ">=7.0.0,<8.0.0"
|
||||
typing-extensions = ">=4.0.0,<5.0.0"
|
||||
|
||||
@ -2452,4 +2379,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.8.1"
|
||||
content-hash = "5de28f6fa03c9bf7e2207a3d3688e379c2c4aa7ed672718583c99f7f0907bc1c"
|
||||
content-hash = "20a3950358ff0c7df2fc8dde966cb5e2fcad0ec695ca605c9d23c84d6a2567ce"
|
||||
|
@ -18,7 +18,7 @@ extra_standard_library = ["typing_extensions"]
|
||||
asyncio_mode = "auto"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.2.0"]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
@ -42,7 +42,7 @@ exclude = ["tests", "deploy"]
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8.1"
|
||||
nonebot2 = ">=2.0.0b4"
|
||||
nonebot-adapter-onebot = ">=2.1.1"
|
||||
nonebot-adapter-qqguild = ">=0.1.2"
|
||||
httpx = ">=0.23.0"
|
||||
beautifulsoup4 = ">=4.11.1"
|
||||
lxml = ">=4.9.2"
|
||||
@ -70,9 +70,7 @@ flake8 = "^6.0.0"
|
||||
black = "^22.12.0"
|
||||
isort = "^5.11.5"
|
||||
pre-commit = "^2.21.0"
|
||||
pycln = "^2.1.2"
|
||||
|
||||
[tool.poetry.group.test.dependencies]
|
||||
nonebug = "^0.3.0"
|
||||
nonebug = "^0.2.2"
|
||||
pytest = "^7.2.0"
|
||||
pytest-asyncio = "^0.20.3"
|
||||
pycln = "^2.1.2"
|
||||
|
@ -28,15 +28,14 @@ httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
msgpack==1.0.5 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
multidict==6.0.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot-adapter-onebot==2.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot-adapter-qqguild==0.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot-plugin-apscheduler==0.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
openpyxl==3.1.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
passlib==1.7.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pillow==9.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pydantic[dotenv]==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pygtrie==2.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pypng==0.20220715.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
|
@ -1,5 +1,4 @@
|
||||
LOG_LEVEL=TRACE
|
||||
NICKNAME=["test"]
|
||||
SUPERUSERS=["onebot:10000","10001","other:10002","abcdef"]
|
||||
SUPERUSERS=["10000"]
|
||||
COMMAND_START=["", "/"]
|
||||
DRIVER="~none"
|
||||
|
@ -1,23 +1,34 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
import pytest
|
||||
import nonebot
|
||||
from nonebug import NONEBOT_INIT_KWARGS
|
||||
from nonebot.adapters.onebot.v11 import Adapter
|
||||
|
||||
PLUGINS = ["meta", "adv", "etcimg", "guide"]
|
||||
if TYPE_CHECKING:
|
||||
from nonebot.plugin import Plugin
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def load_bot():
|
||||
driver = nonebot.get_driver()
|
||||
driver.register_adapter(Adapter)
|
||||
@pytest.fixture
|
||||
def load_metadata(nonebug_init: None) -> Optional["Plugin"]:
|
||||
import nonebot
|
||||
|
||||
nonebot.load_all_plugins(
|
||||
[f"GenshinUID.genshinuid_{name}" for name in PLUGINS], []
|
||||
)
|
||||
return nonebot.load_plugin("GenshinUID.genshinuid_meta")
|
||||
|
||||
|
||||
def pytest_configure(config: pytest.Config):
|
||||
config.stash[NONEBOT_INIT_KWARGS] = {
|
||||
"genshinuid_disabled_plugins": {"xkdata", "abyss", "adv"},
|
||||
"genshinuid_priority": 5,
|
||||
}
|
||||
@pytest.fixture
|
||||
def load_adv(nonebug_init: None) -> Optional["Plugin"]:
|
||||
import nonebot
|
||||
|
||||
return nonebot.load_plugin("GenshinUID.genshinuid_adv")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def load_etc(nonebug_init: None) -> Optional["Plugin"]:
|
||||
import nonebot
|
||||
|
||||
return nonebot.load_plugin("GenshinUID.genshinuid_etcimg")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def load_guide(nonebug_init: None) -> Optional["Plugin"]:
|
||||
import nonebot
|
||||
|
||||
return nonebot.load_plugin("GenshinUID.genshinuid_guide")
|
||||
|
@ -6,18 +6,12 @@ MESSAGE = """「安柏」
|
||||
推荐5★武器:阿莫斯之弓、天空之翼、终末嗟叹之诗
|
||||
推荐4★武器:绝弦
|
||||
推荐圣遗物搭配:
|
||||
[昔日宗室之仪]四件套
|
||||
-=-=-=-=-=-=-=-=-=-
|
||||
备注:
|
||||
原神御三家之一,必胜客联动看板角色之一;
|
||||
身份西风骑士团侦查骑士,蒙德飞行冠军,柏菈图的拼图(误);
|
||||
人送外号解谜点火真君/打火姬
|
||||
通常情况下,安柏的大世界解谜意义大于其深渊实战意义,建议根据实际需求选择投入资源培养"""
|
||||
[昔日宗室之仪]四件套"""
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(argnames="alias", argvalues=["安柏用什么", "安柏怎么养"])
|
||||
async def test_adv_char_chat(app: App, alias):
|
||||
async def test_adv_char_chat(app: App, alias, load_adv: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
from nonebug import App
|
||||
|
||||
|
||||
def test_config(app: App):
|
||||
from GenshinUID import config
|
||||
|
||||
assert config.config.disabled_plugins == {"xkdata", "abyss", "adv"}
|
||||
assert config.priority == 5
|
@ -6,7 +6,7 @@ from nonebug import App
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(argnames="alias", argvalues=["版本规划", "原石预估"])
|
||||
async def test_get_primogems_data(app: App, alias):
|
||||
async def test_get_primogems_data(app: App, alias, load_etc: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
@ -37,7 +37,7 @@ async def test_get_primogems_data(app: App, alias):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_primogems_version(app: App):
|
||||
async def test_primogems_version(app: App, load_etc: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
@ -68,7 +68,7 @@ async def test_primogems_version(app: App):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_primogems_failed(app: App):
|
||||
async def test_primogems_failed(app: App, load_etc: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
||||
|
||||
@ -100,7 +100,7 @@ async def test_primogems_failed(app: App):
|
||||
"伤害乘区",
|
||||
],
|
||||
)
|
||||
async def test_get_img_data(app: App, alias):
|
||||
async def test_get_img_data(app: App, alias, load_etc: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
|
@ -13,7 +13,7 @@ from nonebug import App
|
||||
# "岩王爷攻略", # alias
|
||||
# ],
|
||||
# )
|
||||
# async def test_get_guide_pic(app: App, alias ):
|
||||
# async def test_get_guide_pic(app: App, alias, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
@ -35,7 +35,7 @@ from nonebug import App
|
||||
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_get_guide_pic_traveler(app: App ):
|
||||
# async def test_get_guide_pic_traveler(app: App, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
@ -57,7 +57,7 @@ from nonebug import App
|
||||
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_get_guide_pic_failed(app: App ):
|
||||
# async def test_get_guide_pic_failed(app: App, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message
|
||||
|
||||
@ -79,7 +79,7 @@ from nonebug import App
|
||||
"参考面板岩王爷", # alias
|
||||
],
|
||||
)
|
||||
async def test_get_bluekun_pic(app: App, alias):
|
||||
async def test_get_bluekun_pic(app: App, alias, load_guide: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
@ -104,7 +104,7 @@ async def test_get_bluekun_pic(app: App, alias):
|
||||
"冰",
|
||||
],
|
||||
)
|
||||
async def test_get_bluekun_pic_element(app: App, alias):
|
||||
async def test_get_bluekun_pic_element(app: App, alias, load_guide: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
|
@ -3,7 +3,7 @@ from nonebug import App
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_metadata(app: App):
|
||||
async def test_metadata(app: App, load_metadata: None):
|
||||
from GenshinUID.genshinuid_meta import __plugin_meta__
|
||||
|
||||
assert __plugin_meta__.name == 'GenshinUID'
|
||||
@ -13,7 +13,7 @@ async def test_metadata(app: App):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_register_menu(app: App):
|
||||
async def test_register_menu(app: App, load_metadata: None):
|
||||
from GenshinUID.genshinuid_meta import sub_menus, register_menu
|
||||
|
||||
@register_menu(
|
||||
@ -26,11 +26,10 @@ async def test_register_menu(app: App):
|
||||
async def _example() -> None:
|
||||
pass
|
||||
|
||||
menu = {
|
||||
"func": "test",
|
||||
"trigger_condition": "trigger",
|
||||
"trigger_method": "114514",
|
||||
"brief_des": "test register_menu",
|
||||
"detail_des": "test register_menu",
|
||||
}
|
||||
assert menu in sub_menus
|
||||
assert len(sub_menus) == 1
|
||||
menu = sub_menus[0]
|
||||
assert menu['func'] == 'test'
|
||||
assert menu['trigger_condition'] == 'trigger'
|
||||
assert menu['trigger_method'] == '114514'
|
||||
assert menu['brief_des'] == 'test register_menu'
|
||||
assert menu['detail_des'] == 'test register_menu'
|
||||
|
@ -1,9 +0,0 @@
|
||||
from nonebug import App
|
||||
|
||||
|
||||
def test_get_superusers(app: App):
|
||||
from GenshinUID.utils.nonebot2.utils import get_superusers
|
||||
|
||||
superusers = get_superusers()
|
||||
assert len(superusers) == 2
|
||||
assert set(superusers) == {10000, 10001}
|
Reference in New Issue
Block a user