52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
import configparser, sys, comms, functions
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read(sys.argv[1])
|
|
|
|
menuCount = config.getint("Main","Menus")
|
|
|
|
def printMenu(conn, menu, node, user):
|
|
comms.sendString(conn, "\u001B[2J\r")
|
|
try:
|
|
with open("pages/menu"+str(menu)+".asc") as menuAscii:
|
|
for line in menuAscii.readlines():
|
|
line = line.replace("%node%", str(node))
|
|
comms.sendString(conn, line + "\r")
|
|
response = comms.getString(conn, 2)
|
|
except:
|
|
dispMenu = "Menu"+str(menu)
|
|
options = []
|
|
for i in range(0, config.getint(dispMenu, "Options")):
|
|
option = (config.get(dispMenu, "Option"+str(i)), config.get(dispMenu, "Option"+str(i)+"Key"))
|
|
options.append(option)
|
|
comms.sendString(conn,"Menu: \r\n")
|
|
for option in options:
|
|
comms.sendString(conn, option[0]+" : "+option[1]+"\r\n")
|
|
comms.sendString(conn, "What would you like to do? ")
|
|
response = comms.getString(conn, 2)
|
|
parseResponse(conn, menu, node, user, response)
|
|
|
|
|
|
def parseResponse(conn, menu, node, user, response):
|
|
# Add Menu functions and results to this function
|
|
# Menu 0 Functions
|
|
if menu == 0:
|
|
comms.sendString(conn, "\u001B[2J\r")
|
|
if response.strip('\x00') == "X":
|
|
comms.sendString(conn, "Goodbye!")
|
|
|
|
if response.strip('\x00') == "P":
|
|
functions.printProfile(conn, user, node, menu)
|
|
|
|
if response.strip('\x00') == "E":
|
|
functions.editProfile(conn, user, node, menu)
|
|
|
|
if response.strip('\x00') == "M":
|
|
functions.pubMessages(conn, user, node, menu)
|
|
|
|
# Menu 1 Functions
|
|
if menu == 1:
|
|
if response.strip('\x00') == "B":
|
|
printMenu(conn, 0, node, user)
|
|
|