mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-16 04:35:55 +00:00
🐛 修复一个小错误
This commit is contained in:
parent
2bda99e05f
commit
288501dbc5
@ -90,11 +90,17 @@ async def get_loft(url: str) -> List[LofterItem]:
|
||||
def parse_loft_user(url: str, content: str):
|
||||
username = urlparse(url).hostname.split(".")[0]
|
||||
soup = BeautifulSoup(content, "lxml")
|
||||
user = soup.find("div", {"class": "selfinfo"})
|
||||
if user := soup.find("div", {"class": "selfinfo"}):
|
||||
avatar = user.find("img").get("src").split("?")[0]
|
||||
name = user.find("h1").getText()
|
||||
bio = user.find("div", {"class": "text"}).getText()
|
||||
return username, avatar, name, bio, soup
|
||||
if user := soup.find("div", {"class": "g-hdc box"}):
|
||||
avatar = user.find("img").get("src").split("?")[0]
|
||||
name = user.find("h1").getText()
|
||||
bio = user.find("p", {"class": "cont"}).getText()
|
||||
return username, avatar, name, bio, soup
|
||||
return username, None, "未知用户", "", soup
|
||||
|
||||
|
||||
async def get_loft_user(url: str):
|
||||
|
@ -30,13 +30,20 @@ async def lofter_share(_: Client, message: Message):
|
||||
await message.reply_media_group(media=await input_media(img[:9], static), quote=True)
|
||||
else:
|
||||
text, avatar, username, status_link = await get_loft_user(url)
|
||||
if avatar:
|
||||
await message.reply_photo(
|
||||
avatar,
|
||||
caption=text,
|
||||
quote=True,
|
||||
reply_markup=lofter_user_link(username, status_link)
|
||||
)
|
||||
else:
|
||||
await message.reply_text(
|
||||
text,
|
||||
quote=True,
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=lofter_user_link(username, status_link)
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
breakpoint()
|
||||
raise ContinuePropagation
|
||||
|
Loading…
Reference in New Issue
Block a user