- ВКонтакте
- РћРТвЂВВВВВВВВнокласснРСвЂВВВВВВВВРєРСвЂВВВВВВВВ
- РњРѕР№ Р В Р’В Р РЋРЎв„ўР В Р’В Р РЋРІР‚ВВВВВВВВРЎР‚
- Viber
- Skype
- Telegram
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: forwarded message not found
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id
from config import Token, Group_id
emoji_pattern = re.compile(r"^[\U00010000-\U0010ffff\s]+")
def send_reply(message, sender, reply_to):
"""Функция отправки ответа """
print(f"Отправка ответа в чат {sender}: {message}, reply_to: {reply_to}")
auth.method("messages.send", {
"chat_id": sender,
"message": message,
"random_id": get_random_id(),
"reply_to": reply_to
})
auth = vk_api.VkApi(token=Token)
longPoll = VkBotLongPoll(auth, group_id=Group_id)
if __name__ == "__main__":
print("Бот запущен и ждет сообщения...")
for event in longPoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
message = event.message.get("text")
sender = event.chat_id # ID беседы
reply_message = event.message.get("reply_message")
original_message_id = None
if reply_message:
original_message_id = reply_message.get("conversation_message_id")
if "Осадный лагерь нуждается в следующей экипировке:" in message:
lines = message.strip().split("\n")
if lines:
item_name = lines[-1].strip()
item_name = emoji_pattern.sub("", item_name).strip()
response_message = f"передать {item_name}"
send_reply(response_message, sender, original_message_id)
Сообщение на которое был ответ он получает, но бот падает при попытке ответить на это же сообщение. Выдает ошибку
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: forwarded message not found```