Skip to content

Commit

Permalink
⬆️ auto update by pre-commit hooks (#36)
Browse files Browse the repository at this point in the history
* ⬆️ auto update by pre-commit hooks

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Feb 18, 2024
1 parent bb3c762 commit 02cd16f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
stages: [commit]
Expand Down
4 changes: 1 addition & 3 deletions nonebot_plugin_all4one/middlewares/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ async def get_self_info(
"""获取机器人自身信息"""
raise NotImplementedError

async def get_user_info(
self, *, user_id: str, **kwargs: Any
) -> Dict[
async def get_user_info(self, *, user_id: str, **kwargs: Any) -> Dict[
Union[Literal["user_id", "user_name", "user_displayname", "user_remark"], str],
str,
]:
Expand Down
45 changes: 25 additions & 20 deletions nonebot_plugin_all4one/middlewares/qqguild.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ async def send_message(
# NoneBot 的默认 API_TIMEOUT 为 30s,这里设置为 25s
result = await e.get_audit_result(timeout=25)
if result.message_id is None:
raise ob_exception.PlatformError("failed", 34001, "消息审核未通过", None)
raise ob_exception.PlatformError(
"failed", 34001, "消息审核未通过", None
)
time = result.audit_time.timestamp() # type: ignore
message_id = {
"message_id": result.message_id,
Expand Down Expand Up @@ -351,9 +353,9 @@ async def get_guild_member_info(
"user_displayname": member.nick or "",
"qqguild.user": member.user.dict() if member.user else None,
"qqguild.roles": member.roles,
"qqguild.joined_at": member.joined_at.timestamp()
if member.joined_at
else None,
"qqguild.joined_at": (
member.joined_at.timestamp() if member.joined_at else None
),
}

async def _get_all_members(self, guild_id: str) -> List[Member]:
Expand Down Expand Up @@ -388,9 +390,9 @@ async def get_guild_member_list(
"user_displayname": member.nick or "",
"qqguild.user": member.user.dict() if member.user else None,
"qqguild.roles": member.roles,
"qqguild.joined_at": member.joined_at.timestamp()
if member.joined_at
else None,
"qqguild.joined_at": (
member.joined_at.timestamp() if member.joined_at else None
),
}
)
return members_list
Expand Down Expand Up @@ -425,15 +427,15 @@ async def get_channel_list(
{
"channel_id": str(channel.id) if channel.id else "",
"channel_name": channel.name or "",
"qqguild.guild_id": str(channel.guild_id)
if channel.guild_id
else "",
"qqguild.guild_id": (
str(channel.guild_id) if channel.guild_id else ""
),
"qqguild.channel_type": channel.type,
"qqguild.position": channel.position,
"qqguild.parent_id": channel.parent_id,
"qqguild.owner_id": str(channel.owner_id)
if channel.owner_id
else "",
"qqguild.owner_id": (
str(channel.owner_id) if channel.owner_id else ""
),
"qqguild.sub_type": channel.sub_type,
"qqguild.private_type": channel.private_type,
}
Expand All @@ -449,7 +451,10 @@ async def set_channel_name(
@supported_action
async def get_channel_member_info(
self, *, guild_id: str, channel_id: str, user_id: str, **kwargs: Any
) -> Dict[Union[Literal["user_id", "user_name", "user_displayname"], str], Any,]:
) -> Dict[
Union[Literal["user_id", "user_name", "user_displayname"], str],
Any,
]:
member = await self.bot.get_member(guild_id=int(guild_id), user_id=int(user_id))
if member.user is None:
raise ob_exception.PlatformError("failed", 34001, "用户不存在", None)
Expand All @@ -460,9 +465,9 @@ async def get_channel_member_info(
"user_displayname": member.nick or "",
"qqguild.user": member.user.dict() if member.user else {},
"qqguild.roles": member.roles,
"qqguild.joined_at": member.joined_at.timestamp()
if member.joined_at
else None,
"qqguild.joined_at": (
member.joined_at.timestamp() if member.joined_at else None
),
}

@supported_action
Expand Down Expand Up @@ -517,9 +522,9 @@ def can_view(member: Member) -> bool:
"user_displayname": member.nick or "",
"qqguild.user": member.user.dict() if member.user else {},
"qqguild.roles": member.roles,
"qqguild.joined_at": member.joined_at.timestamp()
if member.joined_at
else None,
"qqguild.joined_at": (
member.joined_at.timestamp() if member.joined_at else None
),
}
)
return members_list
Expand Down
12 changes: 6 additions & 6 deletions nonebot_plugin_all4one/middlewares/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ async def to_onebot_event(self, event: Event) -> List[OneBotEvent]:
0,
OneBotMessageSegment.reply(
f"{event.reply_to_message.chat.id}/{event.reply_to_message.message_id}",
user_id=event.reply_to_message.get_user_id()
if not isinstance(event.reply_to_message, ChannelPostEvent)
else "",
user_id=(
event.reply_to_message.get_user_id()
if not isinstance(event.reply_to_message, ChannelPostEvent)
else ""
),
),
)
elif isinstance(event, NoticeEvent):
Expand Down Expand Up @@ -219,9 +221,7 @@ async def get_self_info(
}

@supported_action
async def get_user_info(
self, *, user_id: str, **kwargs: Any
) -> Dict[
async def get_user_info(self, *, user_id: str, **kwargs: Any) -> Dict[
Union[Literal["user_id", "user_name", "user_displayname", "user_remark"], str],
str,
]:
Expand Down
1 change: 1 addition & 0 deletions nonebot_plugin_all4one/migrations/6e6321bc6c48_init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-02-20 21:50:33.023674
"""

import sqlalchemy as sa
from alembic import op

Expand Down
1 change: 1 addition & 0 deletions nonebot_plugin_all4one/migrations/d0a1d19f3408_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-02-26 14:09:17.473872
"""

import sqlalchemy as sa
from alembic import op

Expand Down
6 changes: 3 additions & 3 deletions nonebot_plugin_all4one/onebotimpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ async def _handle_ws(self, conn: WebsocketConfig, websocket: WebSocket) -> None:

async def _http_webhook(self, conn: HTTPWebhookConfig):
headers = {
"Content-Type": "application/msgpack"
if conn.use_msgpack
else "application/json",
"Content-Type": (
"application/msgpack" if conn.use_msgpack else "application/json"
),
"User-Agent": "OneBot/12 NoneBot Plugin All4One/0.1.0",
"X-OneBot-Version": "12",
"X-Impl": "nonebot-plugin-all4one",
Expand Down
3 changes: 2 additions & 1 deletion tests/middlewares/villa/test_villa.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ async def test_to_onebot_event(app: App):
assert channel_create.message_id == "C9G5-O2GK-FJB9-EVB0"
assert channel_create.channel_id == "39761"
assert (
channel_create.alt_message == "<mention_robot:bot_nUcp9kz0I2AhxZGVQDUQ>/帮助"
channel_create.alt_message
== "<mention_robot:bot_nUcp9kz0I2AhxZGVQDUQ>/帮助"
)

0 comments on commit 02cd16f

Please sign in to comment.