Skip to content

Commit

Permalink
Merge pull request #164 from Ailitonia/dev
Browse files Browse the repository at this point in the history
Releases: release v1.0.0
  • Loading branch information
Ailitonia authored Feb 10, 2025
2 parents a5d8485 + cd8c2c7 commit 8c64cb9
Show file tree
Hide file tree
Showing 97 changed files with 93,688 additions and 3,468 deletions.
2,653 changes: 1,759 additions & 894 deletions poetry.lock

Large diffs are not rendered by default.

50 changes: 40 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "omega-miya"
version = "0.9.1"
version = "1.0.0"
description = "基于 nonebot2 的多平台机器人"
authors = ["Ailitonia <[email protected]>"]
license = "MIT"
Expand All @@ -17,28 +17,29 @@ nonebot-adapter-onebot = ">=2.4.6,<2.5.0"
nonebot-adapter-qq = ">=1.6.0,<1.7.0"
nonebot-adapter-telegram = ">=0.1.0b20,<0.2.0"
nonebot-plugin-apscheduler = ">=0.5.0,<1.0.0"
sqlalchemy = ">=2.0.36,<3.0.0"
asyncmy = {version = ">=0.2.9,<1.0.0", optional = true}
aiomysql = {version = ">=0.2.0,<1.0.0", optional = true}
sqlalchemy = ">=2.0.36,<2.1.0"
asyncmy = { version = ">=0.2.9,<1.0.0", optional = true }
aiomysql = { version = ">=0.2.0,<1.0.0", optional = true }
asyncpg = { version = ">=0.30.0,<1.0.0", optional = true }
aiosqlite = {version = ">=0.20.0,<1.0.0", optional = true}
aiosqlite = { version = ">=0.20.0,<1.0.0", optional = true }
apscheduler = ">=3.11.0,<4.0.0"
aiofiles = ">=24.0.0,<25.0.0"
ujson = ">=5.10.0,<6.0.0"
lxml = ">=5.3.0,<6.0.0"
msgpack = ">=1.0.8,<2.0.0"
numpy = ">=2.1.3,<3.0.0"
numpy = ">=2.2.0,<3.0.0"
openpyxl = ">=3.1.2,<4.0.0"
pandas = ">=2.2.0,<3.0.0"
matplotlib = ">=3.10.0,<4.0.0"
pillow = ">=11.0.0,<12.0.0"
imageio = ">=2.36.0,<3.0.0"
pillow = ">=11.1.0,<12.0.0"
imageio = ">=2.37.0,<3.0.0"
psutil = ">=6.1.0,<7.0.0"
pycryptodome = ">=3.21.0,<4.0.0"
py7zr = ">=0.21.0,<1.0.0"
pytz = "^2024.2"
zhconv = ">=1.4.3,<2.0.0"
rapidfuzz = ">=3.11.0,<4.0.0"
emoji = ">=2.14.0,<3.0.0"
openpyxl = ">=3.1.2,<4.0.0"
qrcode = { extras = ["pil"], version = ">=8.0.0,<9.0.0" }
onedice = "1.0.7"
jieba = ">=0.42.1,<1.0.0"
Expand All @@ -53,14 +54,43 @@ sqlite = ["aiosqlite"]

[tool.poetry.group.dev.dependencies]
mypy = ">=1.14.0,<2.0.0"
ruff = ">=0.8.4,<1.0.0"
ruff = ">=0.9.5,<1.0.0"
bump-pydantic = "^0.8.0"
types-lxml = "^2024.3.27"
lxml-stubs = "^0.5.1"
alembic = "^1.14.0"
memory-profiler = ">=0.61.0,<1.0.0"


[[tool.poetry.source]]
name = "清华"
url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
priority = "primary"


[[tool.poetry.source]]
name = "PyPI"
priority = "supplemental"


[[tool.poetry.source]]
name = "中国科大"
url = "https://mirrors.ustc.edu.cn/pypi/simple/"
priority = "explicit"


[[tool.poetry.source]]
name = "阿里云"
url = "https://mirrors.aliyun.com/pypi/simple/"
priority = "explicit"


