Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: viste <[email protected]>
  • Loading branch information
Viste committed Nov 9, 2024
1 parent 909b0fd commit b1b449e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,20 @@ async def comment_on_photo(message: types.Message):
if group_id not in media_group_timers:
media_group_timers[group_id] = asyncio.create_task(group_comment_delay(group_id))
else:
logging.info(
f"Received forwarded photo from channel {message.forward_from_chat.title} in chat {message.chat.id}")
try:
logging.info(
f"Received forwarded photo from channel {message.forward_from_chat.title} in chat {message.chat.id}")

file_info = await message.bot.get_file(message.photo[-1].file_id)
image_url = f"https://api.telegram.org/file/bot{config.token}/{file_info.file_path}"
file_info = await message.bot.get_file(message.photo[-1].file_id)
image_url = f"https://api.telegram.org/file/bot{config.token}/{file_info.file_path}"

comment = await openai.generate_comment_from_image(image_url, message.chat.id)
comment = await openai.generate_comment_from_image(image_url, message.chat.id)

await message.reply(comment)
except Exception as e:
logging.error(f"Error generating comment for single photo: {e}")
await message.reply("Не удалось обработать фотографию. Попробуйте еще раз.")

await message.reply(comment)


@router.message(F.content_type.in_({'video'}), F.chat.type.in_({'group', 'supergroup'}))
Expand Down

0 comments on commit b1b449e

Please sign in to comment.