def text(): print('Receiving text...') message = request.values.get('Body', None) person = request.values.get('From', None) jdata = {} if "textReg.json" in os.listdir("."): with open("textReg.json", "r") as jfile: jdata = json.load(jfile) if len(message.split()) > 1 and message.split()[0] == "switch": jdata[person] = message.split()[1] if person in jdata: gamename = jdata[person] + "@nathanp.me" else: gamename = '*****@*****.**' jdata[person] = "treehacks" with open("textReg.json", "w") as jfile: json.dump(jdata, jfile) if not message or not person: return 'Incorrect POST data' TextProcess.evalAndRespond(person, message, gamename) return 'OK'
def email(): print('Receiving email...') email = request.values.get('to', None) person = request.values.get('from', None) text = request.values.get('text', None) if not email or not person: return "Incorrect POST data" if not text: text = "" TextProcess.evalAndRespond(person, text, email) return 'OK'