def tg_get_pic_url(file_id: str, pic_type: str):
"""
download image from Telegram Server, and generate new image link that send to QQ group
:param file_id: telegram file id
:param pic_type: picture extension name
:return: pic url
"""
file = global_vars.tg_bot.getFile(file_id)
# urlretrieve(file.file_path, os.path.join(CQ_IMAGE_ROOT, file_id)) # download image
file.download(custom_path=os.path.join(CQ_IMAGE_ROOT, file_id))
if pic_type == 'jpg':
create_jpg_image(CQ_IMAGE_ROOT, file_id)
pic_url = get_short_url(SERVER_PIC_URL + file_id + '.jpg')
return pic_url
elif pic_type == 'png':
create_png_image(CQ_IMAGE_ROOT, file_id)
pic_url = get_short_url(SERVER_PIC_URL + file_id + '.png')
return pic_url
return ''
# endregion
_1100_text_forward.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录