Skip to content

Commit 3e6c632

Browse files
committed
Tools: Fixed not allowing empty images to be attached
1 parent 23ffc0b commit 3e6c632

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/widgets/tools/tools.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ def extract_variables_for_sql(self) -> dict:
184184
return variables_for_sql
185185

186186
def attach_online_image(self, bot_message, image_title:str, image_url:str):
187-
attachment = bot_message.add_attachment(
188-
file_id = generate_uuid(),
189-
name = image_title,
190-
attachment_type = 'image',
191-
content = attachments.extract_online_image(image_url, 640)
192-
)
193-
SQL.insert_or_update_attachment(bot_message, attachment)
187+
image_data = attachments.extract_online_image(image_url, 640)
188+
if image_data:
189+
attachment = bot_message.add_attachment(
190+
file_id = generate_uuid(),
191+
name = image_title,
192+
attachment_type = 'image',
193+
content = image_data
194+
)
195+
SQL.insert_or_update_attachment(bot_message, attachment)
194196

195197
class GetCurrentDatetime(Base):
196198
tool_metadata = {

0 commit comments

Comments
 (0)