C
C
cyxarick2020-09-09 20:07:56
Python
cyxarick, 2020-09-09 20:07:56

Why doesn't the bot write in the conversation?

import vk_api
import requests
import random
vk_session = vk_api.VkApi(token='token')

from vk_api.longpoll import VkLongPoll, VkEventType
longpoll = VkLongPoll(vk_session)
vk = vk_session.get_api()
for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
   
   
        usergive=vk.users.get(user_ids=event.user_id)
        idgive=vk.users.get(user_ids=event.user_id)
        id=idgive[0]['id']		
        name=usergive[0]['first_name']
      


     
        				               
        if event.text == "НАРУТООО":
            if event.from_user: 
                print(vk.messages.send( 
                    user_id=event.user_id,
                    message='САСКЕЕЕЕ',
                    random_id=0
                  
    ))
            elif event.from_chat: 
                vk.messages.send(
                    peer_id=2000000002,
                    message="САСКЕЕЕЕ",
                    random_id= 0
    )

When I write in a conversation, it does not give an error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Renat Ataev, 2020-09-09
@cyxarick

vk_api.longpoll will not process the message from the conversation, use vk_api.bot_longpoll

S
soremix, 2020-09-09
@SoreMix

event.to_me
Only messages in PM are processed, as I understand it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question