def send_post_to_telegram(bot_token, chat_id, post):
bot = Bot(token=bot_token)
text = post['text']
attachments = post.get('attachments', [])
message = f"New post from VK:\n\n{text}"
for attachment in attachments:
if attachment['type'] == 'photo':
photo = attachment['photo']
photo_url = sorted(photo['sizes'], key=lambda x: x['width'])[-1]['url']
bot.send_photo(chat_id=chat_id, photo=photo_url, caption=message)
elif attachment['type'] == 'video':
video = attachment['video']
video_url = video['player']
bot.send_video(chat_id=chat_id, video=video_url, caption=message)