Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import vk_api
  2. from vk_api.utils import get_random_id
  3. import requests
  4.  
  5.  
  6. token = "123"
  7.  
  8. botpod_token = "456"
  9.  
  10. user_id = 547098395
  11.  
  12. API = "https://api.vk.com/method"
  13.  
  14. vk = vk_api.VkApi(token=token).get_api()
  15.  
  16. with open("links.txt", "r") as f:
  17. links = f.read().split()
  18.  
  19.  
  20. for num, link in enumerate(links[15:17]):
  21. try:
  22. vk.messages.joinChatByInviteLink(link=link)
  23. except vk_api.exceptions.ApiError as e:
  24. print(e)
  25. continue
  26. convs = vk.messages.getConversations()
  27. peer_id = convs["items"][0]["conversation"]["peer"]["id"]
  28. vk.messages.send(
  29. peer_id=peer_id,
  30. message="dd",
  31. random_id=get_random_id(),
  32. )
  33. response = requests.post(f"https://api.vk.com/method/bot.addBotToChat?access_token={botpod_token}",
  34. data={
  35. 'peer_id': peer_id,
  36. 'bot_id': -187188576,
  37. 'v': 5.92
  38. })
  39. vk.messages.removeChatUser(chat_id=peer_id - 2000000000, user_id=user_id)
  40. print(f"Отправили в конфу №{num}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement