mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-24 09:15:51 +00:00
🐛 Fix bilibili dyn
This commit is contained in:
parent
224bf15b72
commit
29a66ca0d3
@ -421,15 +421,10 @@ async def get_dynamic_screenshot_pc(dynamic_id):
|
||||
# 动态被删除或者进审核了
|
||||
if page.url == "https://www.bilibili.com/404":
|
||||
return None
|
||||
card = await page.query_selector(".card")
|
||||
card = await page.query_selector(".bili-dyn-item__main")
|
||||
assert card
|
||||
clip = await card.bounding_box()
|
||||
assert clip
|
||||
bar = await page.query_selector(".bili-dyn-action__icon")
|
||||
assert bar
|
||||
bar_bound = await bar.bounding_box()
|
||||
assert bar_bound
|
||||
clip["height"] = bar_bound["y"] - clip["y"]
|
||||
return await page.screenshot(clip=clip, full_page=True)
|
||||
except Exception:
|
||||
print(f"截取动态时发生错误:{url}")
|
||||
|
@ -91,7 +91,7 @@ class ImageUtil:
|
||||
self.height = height
|
||||
else:
|
||||
self.mark_image = Image.open(background).resize(
|
||||
(self.width, self.height), Image.ANTIALIAS
|
||||
(self.width, self.height), Image.Resampling.LANCZOS
|
||||
)
|
||||
if is_alpha:
|
||||
array = self.mark_image.load()
|
||||
|
@ -15,7 +15,7 @@ def process_pic(content) -> BytesIO:
|
||||
draw = ImageDraw.Draw(bk_img)
|
||||
current_h, pad = 300, 10
|
||||
for line in para:
|
||||
w, h = draw.textsize(line, font=font)
|
||||
_, _, w, h = font.getbbox(line)
|
||||
draw.text(((MAX_W - w) / 2, current_h), line, font=font)
|
||||
current_h += h + pad
|
||||
draw.text((320, 400), "——鲁迅", font=font2, fill=(255, 255, 255))
|
||||
|
@ -1,3 +1,4 @@
|
||||
import aiofiles
|
||||
from io import BytesIO
|
||||
from os import sep, makedirs
|
||||
from os.path import exists
|
||||
@ -27,8 +28,8 @@ async def friend_say(client: Client, message: Message):
|
||||
user_name = message.reply_to_message.from_user.first_name
|
||||
# Create image
|
||||
if avatar:
|
||||
with open(avatar, "rb") as fh:
|
||||
buf = BytesIO(fh.read())
|
||||
async with aiofiles.open(avatar, "rb") as fh:
|
||||
buf = BytesIO(await fh.read())
|
||||
ava = ImageUtil(100, 100, background=buf)
|
||||
else:
|
||||
ava = ImageUtil(100, 100, color=(0, 0, 0))
|
||||
|
@ -77,6 +77,8 @@ async def ip_command(_: Client, message: Message):
|
||||
if rep_text == "" and text == "":
|
||||
await msg.edit("没有找到要查询的 ip/域名 ...")
|
||||
elif rep_text != "" and text != "":
|
||||
await msg.edit(f"{rep_text}\n================\n{text}")
|
||||
await msg.edit(
|
||||
f"{rep_text}\n================\n{text}", disable_web_page_preview=True
|
||||
)
|
||||
else:
|
||||
await msg.edit(f"{rep_text}{text}")
|
||||
await msg.edit(f"{rep_text}{text}", disable_web_page_preview=True)
|
||||
|
@ -84,7 +84,7 @@ async def process_user(message: Message, username: str):
|
||||
)
|
||||
|
||||
|
||||
@Client.on_message(filters.incoming & filters.text & filters.regex(r"twitter.com/"))
|
||||
# @Client.on_message(filters.incoming & filters.text & filters.regex(r"twitter.com/"))
|
||||
async def twitter_share(_: Client, message: Message):
|
||||
if not message.text:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user