Answer the question
In order to leave comments, you need to log in
I can't understand why this is happening?
I am writing a bot in VK, I made several functions for convenience, all the vk_api libraries are imported, and therefore I had to catch the vk_api error, in one function it is caught, but in another it does not want to and gives an error:
NameError name 'vk_api' is not defined:
And it gives this on the line where it was written:
except vk_api.exceptions.ApiError:
pass
Here is the code itself:
def kick_all(user_id):
try:
result = cursor.execute(f'SELECT * FROM `chats`')
row = cursor.fetchall()
for chat_s in row:
vk.messages.removeChatUser(chat_id=chat_s['chat_id'], member_id=user_id)
return f"Пользователь был кикнут во всех беседах."
except vk_api.exceptions.ApiError:
pass
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