def send_message(): """ Send message from the side's bot. """ subject = request.form["subject"] content = request.form["content"] list = request.form["list"] try: recipients = memory.get_lists_of(session["side"])[list] except: recipients = memory.get_lists_of(session["side"])["all"] bot_name = "Periwinkle_Prime_3" if session["side"] == 1 else "Orangered_HQ" botIO.send_message(ANTENNA, subject, content, recipients, bot_name) return redirect("/")
def home_page(): # tells the session the bot is online. Might actually make this useful # at some point. if NERVES.poll(): signal = NERVES.recv() session["status"] = signal elif "status" not in session: session["status"] = "OFFLINE" if not session.has_key("logged_in") or not session["logged_in"]: LOG.debug("Not logged in, displaying standard home page") return render_template("HomePage.html", groups=None, listname=None, listview=None, majors=None) # if the session has an invalid side, if not session.has_key("side") or session["side"] < 0: session["side"] = 1 # get the name of the list being managed, if any listname = request.args.get("listview") listname = listname if listname is not None else "all" if listname: LOG.debug("Listname = {}".format(listname)) # checks if a new list has been created if request.args.get("new_name") is not None: new_list_name = request.args.get("new_name") listname = new_list_name memory.create_list(session["side"], listname) LOG.debug("Added a new list {} to memory for side {}".format(listname, session["side"])) # if a player was removed, deal with that if request.args.get("remove") is not None: removed_player = request.args.get("remove") memory.remove_player(session["side"], listname, removed_player) LOG.debug("Removed {} from list {} of side {}".format(removed_player, listname, session["side"])) # if a player was added, deal with that if request.args.get("add") is not None: added_player = request.args.get("add") memory.add_player(session["side"], listname, added_player) LOG.debug("Added {} to list {} for side {}".format(added_player, listname, session["side"])) groups = memory.get_lists_of(session["side"]) LOG.debug("Groups for side {} are {}".format(session["side"], groups)) try: listview = groups[listname] LOG.debug("Users in group {}: {}".format(listname, listview)) except KeyError: listview = ["There's nothing here!"] try: majors = memory.get_players_with(g.db, side=session["side"], recruited=True) except sqlite3.InterfaceError: majors = [] return render_template( "HomePage.html", groups=groups, listname=listname, listview=listview, majors=majors, version=CONFIG["VERSION"] )