This repository was archived by the owner on Mar 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
38 lines (30 loc) · 2.28 KB
/
api.py
File metadata and controls
38 lines (30 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, request
from flask_restful import Api, Resource
import requests
import config
from main import get_token
app = Flask(__name__)
api = Api(app)
class getApi(Resource):
def get(self):
method = request.args.get('method')
if method == "getReporter":
id = request.args.get('id')
testr = True
data = requests.get(f"https://api.vk.com/method/bugtracker.getReportersById?access_token={config.main_token}&reporter_ids={id}&v=5.163").json()
if data.get('error') is not None:
config.main_token = get_token()
data = requests.get(
f"https://api.vk.com/method/bugtracker.getReportersById?access_token={config.main_token}&reporter_ids={id}&v=5.163").json()
if len(data['response']['items']) == 0:
return {"message": "user not found"}
if data['response']['items'][0]['status_text'] in ['Обычный пользователь', 'Не учавствует в программе VK Testers', 'Исключён из программы VK Testers', 'Вышел из программы VK Testers', 'Отклонил приглашение в программу', "Во вступлении в программу отказано", 'Вышла из программы VK Testers']:
testr = False
if data['response']['items'][0]['status_text'] not in ['Обычный пользователь', 'Не учавствует в программе VK Testers', 'Исключён из программы VK Testers', 'Вышел из программы VK Testers', 'Отклонил приглашение в программу', "Во вступлении в программу отказано", 'Вышла из программы VK Testers']:
testr = True
return {"response": {"reporter": {"id": id, "status_text": data['response']['items'][0]['status_text'], "reports_count": data['response']['items'][0]['reports_count'], "top_position": data['response']['items'][0]['top_position'], "tester": testr}}}
else:
return {"message": "method not passed or found"}
api.add_resource(getApi, "/vk-bugs-api/")
if __name__ == '__main__':
app.run(host='127.0.0.1', port='3551', debug=False)