R
R
Roma2021-02-14 16:54:51
In contact with
Roma, 2021-02-14 16:54:51

How to attach a photo to text?

How to attach a photo to text?
help me please

import vk_api
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventTypet

def write_message(sender, message):
    authorize.method('messages.send', {'chat_id': sender, 'message': message, "random_id": get_random_id()})


def send_photo(sender, url):
    authorize.method('messages.send', {'chat_id': sender, 'attachment': url, "random_id": get_random_id()})

token = ""
authorize = vk_api.VkApi(token=token)
longpoll = VkBotLongPoll(authorize, group_id=)
getting_api = authorize.get_api()
for event in longpoll.listen():
    if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat and event.message.get('text') != "":
        reseived_message = event.message.get('text')
        sender = event.chat_id
        from_id = event.message.get('from_id')
        name = get_name(from_id)
        user_id = event.message.get('from_id')
 if reseived_message.lower() in ("444443", "13"):
            write_message(sender, f' Версия бота: 375647395634963956' + send_photo(sender, 'photo-201632468_457239022'))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lenskii, 2021-02-14
@Milovenskii

In a telegram like this:
bot.send_photo(id, photo, caption='desired text')
In VK it's probably the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question