Skip to content

Commit

Permalink
🚀v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes4m committed May 1, 2024
1 parent a9b7121 commit ebccdc7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ _✨自动b站粉丝牌✨_
<img src="https://img.shields.io/badge/nonebot-2.0.0-red.svg" alt="NoneBot">
</div>

## 最新说明

- 已经可以正常使用和登录了,只是输出log暂时有问题

## 配置说明

启动一次插件,在bot路径下,"data/bilifan"文件夹内,按需求修改"users.yaml"文件
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_bilifan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


driver = get_driver()
__version__ = "0.3.3"
__version__ = "0.3.4"
__plugin_meta__ = PluginMetadata(
name="bilifan",
description="b站粉丝牌~",
Expand Down
16 changes: 9 additions & 7 deletions nonebot_plugin_bilifan/login/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def get_tv_qrcode_url_and_auth_code():
code = resp_data["code"]
if code == 0:
login_url = resp_data["data"]["url"]
login_key = resp_data["data"]["qrcode_key"]
login_key = resp_data["data"]["auth_code"]
return login_url, login_key
raise Exception("get_tv_qrcode_url_and_auth_code error")

Expand Down Expand Up @@ -99,19 +99,21 @@ async def verify_login(login_key: str, data_path: Path):
data_path / "users.yaml",
)
config = yaml.safe_load(
await anyio.Path(data_path / "users.yaml").read_text("u8")
await anyio.Path(data_path / "users.yaml").read_text("u8"),
)
# with Path(data_path / "users.yaml").open(
# "r", encoding="utf-8"
# ) as f:
# config = yaml.safe_load(f)

config["USERS"][0]["access_key"] = access_key
config = yaml.dump(
await anyio.Path(data_path / "users.yaml").write_text("u8"),
yaml_string = yaml.dump(
config,
allow_unicode=True,
default_flow_style=False,
)
await anyio.Path(data_path / "users.yaml").write_text(yaml_string, "u8")

# with Path(data_path / "users.yaml").open(
# "w", encoding="utf-8"
# ) as f: # noqa: ASYNC101
Expand All @@ -124,7 +126,7 @@ async def verify_login(login_key: str, data_path: Path):
appsec = "59b43e04ad6965f34319062b478f83dd"


async def signature(params: dict):
async def signature(params: dict): # noqa: RUF029
keys = list(params.keys())
params["appkey"] = appkey
keys.append("appkey")
Expand All @@ -135,11 +137,11 @@ async def signature(params: dict):
params["sign"] = hash_.hexdigest()


async def map_to_string(params: dict) -> str:
async def map_to_string(params: dict) -> str: # noqa: RUF029
return "&".join([k + "=" + v for k, v in params.items()])


async def draw_QR(login_url: str): # noqa: N802
async def draw_QR(login_url: str): # noqa: N802, RUF029
"绘制二维码"
qr = qrcode.QRCode(version=1, box_size=10, border=4) # type: ignore
qr.add_data(login_url)
Expand Down
11 changes: 6 additions & 5 deletions nonebot_plugin_bilifan/src/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def getMedals(self):
if self.whiteList == [0]:
if medal["medal"]["target_id"] in self.bannedList:
log.warning(
f"{medal['anchor_info']['nick_name']} 在黑名单中,已过滤"
f"{medal['anchor_info']['nick_name']} 在黑名单中,已过滤",
)
continue
self.medals.append(medal) if medal["room_info"]["room_id"] != 0 else ...
Expand All @@ -123,7 +123,7 @@ async def getMedals(self):
else ...
)
log.success(
f"{medal['anchor_info']['nick_name']} 在白名单中,加入任务"
f"{medal['anchor_info']['nick_name']} 在白名单中,加入任务",
)
[
self.medalsNeedDo.append(medal)
Expand Down Expand Up @@ -224,7 +224,7 @@ async def asynclikeandShare(self, failedMedals: list = []): # noqa: B006
log.warning("成功率过低,重新执行任务")
self.retryTimes += 1
log.warning(
"重试次数: {}/{}".format(self.retryTimes, self.maxRetryTimes)
"重试次数: {}/{}".format(self.retryTimes, self.maxRetryTimes),
)
await self.asynclikeandShare(failedMedals)
except Exception:
Expand Down Expand Up @@ -325,8 +325,9 @@ async def sendDanmaku(self):
except Exception as e:
log.error(
"{} 房间弹幕打卡失败: {}".format(
medal["anchor_info"]["nick_name"], e
)
medal["anchor_info"]["nick_name"],
e,
),
)
self.errmsg.append(
f"【{self.name}{medal['anchor_info']['nick_name']} 房间弹幕打卡失败: {e!s}",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot_plugin_bilifan"
version = "0.3.3"
version = "0.3.4"
description = "刷站粉丝牌子的机器人插件"
authors = ["Agnes_Digital <[email protected]>"]
license = "GPLv3"
Expand Down

0 comments on commit ebccdc7

Please sign in to comment.