E:\Python\Proekt>main.py
Traceback (most recent call last):
File "E:\Python\Proekt\main.py", line 21, in
sender(id, 'б')
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\Администратор\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 == 'Привет':
sender(id, 'И тебе привет')
if msg == 'а':
sender(id, 'б')
-
Вопрос задан
-
264 просмотра