Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import vk_api
  2. class bot:
  3.     count = 0
  4.  
  5.     def __init__(self, token, id, name):
  6.         self.token = token
  7.         self.id = id
  8.         self.session = vk_api.VkApi(token = self.token)
  9.         self.vk = self.session.get_api()
  10.         self.name = name
  11.  
  12.         bot.count += 1
  13.         self.count = bot.count
  14.  
  15.     def SendMsg(self, chat_id, message = '', reply_to='', attachments = '', random_id = 0):
  16.         self.vk.messages.send(
  17.             chat_id = chat_id,
  18.             message = message,
  19.             reply_to = reply_to,
  20.             attachemnts = attachments,
  21.             random_id = random_id
  22.         )
  23.     def getcount(self):
  24.         return self.count
  25.  
  26. admin_bot = bot('token', id1, 'Valeria Banschikova')
  27.  
  28. first_bot = bot('token2', id2)
  29.  
  30. second_bot = bot('token3', id3)
  31.  
  32.  
  33. admin_bot.SendMsg(
  34.     chat_id = event.chat_id,
  35.     message = 'Test',
  36. )
  37.  
  38. second_bot.SendMsg(
  39.     chat_id = event.chat_id,
  40.     message = 'Test2',
  41. )
  42.  
  43.  
  44. print(second_bot.count) # 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement