Esempio n. 1
0
def client_server(request):
    body = json.loads(request.body)
    res = {}
    if body['type'] == 'login':
        if (body['username'] == 'admin') and (body['password'] == 'admin'):
            res['correct'] = True
            res['val'] = database.get_groups()
            with open('myBotVK/templates/admin.html', 'r') as file:
                res['html'] = file.read()
        else:
            res['correct'] = False
        #print(res)
        return HttpResponse(json.dumps(res))
    elif body["type"] == 'postNewMessage':
        users_chat_id = database.get_member(body["group"])
        for i in users_chat_id:
            vk_api.messages.send(user_id=i,
                                 message=body['content'],
                                 random_id=random.randint(
                                     1, 50000000000000000000000),
                                 v=5.103)
        return HttpResponse(json.dumps({"res": "ok"}))
def member_register(did):
    global current_member, current_run, current_state
    if request.method == 'GET':
        broadcast.broadcast_message(b'reset')
        data = json.dumps(database.get_member(did))
        current_member = json.loads(
            data,
            object_hook=lambda d: namedtuple('Driver', d.keys())(*d.values()))
        print(current_member)
        print("Driver Registered: %s" % did)
        current_run = 0
        current_state = 0
        socketio.emit('my_response', {'data': 'Driver Registered'},
                      namespace='/comms')
        socketio.emit('reload_contender', {'data': 'reload contender'},
                      namespace='/comms')
        socketio.emit('reload_results', {'data': 'reload results'},
                      namespace='/comms')
        socketio.emit('reload_current', {'data': 'reload current'},
                      namespace='/comms')
        socketio.emit('reload_gates', {'data': 'reload current'},
                      namespace='/comms')
    return "Ok"
Esempio n. 3
0
def client_server(request):
    body = json.loads(request.body)
    res = {}
    if body["type"] == "login":
        if (body["username"] == "admin") and (body["password"] == "admin"):
            res["correct"] = True
            res["val"] = database.get_groups()
            with open('Weapon/templates/Admin.html', 'r') as file:
                res["html"] = file.read()
        else:
            res["correct"] = False
            print(res)
        return HttpResponse(json.dumps(res))
    elif body["type"] == "postNewMessage":
        users_chat_id = database.get_member(body["group"])
        # print("Check dV")
        for i in users_chat_id:
            vk_api.messages.send(user_id=i,
                                 message=body['content'],
                                 random_id=random.randint(
                                     1, 50000000000000000000000000),
                                 v=5.103)
        return HttpResponse(json.dumps({"res": "ok"}))
Esempio n. 4
0
async def throw_member(id: str):
    member = get_member(id)
    return member