🐛 Fix a bug

This commit is contained in:
xtaodada 2022-09-23 16:57:04 +08:00
parent 01b2ff9662
commit 01567e55a6
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -1,4 +1,5 @@
import re
from io import BytesIO
from pyrogram import Client, filters, ContinuePropagation
from pyrogram.types import Message
@ -7,7 +8,7 @@ from defs.bilibili import b23_extract, video_info_get, binfo_image_create, get_d
from defs.button import gen_button, Button
@Client.on_message(filters.incoming &
@Client.on_message(filters.incoming & filters.text &
filters.regex(r"av(\d{1,12})|BV(1[A-Za-z0-9]{2}4.1.7[A-Za-z0-9]{2})|b23.tv"))
async def bili_resolve(_: Client, message: Message):
"""
@ -30,7 +31,7 @@ async def bili_resolve(_: Client, message: Message):
raise ContinuePropagation
@Client.on_message(filters.incoming &
@Client.on_message(filters.incoming & filters.text &
filters.regex(r"t.bilibili.com/([0-9]*)"))
async def bili_dynamic(_: Client, message: Message):
# sourcery skip: use-named-expression
@ -40,8 +41,11 @@ async def bili_dynamic(_: Client, message: Message):
dynamic_id = dynamic_number[1]
image = await get_dynamic_screenshot_pc(dynamic_id)
if image:
# 将bytes结果转化为字节流
photo = BytesIO(image)
photo.name = "screenshot.png"
await message.reply_photo(
image,
photo,
quote=True,
reply_markup=gen_button([Button(0, "Link", f"https://t.bilibili.com/{dynamic_id}")])
)