SHARE
TWEET

Untitled

a guest Jun 19th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import vk_api
  2. import time
  3. import datetime
  4. import random
  5.  
  6. vk = vk_api.VkApi(token = "здесь токен был если что")
  7. vk._auth_token()
  8.  
  9. while True:
  10.     now = datetime.datetime.now()
  11.     if str(now.hour) == "23":
  12.         vk.method("messages.send",
  13.                   {"peer_id": 292171486, "message": "Тест", "random_id": random.randint(1, 9999999)})
  14.     try:
  15.         messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"})
  16.         if messages["count"] >= 1:
  17.             user_id = messages["items"][0]["last_message"]["from_id"]
  18.             text_message = messages["items"][0]["last_message"]["text"]
  19.             if text_message.lower() == "привет":
  20.                 vk.method("messages.send",
  21.                           {"peer_id": user_id, "message": "Привет!", "random_id": random.randint(1, 9999999)})
  22.             else:
  23.                 vk.method("messages.send",
  24.                           {"peer_id": user_id, "message": "Не понял тебя!", "random_id": random.randint(1, 9999999)})
  25.     except Exception as E:
  26.         time.sleep(1)
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
 
Top