SHARE
TWEET

Untitled

a guest Oct 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from datetime import timedelta
  2. from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
  3. from vk_api.keyboard import VkKeyboard, VkKeyboardColor
  4. import vk_api
  5. from datetime import datetime
  6. import random
  7. import time
  8.  
  9. vk_session = vk_api.VkApi(token='токен')
  10. session_api = vk_session.get_api()
  11. longpoll = VkBotLongPoll(vk_session, айдигруппы)
  12. vk = vk_session.get_api()
  13.  
  14. for event in longpoll.listen():
  15.     if event.type == VkBotEventType.MESSAGE_NEW:
  16.         print('Текст сообщения: ' + str(event.obj.text))
  17.         print(event.obj.peer_id)
  18.         response = event.obj.text.lower()
  19.         print(response)
  20.         try:
  21.             if response.split(' ')[0] == '/kick':
  22.                     try:
  23.                         print(response.split(' ')[1])
  24.                         print(event.obj)
  25.                         vk.messages.removeChatUser(chat_id=event.obj.peer_id-2000000000, member_id=response.split(' ')[1])
  26.                     except Exception as e:
  27.                         vk.messages.send(
  28.                             peer_id=event.obj.peer_id,
  29.                             random_id=random.randint(-2147483648, +2147483648),
  30.                             message='Ошибка при удалении пользователя.{0}'.format(e)
  31.                         )
  32.  
  33.         except:
  34.             pass
  35.  
  36.         finally:
  37.             time.sleep(3)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top