mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix(telegram): ensure image cache path exists
This commit is contained in:
@@ -206,14 +206,15 @@ class Telegram:
|
|||||||
"""
|
"""
|
||||||
向Telegram发送报文
|
向Telegram发送报文
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if image:
|
if image:
|
||||||
res = RequestUtils(proxies=settings.PROXY).get_res(image)
|
res = RequestUtils(proxies=settings.PROXY).get_res(image)
|
||||||
if res is None:
|
if res is None:
|
||||||
raise Exception("获取图片失败")
|
raise Exception("获取图片失败")
|
||||||
if res.content:
|
if res.content:
|
||||||
# 使用随机标识构建图片文件的完整路径,并写入图片内容到文件
|
# 使用随机标识构建图片文件的完整路径,并写入图片内容到文件
|
||||||
image_file = Path(settings.TEMP_PATH) / str(uuid.uuid4())
|
image_file = Path(settings.TEMP_PATH) / "telegram" / str(uuid.uuid4())
|
||||||
|
if not image_file.parent.exists():
|
||||||
|
image_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
image_file.write_bytes(res.content)
|
image_file.write_bytes(res.content)
|
||||||
photo = InputFile(image_file)
|
photo = InputFile(image_file)
|
||||||
# 发送图片到Telegram
|
# 发送图片到Telegram
|
||||||
@@ -223,8 +224,7 @@ class Telegram:
|
|||||||
parse_mode="Markdown")
|
parse_mode="Markdown")
|
||||||
if ret is None:
|
if ret is None:
|
||||||
raise Exception("发送图片消息失败")
|
raise Exception("发送图片消息失败")
|
||||||
if ret:
|
return True
|
||||||
return True
|
|
||||||
# 按4096分段循环发送消息
|
# 按4096分段循环发送消息
|
||||||
ret = None
|
ret = None
|
||||||
if len(caption) > 4095:
|
if len(caption) > 4095:
|
||||||
|
|||||||
Reference in New Issue
Block a user