K
K
kadzu22021-04-06 22:39:42
In contact with
kadzu2, 2021-04-06 22:39:42

Lamer does not understand what he is doing wrong (VK_api). Can you help?

E:\Python\Proekt>main.py
Traceback (most recent call last):
File "E:\Python\Proekt\main.py", line 21, in
sender(id, 'b')
File "E:\Python \Proekt\main.py", line 10, in sender
vk_session.method('message.send', {"user_id" : id, 'message' : text, 'random id' : 0})
File "C:\Users \Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\vk_api\vk_api.py", line 656, in method
raise error
vk_api.exceptions.ApiError: [3] Unknown method passed

import vk_api
from vk_api. longpoll import VkLongPoll, VkEventType
from toks import main_token

vk_session = vk_api.VkApi(token = main_token )
session_api = vk_session.get_api()
longpoll = vk_api.longpoll.VkLongPoll(vk_session)

def sender(id, text):
vk_session.method('message.send', {"user_id" : id, 'message' : text, 'random id' : 0})

for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:

msg = event.text.lower()
id = event.user_id

if msg == 'Hello':
sender(id, 'Hello to you too')
if msg == 'a':
sender(id, 'b')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question