Skip to content

Commit

Permalink
🐛 fix event.description
Browse files Browse the repository at this point in the history
resolve #23
  • Loading branch information
RF-Tar-Railt committed Jun 5, 2024
1 parent 0000527 commit 01a6b19
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 91 deletions.
2 changes: 1 addition & 1 deletion nonebot/adapters/satori/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .utils import API, log
from .config import ClientInfo
from .event import Event, MessageEvent
from .models import InnerMessage as SatoriMessage
from .models import MessageObject as SatoriMessage
from .message import Author, Message, RenderMessage, MessageSegment
from .models import Role, User, Guild, Login, Member, Channel, PageResult
from .exception import (
Expand Down
8 changes: 4 additions & 4 deletions nonebot/adapters/satori/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .compat import model_validator
from .models import Event as SatoriEvent
from .message import Message, RenderMessage
from .models import InnerMessage as SatoriMessage
from .models import MessageObject as SatoriMessage
from .models import ArgvInteraction, ButtonInteraction
from .models import Guild, Login, Member, Channel, ChannelType

Expand Down Expand Up @@ -334,7 +334,7 @@ class PublicMessageCreatedEvent(MessageCreatedEvent, PublicMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name or ''}({self.channel.id})"
f"{self.member.name if self.member else (self.user.name or '')}({self.user.id})"
f"@[{self.channel.name or ''}:{self.channel.id}]"
f": {self.get_message()!r}"
)
Expand All @@ -351,7 +351,7 @@ class PublicMessageDeletedEvent(MessageDeletedEvent, PublicMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name or ''}({self.channel.id})"
f"{self.member.name if self.member else (self.user.name or '')}({self.user.id})"
f"@[{self.channel.name or ''}:{self.channel.id}] deleted"
)

Expand All @@ -371,7 +371,7 @@ class PublicMessageUpdatedEvent(MessageUpdatedEvent, PublicMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name or ''}({self.channel.id})"
f"{self.member.name if self.member else (self.user.name or '')}({self.user.id})"
f"@[{self.channel.name or ''}:{self.channel.id}] updated"
f": {self.get_message()!r}"
)
Expand Down
9 changes: 2 additions & 7 deletions nonebot/adapters/satori/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PongPayload(Payload):
op: Literal[Opcode.PONG] = Field(Opcode.PONG)


class InnerMessage(BaseModel):
class MessageObject(BaseModel):
id: str
content: str
channel: Optional[Channel] = None
Expand Down Expand Up @@ -228,11 +228,6 @@ class Config:
extra = "allow"


class OuterMessage(InnerMessage):
channel: Channel
user: User


class Event(BaseModel):
id: int
type: str
Expand All @@ -245,7 +240,7 @@ class Event(BaseModel):
guild: Optional[Guild] = None
login: Optional[Login] = None
member: Optional[Member] = None
message: Optional[InnerMessage] = None
message: Optional[MessageObject] = None
operator: Optional[User] = None
role: Optional[Role] = None
user: Optional[User] = None
Expand Down
Loading

0 comments on commit 01a6b19

Please sign in to comment.