Skip to content

Commit

Permalink
fix: no comment causes /comment list break
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Nov 11, 2023
1 parent f3dcd6e commit 88198ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Qzone3TG"
version = "0.9.4.dev2"
version = "0.9.4.dev3"
description = "Forward Qzone feeds to telegram."
authors = ["aioqzone <zzzzss990315@gmail.com>"]
readme = "README.md"
Expand Down
22 changes: 16 additions & 6 deletions src/qzone3tg/app/interact/_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,35 @@ async def query_fid(mid: int):
await message.reply(**COMMENT_CMD_HELP.as_kwargs())
return

match command.args.split():
match command.args.split(maxsplit=1):
case ["add", content]:
if orm := await query_fid(reply.message_id):
await self.qzone.add_comment(orm.uin, orm.fid, orm.appid, content)
case ["add", "private", content]:
if orm := await query_fid(reply.message_id):
await self.qzone.add_comment(orm.uin, orm.fid, orm.appid, content, private=True)
private = False
if content.startswith("private "):
private = True
content = content.removeprefix("private").lstrip()
await self.qzone.add_comment(orm.uin, orm.fid, orm.appid, content, private=private)
await message.reply("评论成功")
case ["list"]:
if orm := await query_fid(reply.message_id):
detail = await self.qzone.shuoshuo(orm.fid, orm.uin, orm.appid)
comments = sorted(detail.comment.comments, key=lambda comment: comment.commentid)
if not comments:
await message.reply(
**Text(
"尚无评论!使用", CommandText("/command add <content>"), "发表评论!"
).as_kwargs()
)
return

text = as_numbered_section(
"评论:",
*(
as_key_value(comment.user.nickname, comment.content)
for comment in comments
),
)
await message.reply(**text.as_kwargs())
await reply.reply(**text.as_kwargs())
case _:
await message.reply(**COMMENT_CMD_HELP.as_kwargs())

Expand Down

0 comments on commit 88198ce

Please sign in to comment.