[[tool.poetry.source]]
name = "腾讯云"
url = "http://mirrors.cloud.tencent.com/pypi/simple/"
priority = "explicit"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/bilibili_account_manager/scheduled_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from nonebot import get_driver, logger

from src.service import scheduler
from src.utils import run_async_with_time_limited
from src.utils.bilibili_api import BilibiliCredential


Expand Down Expand Up @@ -56,8 +57,8 @@ async def _load_and_refresh_bilibili_login_status() -> None:
second='23',
id='bilibili_login_status_refresh_monitor',
coalesce=True,
misfire_grace_time=120
)
@run_async_with_time_limited(delay_time=300)
async def _bilibili_login_status_refresh_monitor() -> None:
try:
await _refresh_bilibili_login_status()
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bilibili_dynamic_monitor/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing import Literal

from src.database.internal.subscription_source import SubscriptionSourceType
from src.utils.bilibili_api.future.models.dynamic import DynamicType
from src.utils.bilibili_api.models.dynamic import DynamicType

# 订阅相关
BILI_DYNAMIC_SUB_TYPE: str = SubscriptionSourceType.bili_dynamic.value
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bilibili_dynamic_monitor/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if TYPE_CHECKING:
from src.database.internal.entity import Entity
from src.database.internal.subscription_source import SubscriptionSource
from src.utils.bilibili_api.future.models.dynamic import DynItem
from src.utils.bilibili_api.models.dynamic import DynItem


async def _query_dynamic_sub_source(user_id: int | str) -> 'SubscriptionSource':
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/bilibili_dynamic_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from src.exception import PluginException, WebSourceException
from src.service import scheduler
from src.utils import semaphore_gather
from src.utils import run_async_with_time_limited, semaphore_gather
from .consts import AVERAGE_CHECKING_PER_MINUTE, CHECKING_DELAY_UNDER_RATE_LIMITING, MONITOR_JOB_ID
from .helpers import bili_dynamic_monitor_main, query_all_subscribed_dynamic_sub_source

Expand Down Expand Up @@ -51,6 +51,7 @@ async def _get_next_check_uid(num: int) -> list[int]:
return [await _UID_CHECKING_QUEUE.get() for _ in range(min(num, _UID_CHECKING_QUEUE.qsize()))]


@run_async_with_time_limited(delay_time=240)
async def bili_dynamic_update_monitor() -> None:
"""Bilibili 用户动态订阅 动态更新监控"""
logger.debug('BilibiliDynamicMonitor | Started checking bilibili user dynamics update from queue')
Expand Down Expand Up @@ -93,7 +94,8 @@ async def bili_dynamic_update_monitor() -> None:
# timezone=None,
id=MONITOR_JOB_ID,
coalesce=True,
misfire_grace_time=120
max_instances=2,
misfire_grace_time=120,
)


Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bilibili_live_monitor/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .model import BilibiliLiveRoomStatus, BilibiliLiveRoomStatusUpdate

if TYPE_CHECKING:
from src.utils.bilibili_api.future.models.live import RoomInfoData
from src.utils.bilibili_api.models.live import RoomInfoData


__LIVE_ROOM_STATUS: dict[str, BilibiliLiveRoomStatus] = {}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bilibili_live_monitor/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if TYPE_CHECKING:
from src.database.internal.entity import Entity
from src.database.internal.subscription_source import SubscriptionSource
from src.utils.bilibili_api.future.models.live import RoomInfoData
from src.utils.bilibili_api.models.live import RoomInfoData


async def _query_room_sub_source(room_id: int | str) -> 'SubscriptionSource':
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/bilibili_live_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from nonebot.log import logger

from src.service import scheduler
from src.utils import run_async_with_time_limited
from .helpers import bili_live_room_monitor_main


@run_async_with_time_limited(delay_time=120)
async def bili_live_room_update_monitor() -> None:
"""Bilibili 直播间订阅 直播间更新监控"""
logger.debug('BilibiliLiveRoomSubscriptionMonitor | Started checking bilibili live room update')
Expand Down Expand Up @@ -42,7 +44,8 @@ async def bili_live_room_update_monitor() -> None:
# timezone=None,
id='bili_live_room_update_monitor',
coalesce=True,
misfire_grace_time=20
max_instances=2,
misfire_grace_time=60,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from nonebot import get_driver, logger

