Answer the question
In order to leave comments, you need to log in
Vkbotlongpoll answers everything. How to fix?
I want to implement a parser bot that, upon request, copies the table from the site and sends it to the VK conversation.
If everything is fine with the parser, then there are problems with the bot itself. Wrote a bot, but he answers everything. Task:
to make it react only to the command! Table.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.insert(0, '../')
from parsing import url_print # парсинг
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.keyboard import VkKeyboard, VkKeyboardColor
import vk_api
from datetime import datetime
import random
import time
# import get_pictures
import data
vk_session = vk_api.VkApi(token="") # tocken
session_api = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, 186725132) #id группы
def send_message(session_api, peer_id, message=None, attachment=None, keyboard=None, payload=None):
session_api.messages.send(peer_id=peer_id, message=message, random_id=random.randint(-2147483648, +2147483648),
attachment=attachment, keyboard=keyboard, payload=payload)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
# беседа
send_message(session_api,peer_id=event.obj.peer_id, message= url_print + "Bot version beta 0.19")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question