Skip to content

Commit

Permalink
🔀 适配最新的main
Browse files Browse the repository at this point in the history
  • Loading branch information
AzideCupric committed Jun 11, 2024
1 parent f643e1f commit 9dd5309
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nonebot_plugin_saa/adapters/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from functools import partial
from contextlib import suppress
from typing import Any, Dict, List, Optional, cast
from typing import Any, Optional, cast

from nonebot.adapters import Event
from nonebot.drivers import Request
Expand All @@ -17,8 +17,8 @@
)

from ..auto_select_bot import register_list_targets
from ..utils import SupportedAdapters, SupportedPlatform
from ..types import Text, Image, Reply, Mention, MentionAll
from ..utils import SupportedAdapters, SupportedPlatform, type_message_id_check
from ..abstract_factories import (
MessageFactory,
register_ms_adapter,
Expand Down Expand Up @@ -114,7 +114,7 @@ async def _image(i: Image, bot: BaseBot) -> MessageSegment:

@register_discord(Reply)
def _reply(r: Reply) -> MessageSegment:
assert isinstance(mid := r.data["message_id"], DiscordMessageId)
mid = type_message_id_check(DiscordMessageId, r.data["message_id"])
return MessageSegment.reference(reference=mid.message_id)

@register_discord(Mention)
Expand All @@ -134,7 +134,7 @@ def _extract_msg_event(event: Event) -> TargetDiscordChannel:
return TargetDiscordChannel(channel_id=event.channel_id)

@register_convert_to_arg(adapter, SupportedPlatform.discord_channel)
def _gen_channel(target: PlatformTarget) -> Dict[str, Any]:
def _gen_channel(target: PlatformTarget) -> dict[str, Any]:
assert isinstance(target, TargetDiscordChannel)
return {
"channel_id": target.channel_id,
Expand All @@ -154,12 +154,12 @@ async def revoke(self, reason: Optional[str] = None):
async def edit(
self,
content: Optional[str] = None,
embeds: Optional[List[Embed]] = None,
embeds: Optional[list[Embed]] = None,
flags: Optional[MessageFlag] = None,
allowed_mentions: Optional[AllowedMention] = None,
components: Optional[List[DirectComponent]] = None,
files: Optional[List[File]] = None,
attachments: Optional[List[AttachmentSend]] = None,
components: Optional[list[DirectComponent]] = None,
files: Optional[list[File]] = None,
attachments: Optional[list[AttachmentSend]] = None,
) -> "DiscordReceipt":
mg = await cast(BotDiscord, self._get_bot()).edit_message(
channel_id=self.message_get.channel_id,
Expand Down Expand Up @@ -238,9 +238,9 @@ async def send(
return DiscordReceipt(message_get=resp, bot_id=bot.self_id)

@register_list_targets(adapter)
async def list_targets(bot: BaseBot) -> List[PlatformTarget]:
async def list_targets(bot: BaseBot) -> list[PlatformTarget]:
assert isinstance(bot, BotDiscord)
channel_ids: List[Snowflake] = []
channel_ids: list[Snowflake] = []
guild_list = await bot.get_current_user_guilds()
for guild in guild_list:
channels = await bot.get_guild_channels(guild_id=guild.id)
Expand Down

0 comments on commit 9dd5309

Please sign in to comment.