Skip to content

Commit

Permalink
fix: SerialCbData validate error
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Jan 6, 2024
1 parent ff3f828 commit 18514d3
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 96 deletions.
182 changes: 91 additions & 91 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Qzone3TG"
version = "0.9.8.dev5"
version = "0.9.8.dev6"
description = "Forward Qzone feeds to telegram."
authors = ["aioqzone <zzzzss990315@gmail.com>"]
readme = "README.md"
Expand All @@ -18,7 +18,7 @@ aiogram = { version = "^3.3.0", extras = ["proxy"] } # b
apscheduler = "^3.10.4"

[tool.poetry.extras]
captcha = ["slide-tc"]
slide-captcha = ["slide-tc"]

# dependency groups
[tool.poetry.group.test]
Expand Down
7 changes: 5 additions & 2 deletions src/qzone3tg/app/interact/_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ def _like_markup(feed: FeedContent) -> InlineKeyboardButton | None:
if feed.unikey is None:
return
curkey = LikeData.persudo_curkey(feed.uin, feed.abstime)
cbd = SerialCbData(command=("unlike" if feed.islike else "like"), sub_command=curkey)
return InlineKeyboardButton(text=cbd.command.capitalize(), callback_data=cbd.pack())
command, text = ("unlike", "取消赞") if feed.islike else ("like", "赞")

return InlineKeyboardButton(
text=text, callback_data=SerialCbData(command=command, sub_command=curkey).pack()
)

@self.queue.inline_buttons.add_impl
def _emoji_markup(feed: FeedContent) -> InlineKeyboardButton | None:
Expand Down
2 changes: 2 additions & 0 deletions src/qzone3tg/app/interact/_conversation/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ async def btn_comment_refresh(
await self.bot.send_message(self.admin, "消息已过期")
return

assert callback_data.sub_command

orm = await self.store.get_feed_orm(
*FeedOrm.primkey(PersudoCurkey.from_str(callback_data.sub_command))
)
Expand Down
1 change: 1 addition & 0 deletions src/qzone3tg/app/interact/_conversation/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ async def btn_emoji(
else:
reply = partial(self.bot.send_message, chat_id=query.from_user.id)

assert callback_data.sub_command
eids = callback_data.sub_command.split(",")

if len(eids) <= 9:
Expand Down
1 change: 1 addition & 0 deletions src/qzone3tg/app/interact/_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def invert_callback_data(message: Message):


async def btn_like(self: InteractApp, query: CallbackQuery, callback_data: SerialCbData):
assert callback_data.sub_command
task = asyncio.create_task(
like_core(self, str(callback_data.sub_command), callback_data.command == "like")
)
Expand Down
2 changes: 1 addition & 1 deletion src/qzone3tg/app/interact/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

class SerialCbData(CallbackData, prefix=""):
command: str
sub_command: str = ""
sub_command: str | None = None

0 comments on commit 18514d3

Please sign in to comment.