Skip to content

Commit e68936e

Browse files
committed
Support images in webp format.
1 parent 7dbd195 commit e68936e

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

channel/wechat/wechat_channel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
import threading
1111
import time
12-
import uuid
1312
import requests
1413

1514
from bridge.context import *
@@ -297,9 +296,7 @@ def _convert_webp_to_png(webp_image):
297296
webp_image.seek(0)
298297
img = Image.open(webp_image).convert("RGBA")
299298
png_image = io.BytesIO()
300-
unique_filename = f"{uuid.uuid4()}.png"
301299
img.save(png_image, format="PNG")
302-
png_image.name = unique_filename
303300
png_image.seek(0)
304301
return png_image
305302
except Exception as e:

plugins/keyword/keyword.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def on_handle_context(self, e_context: EventContext):
5555
reply_text = self.keyword[content]
5656

5757
# 判断匹配内容的类型
58-
if (reply_text.startswith("http://") or reply_text.startswith("https://")) and any(reply_text.endswith(ext) for ext in [".jpg", ".jpeg", ".png", ".gif", ".img"]):
58+
if (reply_text.startswith("http://") or reply_text.startswith("https://")) and any(reply_text.endswith(ext) for ext in [".jpg", ".webp", ".jpeg", ".png", ".gif", ".img"]):
5959
# 如果是以 http:// 或 https:// 开头,且".jpg", ".jpeg", ".png", ".gif", ".img"结尾,则认为是图片 URL。
6060
reply = Reply()
6161
reply.type = ReplyType.IMAGE_URL

0 commit comments

Comments
 (0)