from src.service import scheduler
from src.utils import run_async_with_time_limited
from .sites import (
BooruArtworksUpdater,
LocalCollectedArtworkUpdater,
Expand All @@ -29,6 +30,7 @@ async def artwork_collection_updater_startup_task() -> None:
logger.error(f'OmegaArtworkCollectionUpdater | Updating from LocalCollectedArtwork failed, {e!r}')


@run_async_with_time_limited(delay_time=240)
async def artwork_collection_updater_main() -> None:
logger.debug('OmegaArtworkCollectionUpdater | Starting update from LoliconAPI')
try:
Expand Down Expand Up @@ -82,7 +84,8 @@ async def artwork_collection_updater_main() -> None:
# timezone=None,
id='artwork_collection_updater',
coalesce=True,
misfire_grace_time=120
max_instances=1,
misfire_grace_time=120,
)

__all__ = [
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/omega_sign_in/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ def _handle_signin_card() -> bytes:

# 总高度
if draw_fortune:
height = (top_img_height + top_text_height + user_text_height + level_text_height +
fortune_text_height * 3 + fortune_star_height * 6 + bottom_text_height * 6 +
int(0.41625 * width))
height = int(top_img_height + top_text_height + user_text_height + level_text_height
+ fortune_text_height * 3 + fortune_star_height * 6 + bottom_text_height * 6
+ 0.41625 * width)
else:
height = (top_img_height + top_text_height + user_text_height + level_text_height +
fortune_text_height * 1 + fortune_star_height * 2 + bottom_text_height * 6 +
int(0.25125 * width))
height = int(top_img_height + top_text_height + user_text_height + level_text_height
+ fortune_text_height * 1 + fortune_star_height * 2 + bottom_text_height * 6
+ 0.25125 * width)

if head_img is not None:
height += int(0.03125 * width)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/onebot_v11_group_welcome_message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@Project : nonebot2_miya
@Description : QQ 群自定义欢迎消息
@GitHub : https://github.com/Ailitonia
@Software : PyCharm
@Software : PyCharm
"""

from nonebot.plugin import PluginMetadata
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/onebot_v11_group_welcome_message/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
@Author : Ailitonia
@Date : 2021/08/14 19:09
@FileName : omega_welcome_message.py
@Project : nonebot2_miya
@Project : nonebot2_miya
@Description : 群自定义欢迎消息
@GitHub : https://github.com/Ailitonia
@Software : PyCharm
@Software : PyCharm
"""

from typing import Annotated, Literal
Expand All @@ -27,6 +27,7 @@
from nonebot.params import Arg, Depends
from nonebot.permission import SUPERUSER
from nonebot.plugin import CommandGroup, on_notice
from sqlalchemy.exc import NoResultFound

from src.params.handler import get_command_message_arg_parser_handler
from src.params.rule import event_has_permission_level
Expand Down Expand Up @@ -121,14 +122,16 @@ async def handle_send_welcome_message(
)

if welcome_message_setting.value is None or welcome_message_setting.available != 1:
logger.info(f'{interface.entity}, 有新用户: {event.user_id} 进群, 未配置欢迎消息, 跳过发送欢迎消息流程')
logger.info(f'{interface.entity}, 有新用户: {event.user_id} 进群, 未启用欢迎消息, 跳过发送欢迎消息流程')
return

logger.info(f'{interface.entity}, 有新用户: {event.user_id} 进群, 发送欢迎消息')
send_message = OmegaMessage.loads(message_data=welcome_message_setting.value)
await interface.send_at_sender(message=send_message)
except NoResultFound:
logger.info(f'{interface.entity}, 有新用户: {event.user_id} 进群, 该群未配置欢迎消息, 跳过发送欢迎消息流程')
except Exception as e:
logger.error(f'{interface.entity} 获取自定义欢迎消息配置失败, 或发送消息失败, {e!r}')
logger.error(f'{interface.entity} 有新用户: {event.user_id} 进群, 获取欢迎消息配置失败, 或发送消息失败, {e}')


__all__ = []
2 changes: 1 addition & 1 deletion src/plugins/pixiv_artist_monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'/pixiv用户订阅列表\n\n'
'仅限私聊或群聊中群管理员使用:\n'
'/pixiv用户订阅 <UID>\n'
'/pixiv取消用户订阅 <UID>',
'/取消pixiv用户订阅 <UID>',
extra={'author': 'Ailitonia'},
)

