Skip to content

Commit eb656da

Browse files
committed
🐛 Bug: Fix the bug causing image file upload failure.
💻 Code: Upgrade ModelMerge version to 0.6.11
1 parent b91ba4b commit eb656da

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

bot.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ async def command_bot(update, context, language=None, prompt=translator_prompt,
208208

209209
if "gpt" in engine or (config.CLAUDE_API and "claude-3" in engine):
210210
message = [{"type": "text", "text": message}]
211+
if image_url == None and file_url and (file_url[-3:] == "jpg" or file_url[-3:] == "png" or file_url[-4:] == "jpeg"):
212+
image_url = file_url
211213
message = get_image_message(image_url, message, engine)
212214
if Users.get_config(convo_id, "TYPING"):
213215
await context.bot.send_chat_action(chat_id=chatid, message_thread_id=message_thread_id, action=ChatAction.TYPING)
@@ -475,6 +477,8 @@ async def handle_file(update, context):
475477

476478
if file_url == None and image_url:
477479
file_url = image_url
480+
if image_url == None and file_url:
481+
image_url = file_url
478482
message = Document_extract(file_url, image_url, engine)
479483

480484
robot.add_to_conversation(message, role, convo_id)
@@ -601,10 +605,10 @@ async def process_update(update):
601605
application.add_handler(CommandHandler("zh2en", lambda update, context: command_bot(update, context, "english", robot=config.translate_bot)))
602606
application.add_handler(CommandHandler("info", info))
603607
application.add_handler(InlineQueryHandler(inlinequery))
604-
application.add_handler(MessageHandler(filters.Document.PDF | filters.Document.TXT | filters.Document.DOC | filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg"), handle_file))
608+
# application.add_handler(MessageHandler(~filters.CAPTION & , handle_file))
605609
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, lambda update, context: command_bot(update, context, prompt=None, has_command=False), block = False))
606-
application.add_handler(MessageHandler(filters.CAPTION & filters.PHOTO & ~filters.COMMAND, lambda update, context: command_bot(update, context, prompt=None, has_command=False)))
607-
application.add_handler(MessageHandler(~filters.CAPTION & filters.PHOTO & ~filters.COMMAND, handle_file))
610+
application.add_handler(MessageHandler(filters.CAPTION & ((filters.PHOTO & ~filters.COMMAND) | (filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg") | filters.Document.FileExtension("png"))), lambda update, context: command_bot(update, context, prompt=None, has_command=False)))
611+
application.add_handler(MessageHandler(~filters.CAPTION & ((filters.PHOTO & ~filters.COMMAND) | (filters.Document.PDF | filters.Document.TXT | filters.Document.DOC | filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg"))), handle_file))
608612
application.add_handler(MessageHandler(filters.COMMAND, unknown))
609613
application.add_error_handler(error)
610614

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--index-url https://pypi.python.org/simple/
22
python-dotenv
33
md2tgmd==0.2.2
4-
ModelMerge==0.6.10
4+
ModelMerge==0.6.11
55
python-telegram-bot[webhooks,rate-limiter]==21.0.1

0 commit comments

Comments
 (0)