Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import random
- options = json.load(open('info.json'))
- token = options['token']
- idd = options['id']
- def makeRequest(token, method, options):
- url = 'https://api.vk.com/method/' + method + '?' + 'access_token=' + token + '&'
- for key in options:
- url = url + key + '=' + str(options[key]) + '&'
- return requests.get(url).json()
- class Bot:
- def __init__(self, token, id):
- self.token = token
- self.id = id
- def getLastLPr(self):
- lpsp = makeRequest(self.token, 'groups.getLongPollServer', {'group_id':self.id, 'v':5.95})['response']
- url = lpsp['server'] + '?act=a_check&key=' + str(lpsp['key']) + '&ts=' + str(lpsp['ts']) + '&wait=5'
- return requests.get(url).json()
- def sendMessage(self, id, type, msg):
- makeRequest(self.token, 'messages.send', {'user_id':id, 'random_id': random.randint(0, 999999999), 'message':msg, 'v':5.95})
- bot = Bot(token, idd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement