-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
85 lines (75 loc) · 2.27 KB
/
app.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
import os
import sys
import platform
from xlpy import *
def main_menu():
clear()
print(
" .::XL - Direct Purchase Package By Rizky::." +
"\nPlease choose the menu you want to start:"
"\n[1] Purchase Package" +
"\n[2] Request OTP Code" +
"\n[3] Request Password" +
"\n[0] Quit"
)
choice = str(input(" >> "))
exec_menu(choice)
return
def exec_menu(choice):
clear()
if(choice == ''):
menu_actions['main']()
else:
try:
menu_actions[choice]()
except KeyError:
print("Invalid selection, please try again.\n")
menu_actions['main']()
return
def menu_1():
print(".::Purchase Package Menu::.")
msisdn = str(input("Input your MSISDN >> "))
po = str(input("Input your OTP >> "))
serviceid = str(input("Input your Service ID >> "))
xl = XL(msisdn)
r = xl.loginWithOTP(po)
if(r != False):
print(xl.purchasePackage(serviceid)['message'])
decision = str(input("Want to repeat the process [Y/N]? >> "))
menu_actions['main']() if(decision in ['N','n']) else menu_actions['1']()
else:
print("Login failed try again")
decision = str(input("Want to repeat the process [Y/N]? >> "))
menu_actions['main']() if(decision in ['N','n']) else menu_actions['1']()
return
def menu_2():
clear()
print(".::OTP Code Menu::.")
msisdn = str(input("Input your MSISDN >> "))
xl = XL(msisdn)
print(xl.reqOTP()['message'])
decision = str(input("Want to repeat the process [Y/N]? >> "))
menu_actions['main']() if(decision in ['N','n']) else menu_2()
def menu_3():
clear()
print(".::Password Menu::.")
msisdn = str(input("Input your MSISDN >> "))
xl = XL(msisdn)
print(xl.reqPassword()['message'])
decision = str(input("Want to repeat the process [Y/N]? >> "))
menu_actions['main']() if(decision in ['N','n']) else menu_actions['3']()
return
def exit():
sys.exit()
def clear():
return os.system("cls") if (platform.system() == 'Windows') else os.system("clear")
menu_actions = {
"main" : main_menu,
"1" : menu_1,
"2" : menu_2,
"3" : menu_3,
"0" : exit
}
if __name__ == "__main__":
main_menu()