Esempio n. 1
0
def get_attendance(username, password):
    #Gets the session id and sid
    login = libvaasu.login(username, password)
    if (login == 'wrong'):
        raise Exception('Username or password is wrong!')
    else:
        sid = login[0]
        session_id = login[1]

    return libvaasu.retrieve_attendance(sid, session_id)
Esempio n. 2
0
def get_erppassword(update, context):
    user = update.message.from_user
    msg = update.message.text

    erpusername = temp['erpusernames'][user.id]

    login = libvaasu.login(erpusername, msg)
    if login == 'wrong':
        update.message.reply_text('Username or password wrong. Try again : /login')
    else:
        # Insert to database here
        update.message.reply_text('Registrtion successful. Now you can use Vaasu bot :)')

    # /start conversation has ended
    return ConversationHandler.END
Esempio n. 3
0
def get_erppassword(update, context):
    user = update.message.from_user
    msg = update.message.text
    erpusername = temp['erpusernames'][user.id]
    user = update.message.from_user
    telegram_id = user.id

    login = libvaasu.login(erpusername, msg)
    if login == 'wrong':
        update.message.reply_text(
            'Username or password is wrong! Try again : /login')
    else:
        if libvaasu.add_student(erpusername, msg, telegram_id):
            update.message.reply_text(
                'Registration successful. Now you can use Vaasu bot. Use /attendance to get your attendance\n'
            )
        else:
            update.message.reply_text(
                'You have already registered an account, use /attendance')

    # /start conversation has ended
    return ConversationHandler.END
Esempio n. 4
0
def get_attendance(username, password):

    #Gets the session id and sid
    login = libvaasu.login(username, password)
    if (login == 'wrong'):
        print('Username or password wrong')
        raise Exception('Password wrong')
    else:
        sid = login[0]
        session_id = login[1]

    #Gets args value
    url = "https://erp.vidyaacademy.ac.in/web/dataset/call_kw"
    payload = {
        "jsonrpc": "2.0",
        "method": "call",
        "params": {
            "model": "vict.academics.duty.leave.status",
            "method": "create",
            "args": [{}],
            "kwargs": {
                "context": {}
            },
            "session_id": session_id,
            "context": {}
        }
    }
    r = requests.post(url, data=json.dumps(payload), cookies={"sid": sid})
    args = r.json()["result"]

    url = "https://erp.vidyaacademy.ac.in/web/dataset/call_button"
    payload = {
        "jsonrpc": "2.0",
        "method": "call",
        "params": {
            "model": "vict.academics.duty.leave.status",
            "method": "button_check_status",
            "domain_id": "null",
            "context_id": 1,
            "args": [[args], {}],
            "session_id": session_id
        },
        "id": "r54"
    }
    r = requests.post(url, data=json.dumps(payload), cookies={"sid": sid})
    #print(r.json())

    #Gets the subject id
    url = "https://erp.vidyaacademy.ac.in/web/dataset/call_kw"
    payload = {
        "jsonrpc": "2.0",
        "method": "call",
        "params": {
            "model": "vict.academics.duty.leave.status",
            "method": "read",
            "args": [[args], ["atten_status"]],
            "kwargs": {
                "context": {}
            },
            "session_id": session_id,
            "context": {}
        }
    }
    r = requests.post(url, data=json.dumps(payload), cookies={"sid": sid})
    subs = r.json()["result"][0]["atten_status"]
    #print(subs)

    #Gets the attendance
    payload = {
        "jsonrpc": "2.0",
        "method": "call",
        "params": {
            "model": "vict.academics.duty.leave.status.lines",
            "method": "read",
            "args": [subs, ["course", "course_percentage"]],
            "kwargs": {
                "context": {}
            },
            "session_id": session_id,
            "context": {}
        }
    }
    headers = {
        'user-agent':
        "Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
    }
    r = requests.post(url, data=json.dumps(payload), cookies={"sid": sid})
    Attendance = {}
    for i in r.json()["result"]:
        Attendance[i["course"][1]] = i["course_percentage"]
    return Attendance