Answer the question
In order to leave comments, you need to log in
NameError: name 'user_id' is not defined - Where is the error?
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk_session = vk_api.VkApi(token = '1adbd73f02bcfa805971facdaf130387d5df1a176dc37fdb07eff4b7c97af7b409643e9c706c5f')
longpoll = VkBotLongPoll(vk_session, 20575886)
def sender(id, text):
vk_session.method('messages.send', {'chat_id': id, 'message': text, 'random_id': 0})
def main():
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.from_chat:
id = event.chat_id
msg = event.object.message['text'].lower()
try:
dey = event.message.action['type']
invite_id = event.message.action['member_id']
except:
dey = ""
invite_id = -100
if dey == 'chat_invite_user' or dey == 'chat_invite_user_by_link':
sender(id, 'Лох')
if msg == 'привет':
sender(id, '123')
if user_id == admin_id and msg == 'кик':
vk_session.method('messages.removeChatUser', {'chat_id' : id, 'user_id' : user_id, 'member_id': member_id})
if __name__ == '__main__':
main()
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