Skip to content

Commit

Permalink
💄 auto fix by pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 7, 2024
1 parent 79cb15f commit 71f1c25
Show file tree
Hide file tree
Showing 9 changed files with 13,736 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ _✨ 用于每日早八定时签到森空岛明日方舟的Nonebot插件 ✨_
</div>

## 💿 安装

根据数美 device ID 获取的方法的不同,可选择以下版本(区别下述):

```bash
nb plugin install nonebot-plugin-skland-arksign
nb plugin install nonebot-plugin-skland-arksign[sm_local]
Expand Down Expand Up @@ -87,7 +89,6 @@ nb plugin install nonebot-plugin-skland-arksign[sm_htmlrender]

**额外安装插件**[`nonebot-plugin-htmlrender`](https://github.com/kexue-z/nonebot-plugin-htmlrender)


安装:`nb plugin install nonebot-plugin-skland-arksign[sm_htmlrender]`

配置:`skland_sm_method_identifier = 2`
Expand Down
6 changes: 4 additions & 2 deletions nonebot_plugin_skland_arksign/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nonebot import require, logger
from nonebot import logger, require
from nonebot.plugin import PluginMetadata, inherit_supported_adapters

require("nonebot_plugin_apscheduler")
Expand All @@ -11,15 +11,17 @@
from nonebot_plugin_saa import enable_auto_select_bot

from . import migrations
from .config import plugin_config
from .command import skland as skland
from .sched import scheduler as scheduler
from .config import plugin_config

if plugin_config.skland_sm_method_identifier == 0:
logger.info("选用 dId 获取方案:retrieval-server api")
elif plugin_config.skland_sm_method_identifier == 1:
logger.info("选用 dId 获取方案:本地 Python 原生模拟")
try:
import cryptography as cryptography

from .did import local_simulate as local_simulate
except Exception:
logger.warning("请安装 nonebot-plugin-skland-arksign[sm_local]!")
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_skland_arksign/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Literal

from pydantic import BaseModel
from nonebot import get_plugin_config

Expand All @@ -12,7 +13,6 @@ class Config(BaseModel):
skland_sm_method_identifier: Literal[0, 1, 2] = 0
skland_sm_api_endpoint: str = "https://skland-did-retrieval-server.gugumur.eu.org/did"


@property
def init_des(self) -> str:
if self.skland_arksign_allow_group is True:
Expand Down
3 changes: 1 addition & 2 deletions nonebot_plugin_skland_arksign/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def REQUEST_HEADERS_BASE(self) -> dict[str, str]:
"Content-Type": "application/json; charset=utf-8",
"manufacturer": "Xiaomi",
"os": "33",
"dId": ""
"dId": "",
}

@property
Expand All @@ -41,5 +41,4 @@ def SM_CONFIG(self) -> dict[str, str]:
}



CONSTANTS = _CONSTANTS()
2 changes: 2 additions & 0 deletions nonebot_plugin_skland_arksign/did/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# ID: 0
from httpx import AsyncClient

from ..config import plugin_config


async def get_did() -> str:
if plugin_config.skland_use_web_timestamp:
async with AsyncClient() as client:
Expand Down
4 changes: 3 additions & 1 deletion nonebot_plugin_skland_arksign/did/html_simulate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# ID: 2
from nonebot import require
from pathlib import Path

from nonebot import require

from ...config import plugin_config

if plugin_config.skland_sm_method_identifier == 2:
require("nonebot_plugin_htmlrender")
from nonebot_plugin_htmlrender import get_new_page

async def get_did() -> str:
async with get_new_page() as page:
path = Path(__file__).parent / "static"
Expand Down
13,718 changes: 13,717 additions & 1 deletion nonebot_plugin_skland_arksign/did/html_simulate/static/fp.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions nonebot_plugin_skland_arksign/did/local_simulate.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# ID: 1
# 来自https://gitee.com/FancyCabbage/skyland-auto-sign/blob/master/SecuritySm.py
# 协议:MIT(https://gitee.com/FancyCabbage/skyland-auto-sign/blob/master/LICENSE)
import base64
import gzip
import hashlib

# 数美加密方法类
import json
import time
import uuid
import base64
import hashlib

from httpx import AsyncClient
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES
from cryptography.hazmat.primitives.ciphers.base import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import CBC, ECB
from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES

# 查询dId请求头
devices_info_url = "https://fp-it.portal101.cn/deviceprofile/v4"
Expand Down
2 changes: 2 additions & 0 deletions nonebot_plugin_skland_arksign/signin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
from .did.local_simulate import get_did as get_did
except Exception:
from .did.api import get_did as get_did

logger.warning("请安装 nonebot-plugin-skland-arksign[sm_local]!")
elif plugin_config.skland_sm_method_identifier == 2:
try:
from .did.html_simulate import get_did as get_did
except Exception:
from .did.api import get_did as get_did

logger.warning("请安装 nonebot-plugin-skland-arksign[sm_htmlrender]!")


Expand Down

0 comments on commit 71f1c25

Please sign in to comment.