Expand Down
6 changes: 4 additions & 2 deletions src/plugins/pixiv_artist_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
from nonebot.log import logger

from src.service import scheduler
from src.utils import semaphore_gather
from src.utils import run_async_with_time_limited, semaphore_gather
from src.utils.pixiv_api import PixivUser
from .helpers import pixiv_user_new_artworks_monitor_main, query_all_subscribed_pixiv_user_sub_source


@run_async_with_time_limited(delay_time=300)
async def pixiv_user_new_artworks_monitor() -> None:
"""Pixiv 用户订阅 作品更新监控"""
logger.debug('PixivUserSubscriptionMonitor | Started checking pixiv user artworks update')
Expand Down Expand Up @@ -49,7 +50,8 @@ async def pixiv_user_new_artworks_monitor() -> None:
# timezone=None,
id='pixiv_user_new_artworks_monitor',
coalesce=True,
misfire_grace_time=120
max_instances=1,
misfire_grace_time=300,
)


Expand Down
24 changes: 18 additions & 6 deletions src/plugins/pixiv_pixivision_monitor/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,24 @@ async def generate_pixivision_illustration_list_preview(page: int = 1) -> 'Tempo

async def _generate_pixivision_article_preview(title: str, article_data: 'PixivisionArticle') -> 'TemporaryResource':
"""根据 Pixivision 特辑内容生成预览图"""
return await PixivArtworkProxy.generate_artworks_preview(
preview_name=title,
artworks=[PixivArtworkProxy(x.artwork_id) for x in article_data.artwork_list],
preview_size=(512, 512),
num_of_line=4,
)
if article_data.illustration_list:
return await PixivArtworkProxy.generate_any_images_preview(
preview_name=title,
image_data=[
(x.thumbnail, f'ArticleID: {x.aid}\n{x.split_title_without_mark}')
for x in article_data.illustration_list
],
preview_size=(480, 270),
hold_ratio=True,
num_of_line=4,
)
else:
return await PixivArtworkProxy.generate_artworks_preview(
preview_name=title,
artworks=[PixivArtworkProxy(x.artwork_id) for x in article_data.artwork_list],
preview_size=(512, 512),
num_of_line=4,
)


async def format_pixivision_article_message(article: Pixivision, msg_prefix: str | None = None) -> str | OmegaMessage:
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/pixiv_pixivision_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from nonebot.log import logger

from src.service import scheduler
from src.utils import run_async_with_time_limited
from .helpers import pixivision_monitor_main


@run_async_with_time_limited(delay_time=300)
async def pixivision_article_monitor() -> None:
logger.debug('PixivisionArticleMonitor | Start checking new pixivision articles')

Expand Down Expand Up @@ -42,7 +44,8 @@ async def pixivision_article_monitor() -> None:
# timezone=None,
id='pixivision_article_monitor',
coalesce=True,
misfire_grace_time=120
max_instances=1,
misfire_grace_time=300,
)


Expand Down
4 changes: 2 additions & 2 deletions src/plugins/sticker_maker/render/renders.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _core_render(
_, text_h = ImageUtils.get_text_size(text=text_main_fin, font=font)

# 处理图片
background_h = int(image.height * 1.08) + text_h
background_h = int(image.height * 1.08 + text_h)
background = Image.new(mode='RGB', size=(image.width, background_h), color=(255, 255, 255))

# 处理粘贴位置 顶头
Expand Down Expand Up @@ -217,7 +217,7 @@ def _core_render(

# 生成图片定长 两部分文字之间间隔及两侧留空为固定值三个空格大小
split_width, _ = ImageUtils.get_text_size(' ', font)
image_width = w_text_width + y_text_width + int(split_width * 5.5)
image_width = int(w_text_width + y_text_width + split_width * 5.5)
image_height = int(text_height * 2.25)

# 计算黄色圆角矩形所在位置
Expand Down
Loading

0 comments on commit 8c64cb9

Please sign in to comment.