Skip to content

Commit

Permalink
🔖 version 0.1.3
Browse files Browse the repository at this point in the history
optional channel name
  • Loading branch information
RF-Tar-Railt committed Oct 8, 2023
1 parent 3060031 commit 51ada25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions nonebot/adapters/satori/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class PrivateMessageCreatedEvent(MessageCreatedEvent, PrivateMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name}({self.channel.id}): {self.get_message()!r}"
f"{self.user.name or ''}({self.channel.id}): {self.get_message()!r}"
)


Expand All @@ -330,7 +330,7 @@ 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.channel.name}:{self.guild.id}/{self.channel.id}]"
f"@[{self.channel.name or ''}:{self.guild.id}/{self.channel.id}]"
f": {self.get_message()!r}"
)

Expand All @@ -340,7 +340,7 @@ class PrivateMessageDeletedEvent(MessageDeletedEvent, PrivateMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name}({self.channel.id}) deleted"
f"{self.user.name or ''}({self.channel.id}) deleted"
)


Expand All @@ -350,7 +350,7 @@ 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.channel.name}:{self.guild.id}/{self.channel.id}] deleted"
f"@[{self.channel.name or ''}:{self.guild.id}/{self.channel.id}] deleted"
)


Expand All @@ -359,7 +359,7 @@ class PrivateMessageUpdatedEvent(MessageUpdatedEvent, PrivateMessageEvent):
def get_event_description(self) -> str:
return escape_tag(
f"Message {self.msg_id} from "
f"{self.user.name}({self.channel.id}) updated"
f"{self.user.name or ''}({self.channel.id}) updated"
f": {self.get_message()!r}"
)

Expand All @@ -370,7 +370,7 @@ 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.channel.name}:{self.guild.id}/{self.channel.id}] updated"
f"@[{self.channel.name or ''}:{self.guild.id}/{self.channel.id}] updated"
f": {self.get_message()!r}"
)

Expand Down
14 changes: 7 additions & 7 deletions nonebot/adapters/satori/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ChannelType(IntEnum):

class Channel(BaseModel, extra=Extra.allow):
id: str
name: str
name: Optional[str] = None
type: ChannelType
parent_id: Optional[str] = None

Expand Down Expand Up @@ -48,8 +48,8 @@ def parse_joined_at(cls, v):
return v
try:
timestamp = int(v)
except ValueError:
raise ValueError(f"invalid timestamp: {v}")
except ValueError as e:
raise ValueError(f"invalid timestamp: {v}") from e
return datetime.fromtimestamp(timestamp / 1000)


Expand Down Expand Up @@ -164,8 +164,8 @@ def parse_created_at(cls, v):
return v
try:
timestamp = int(v)
except ValueError:
raise ValueError(f"invalid timestamp: {v}")
except ValueError as e:
raise ValueError(f"invalid timestamp: {v}") from e
return datetime.fromtimestamp(timestamp / 1000)

@validator("updated_at", pre=True)
Expand All @@ -176,8 +176,8 @@ def parse_updated_at(cls, v):
return v
try:
timestamp = int(v)
except ValueError:
raise ValueError(f"invalid timestamp: {v}")
except ValueError as e:
raise ValueError(f"invalid timestamp: {v}") from e
return datetime.fromtimestamp(timestamp / 1000)


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nonebot-adapter-satori"
version = "0.1.2"
version = "0.1.3"
description = "Satori Protocol Adapter for Nonebot2"
authors = [
{name = "RF-Tar-Railt",email = "rf_tar_railt@qq.com"},
Expand Down

0 comments on commit 51ada25

Please sign in to comment.