Answer the question
In order to leave comments, you need to log in
How to send a post with an image in VK?
There is a code that sends messages to the group that are sent to the bot.
import vk_api
import time
import aiogram
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
TOKEN = 'Токен Бота'
admin_id = 'Чат айди'
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
group_id = '-айдигруппы'
token_vk = 'Токен вконтакте'
vk_session = vk_api.VkApi(token=token_vk)
vk = vk_session.get_api()
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
await bot.send_message(message.chat.id, f' Здравствуйте {message.from_user.username} \n бот успешно работает.')
await bot.send_message(message.chat.id, f' Введите любое сообщения, для постинга в группе.')
#Отправка сообщений из бота в группу
@dp.message_handler(content_types=['text'])
async def process_start_command(message: types.Message):
posting = vk.wall.post(owner_id=group_id, message=f'{message.text}')
if __name__ == '__main__':
executor.start_polling(dp)
Answer the question
In order to leave comments, you need to log in
Download a picture from a message in a telegram, then upload it to the VKontakte server and send it in the request in the attachments field. In theory, your attachment should look like this: photo66748_265827614. Here is an example for sending a photo: https://github.com/python273/vk_api/blob/master/ex... . And here you can see how to download photos: https://ru.stackoverflow.com/questions/1080264/aio... .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question