Skip to content

Commit

Permalink
🚀v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes4m committed Aug 12, 2024
1 parent 151b906 commit 3037d1e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
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.4.0"
__version__ = "0.4.1"
__plugin_meta__ = PluginMetadata(
name="bilifan",
description="b站粉丝牌~",
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_bilifan/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"ignore",
message="The localize method is no longer necessary, as this time zone supports the fold attribute",
)
# os.chdir(os.path.dirname(os.path.abspath(__file__)).split(__file__)[0])

base_path = Path().joinpath("data/bilifan")
base_path.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -58,6 +57,7 @@ async def read_yaml(msg_path: Path):
"WEARMEDAL": users["WEARMEDAL"],
"SIGNINGROUP": users.get("SIGNINGROUP", 2),
"LEVEN": users.get("LEVEN", 20),
"WHACHASYNER": users.get("WHACHASYNER", 1),
}
except Exception as e:
logger.error(f"读取配置文件失败,请检查配置文件格式是否正确: {e}")
Expand Down
60 changes: 32 additions & 28 deletions nonebot_plugin_bilifan/src/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
from loguru import logger
from nonebot.log import logger as log

# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# logger.remove()
# logger.add(
# sys.stdout,
# colorize=True,
# format="<green>{time:YYYY-MM-DD HH:mm:ss}</green> <blue> {extra[user]} </blue> <level>{message}</level>",
# backtrace=True,
# diagnose=True,
# )

global user


Expand Down Expand Up @@ -330,24 +319,39 @@ async def watchinglive(self):
log.info("每日观看不直播任务关闭")
return
HEART_MAX = self.config["WATCHINGLIVE"]
log.info(f"每日{HEART_MAX}分钟任务开始")
n = 0
for medal in self.medalsNeedDo:
n += 1
for heartNum in range(1, HEART_MAX + 1):
tasks = []
tasks.append(
self.api.heartbeat(
medal["room_info"]["room_id"], medal["medal"]["target_id"]
)
)
await asyncio.gather(*tasks)
if heartNum % 5 == 0:
log.info(
f"{medal['anchor_info']['nick_name']}{heartNum}次心跳包已发送({n}/{len(self.medalsNeedDo)})"
if self.config["WHACHASYNER"]:
log.info(f"每日{HEART_MAX}分钟任务开始")
n = 0
for medal in self.medalsNeedDo:
n += 1
for heartNum in range(1, HEART_MAX + 1):
tasks = []
tasks.append(
self.api.heartbeat(
medal["room_info"]["room_id"], medal["medal"]["target_id"]
)
)
await asyncio.sleep(60)
log.success(f"每日{HEART_MAX}分钟任务完成")
await asyncio.gather(*tasks)
if heartNum % 5 == 0:
log.info(
f"{medal['anchor_info']['nick_name']}{heartNum}次心跳包已发送({n}/{len(self.medalsNeedDo)})"
)
await asyncio.sleep(60)
log.success(f"每日{HEART_MAX}分钟任务完成")
# else:
# log.info(f"每日{HEART_MAX}分钟任务开始")
# for medal in self.medalsNeedDo:
# n += 1
# for heartNum in range(1, HEART_MAX + 1):
# tasks = self.api.heartbeat(
# medal["room_info"]["room_id"], medal["medal"]["target_id"]
# )
# if heartNum % 5 == 0:
# log.info(
# f"{medal['anchor_info']['nick_name']} 第{heartNum}次心跳包已发送({n}/{len(self.medalsNeedDo)})"
# )
# await asyncio.sleep(60)
# log.success(f"每日{HEART_MAX}分钟任务完成")

async def signInGroups(self):
if not self.config["SIGNINGROUP"]:
Expand Down
6 changes: 6 additions & 0 deletions nonebot_plugin_bilifan/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ WATCHINGLIVE: 25 # 总观看时长为未满20级牌子数*每直播间观看时

WEARMEDAL: 1 # 是否弹幕打卡时自动带上当前房间的粉丝牌,避免房间有粉丝牌等级禁言,默认关闭,设置为1则开启

WHACHASYNER: 1 # 是否异步观看直播间,默认异步观看,设置为0则依次同步观看。
# 说明:
# 由于2024年8月不允许同时观看计算了,异步观看只能从所有直播间随机选择一个进行计算
# 也就是说,例如你观看60分钟,那60分钟将随机分配到所有的牌子对应直播间上。
# 如果设置为0,则不异步观看,只是依次同步观看,如果设置20分钟时间,那么总时间是数量*20分钟

SIGNINGROUP: 0 # 应援团签到CD时间,单位秒,默认2秒,设置为0则不签到
# 说明:
# 本项目中的异步执行指的是:同时点赞或者分享所有直播间,速度非常快,但缺点就是可能会被B站吞掉亲密度,所以建议粉丝牌较少的用户开启异步执行
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot_plugin_bilifan"
version = "0.4.0"
version = "0.4.1"
description = "刷站粉丝牌子的机器人插件"
authors = ["Agnes_Digital <[email protected]>"]
license = "GPLv3"
Expand Down Expand Up @@ -31,6 +31,7 @@ pillow = ">=9.5.0"
aiohttp-socks = "^0.8.0"
pyyaml = "^6.0"
qrcode = "^7.4.2"
anyio = ">=3.6.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -39,7 +40,7 @@ build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 89
target-version = ["py39", "py310", "py311","py312"]
target-version = ["py39", "py310", "py311"]
include = '\.pyi?$'
# skip-string-normalization = true

Expand Down

0 comments on commit 3037d1e

Please sign in to comment.