def teamspeak_change(): action = request.form['action'] # add/remove, set if action == "add" and perm_edit_server.can(): display_name = request.form['displayName'] host = request.form['internalHost'] port = int(request.form['internalPort']) display_host = request.form['displayHost'] display_port = int(request.form['displayPort']) query_name = request.form['queryName'] query_password = request.form['queryPassword'] server_id = int(request.form['serverID']) channel_id = int(request.form['channelID']) client_name = request.form['clientName'] safety_channel_id = request.form['safetyChannelID'] ts = TeamspeakDatum(displayName=display_name, host=host, port=port, displayHost=display_host, displayPort=display_port, queryName=query_name, queryPassword=query_password, serverID=server_id, channelID=channel_id, clientName=client_name, safetyChannelID=safety_channel_id) db.session.add(ts) db.session.commit() # set as active ts if there was none before if sget_active_ts_id() is None: sset_active_ts_id(ts.teamspeakID) change_connection() elif action == "remove" and perm_edit_server.can(): teamspeak_id = int(request.form['teamspeakID']) db.session.query(TeamspeakDatum).filter( TeamspeakDatum.teamspeakID == teamspeak_id).delete() active_id = sget_active_ts_id() if active_id is not None and active_id == teamspeak_id: sset_active_ts_id(None) change_connection() db.session.commit() elif action == "set": teamspeak_id = int(request.form['teamspeakID']) active_id = sget_active_ts_id() sset_active_ts_id(teamspeak_id) if active_id is None: change_connection() else: flask.abort(400) return redirect(url_for("teamspeak.teamspeak"))
def move_fleetmembers_to_safety(): fleet_id = int(request.form.get('fleetID')) crest_fleet = db.session.query(CrestFleet).get(fleet_id) if not crest_fleet.comp.get_eve_id() == current_user.get_eve_id(): flask.abort(403, "You are not the Fleet Comp of this fleet!") teamspeak_id = sget_active_ts_id() if teamspeak_id is None: flask.abort(500, "No TeamSpeak Server set!") teamspeak: TeamspeakDatum = db.session.query(TeamspeakDatum).get( teamspeak_id) if teamspeak.safetyChannelID is None: flask.abort(500, "No TeamSpeak Safety Channel set!") # get the safety fleet channel id member = member_info.get_fleet_members(fleet_id, crest_fleet.comp) for charID in member: char_id: int = member[charID].character_id() char = db.session.query(Character).get(char_id) if char is None: continue safety_channel_id: int = teamspeak.safetyChannelID move_to_safety_channel(char.eve_name, safety_channel_id) return make_response("OK", 200)
def make_connection(): if config.disable_teamspeak: return None teamspeak_id = sget_active_ts_id() if teamspeak_id is None: return None teamspeak = db.session.query(TeamspeakDatum).get(teamspeak_id) try: con = TS3Connection(teamspeak.host, teamspeak.port) con.login(client_login_name=teamspeak.queryName, client_login_password=teamspeak.queryPassword) con.use(sid=teamspeak.serverID) con.clientupdate(CLIENT_NICKNAME=teamspeak.clientName) try: con.clientmove(cid=teamspeak.channelID, clid=0) except TS3QueryError as ex: if ex.resp.error['msg'] == "already member of channel": pass else: logger.error("Failed to connect to T3Query %s", ex.resp.error['msg']) con = None except TS3QueryError as ex: logger.error("Failed to connect to T3Query %s", ex.resp.error['msg']) con = None except Exception as ex: logger.error("Failed to connect to T3Query %s", ex) con = None return con
def index(): if 'groupId' in request.args: group_id = int(request.args.get('groupId')) group = db.session.query(WaitlistGroup).get(group_id) else: # noinspection PyPep8 group = db.session.query(WaitlistGroup).filter(WaitlistGroup.enabled == True).order_by( WaitlistGroup.odering).first() if group is None: return render_template("index.html", is_index=True) new_bro = True if current_user.type == "character": if current_user.newbro is None: new_bro = True else: new_bro = current_user.newbro elif current_user.type == "account": if current_user.current_char_obj.newbro is None: new_bro = True else: new_bro = current_user.current_char_obj.newbro wlists = [] logi_wl = group.logilist dps_wl = group.dpslist sniper_wl = group.sniperlist queue = group.xuplist other_wl = group.otherlist wlists.append(queue) wlists.append(logi_wl) wlists.append(dps_wl) wlists.append(sniper_wl) if other_wl is not None: wlists.append(other_wl) # noinspection PyPep8 activegroups = db.session.query(WaitlistGroup).filter(WaitlistGroup.enabled == True).all() active_ts_setting_id = sget_active_ts_id() active_ts_setting = None if active_ts_setting_id is not None: active_ts_setting = db.session.query(TeamspeakDatum).get(active_ts_setting_id) events = db.session.query(CalendarEvent).filter(CalendarEvent.eventTime > datetime.utcnow()).order_by( CalendarEvent.eventTime.asc()).limit(10).all() trivias: Optional[Sequence[Trivia]] = db.session.query(Trivia)\ .filter((Trivia.fromTime <= datetime.utcnow()) & (Trivia.toTime > datetime.utcnow())).all() if trivias is None: trivias = [] return render_template("index.html", lists=wlists, user=current_user, is_index=True, is_on_wl=is_on_wl(), newbro=new_bro, group=group, groups=activegroups, ts=active_ts_setting, events=events, trivias=trivias)
def teamspeak(): active_ts_setting_id = sget_active_ts_id() active_ts_setting = None if active_ts_setting_id is not None: active_ts_setting = db.session.query(TeamspeakDatum).get( active_ts_setting_id) all_ts_settings = db.session.query(TeamspeakDatum).all() return render_template("settings/ts.html", active=active_ts_setting, all=all_ts_settings)
def index(): new_bro = current_user.is_new # noinspection PyPep8 defaultgroup = db.session.query(WaitlistGroup).filter(WaitlistGroup.enabled == True) \ .order_by(WaitlistGroup.ordering).first() # noinspection PyPep8 activegroups = db.session.query(WaitlistGroup).filter( WaitlistGroup.enabled == True).all() ts_settings = None ts_id = sget_active_ts_id() if not disable_teamspeak and ts_id is not None: ts_settings = db.session.query(TeamspeakDatum).get(ts_id) return render_template("xup.html", newbro=new_bro, group=defaultgroup, groups=activegroups, ts=ts_settings)
def setup(fleet_id: int, fleet_type: str)\ -> Optional[Tuple[Optional[int], Optional[int], Optional[int], Optional[int]]]: fleet_api = EveFleetEndpoint(fleet_id) fleet_settings = fleet_api.get_fleet_settings() if fleet_settings.is_error(): logger.error("Failed to get Fleet Settings code[%d] msg[%s]", fleet_settings.code(), fleet_settings.error()) flask.abort(500) old_motd = fleet_settings.get_motd() wait_for_change = False # check number of wings fleet_wings = fleet_api.get_wings() num_wings = len(fleet_wings.wings()) if num_wings <= 0: fleet_api.create_wing() # create 1st wing fleet_api.create_wing() # create 2nd wing wait_for_change = True elif num_wings <= 1: fleet_api.create_wing() # create 2nd wing wait_for_change = True ts_string = "" ts_id = sget_active_ts_id() if ts_id is not None: teamspeak = db.session.query(TeamspeakDatum).get(ts_id) ts_string = teamspeak.displayHost if teamspeak.displayPort != 9987: ts_string = ts_string + ":" + str(teamspeak.displayPort) if len(old_motd) < 50: new_motd = "" if fleet_type == "hq": hq_motd = sget_motd_hq() if hq_motd is not None: new_motd = hq_motd elif fleet_type == "vg": vg_motd = sget_motd_vg() if vg_motd is not None: new_motd = vg_motd fleet_api.set_fleet_settings(False, new_motd.replace("$ts$", ts_string)) if wait_for_change: sleep(6) wait_for_change = False wing1 = wing2 = None for wing in fleet_api.get_wings().wings(): if wing.name() == "Wing 1" or wing.name().lower() == "on grid": wing1 = wing elif wing.name() == "Wing 2" or wing.name().lower() == "off grid": wing2 = wing if wing1 is None or wing2 is None: return None if wing1.name().lower() != "on grid": wait_for_change = True fleet_api.set_wing_name(wing1.id(), 'ON GRID') num_needed_squads = 4 if fleet_type == "hq" else 2 num_squads = len(wing1.squads()) if num_squads < num_needed_squads: for _ in range(num_needed_squads - num_squads): wait_for_change = True fleet_api.create_squad(wing1.id()) if wing2.name().lower() != "óff grid": fleet_api.set_wing_name(wing2.id(), 'OFF GRID') num_squads = len(wing2.squads()) if num_squads < 1: wait_for_change = True fleet_api.create_squad(wing2.id()) if wait_for_change: sleep(6) wings = fleet_api.get_wings() for wing in wings.wings(): if wing.name().lower() == "on grid": wing1 = wing elif wing.name().lower() == "off grid": wing2 = wing if wing1 is None or wing2 is None: return None logi_squad = sniper_squad = dps_squad = more_dps_squad = None for squad in wing1.squads(): if squad.name() == "Squad 1" or squad.name().lower() == "logi": logi_squad = squad elif squad.name() == "Squad 2" or squad.name().lower() == "sniper": sniper_squad = squad elif squad.name() == "Squad 3" or squad.name().lower() == "dps": dps_squad = squad elif squad.name() == "Squad 4" or squad.name().lower( ) == "more dps" or squad.name().lower() == "other": more_dps_squad = squad if fleet_type == "hq": if logi_squad is not None and logi_squad.name() == "Squad 1": fleet_api.set_squad_name(logi_squad.id(), 'LOGI') if sniper_squad is not None and sniper_squad.name() == "Squad 2": fleet_api.set_squad_name(sniper_squad.id(), 'SNIPER') if dps_squad is not None and dps_squad.name() == "Squad 3": fleet_api.set_squad_name(dps_squad.id(), 'DPS') if more_dps_squad is not None and more_dps_squad.name() == "Squad 4": fleet_api.set_squad_name(more_dps_squad.id(), 'MORE DPS') elif fleet_type == "vg": if logi_squad is not None and logi_squad.name() == "Squad 1": fleet_api.set_squad_name(logi_squad.id(), 'LOGI') if sniper_squad is not None and sniper_squad.name() == "Squad 2": fleet_api.set_squad_name(sniper_squad.id(), 'DPS') if wing2 is not None and len(wing2.squads()) > 0 and wing2.squads( )[0].name().lower() != "off grid": fleet_api.set_squad_name(wing2.squads()[0].id(), 'OFF GRID') sleep(5) return logi_squad, sniper_squad, dps_squad, more_dps_squad
def index(): """ current_time: datetime = datetime.utcnow() end_time: datetime = datetime(2016, 8, 7, 11, 0, 0) start_time: datetime = datetime(2016, 7, 4, 11, 0, 0) cc_vote_on: bool = ((start_time < current_time) and (current_time < end_time)) """ cc_vote_on: bool = False if 'groupId' in request.args: group_id = int(request.args.get('groupId')) group = db.session.query(WaitlistGroup).get(group_id) else: # noinspection PyPep8 group = db.session.query(WaitlistGroup).filter( WaitlistGroup.enabled == True).order_by( WaitlistGroup.ordering).first() if group is None: return render_template("index.html", is_index=True, ccvote_on=cc_vote_on) new_bro = current_user.is_new wlists = [] logi_wl = group.logilist dps_wl = group.dpslist sniper_wl = group.sniperlist queue = group.xuplist other_wl = group.otherlist wlists.append(queue) wlists.append(logi_wl) wlists.append(dps_wl) wlists.append(sniper_wl) if other_wl is not None: wlists.append(other_wl) # noinspection PyPep8 activegroups = db.session.query(WaitlistGroup).filter( WaitlistGroup.enabled == True).all() active_ts_setting_id = sget_active_ts_id() active_ts_setting = None if not disable_teamspeak and active_ts_setting_id is not None: active_ts_setting = db.session.query(TeamspeakDatum).get( active_ts_setting_id) events = db.session.query(CalendarEvent).filter( CalendarEvent.eventTime > datetime.utcnow()).order_by( CalendarEvent.eventTime.asc()).limit(10).all() trivias: Optional[Sequence[Trivia]] = db.session.query(Trivia)\ .filter((Trivia.fromTime <= datetime.utcnow()) & (Trivia.toTime > datetime.utcnow())).all() if trivias is None: trivias = [] return render_template("index.html", lists=wlists, user=current_user, is_index=True, is_on_wl=is_on_wl(), newbro=new_bro, group=group, groups=activegroups, ts=active_ts_setting, events=events, trivias=trivias, ccvote_on=cc_vote_on, stattool_enabled=stattool_enabled, stattool_uri=stattool_uri, stattool_sri=stattool_sri)