Beispiel #1
0
        public async void GetRefreshToken(string refreshToken)
        {
            token = await _client.SSO.GetToken(GrantType.RefreshToken, refreshToken);

            //Extensions.AwaitMessage(ref token.RefreshToken, "Awaiting token...", "Token downloaded.");
            Settings.AuthorisationData = Verify().Result;
            //Extensions.AwaitMessage(ref Settings.AuthorisationData.CharacterName, "Awaiting verification...", "Token verified successfully.");
            _client.SetCharacterData(Settings.AuthorisationData);
            Console.WriteLine("Character data set.");
            Console.WriteLine();

            Settings.Save();
        }
        /// <summary>
        /// Invites the pilot to a fleet. If a specific squad is not specified they will be invited to the default squad.
        /// </summary>
        /// <param name="fleetBoss">Fleet Boss explicit cast as AuthorizedCharacterData</param>
        /// <param name="fleetId">Target fleet Id</param>
        /// <param name="squadId">Target squad Id</param>
        /// <param name="pilotId">Invitee Id</param>
        public static async Task <object> FleetInvite(AuthorizedCharacterData fleetBoss, long fleetId, long squadId, long wingId, int pilotId)
        {
            try
            {
                EsiClient x = GetEsiClient();
                x.SetCharacterData(fleetBoss);
                EsiResponse <string> response = await x.Fleets.InviteCharacter(fleetId, pilotId, ESI.NET.Enumerations.FleetRole.SquadMember, wingId, squadId);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    s_Log.LogError("{0} error search API '{1}': {2}", response.StatusCode, response.Endpoint, response.Message);

                    Exception ex;
                    if (response.Message.Contains("'error_label': 'FleetCandidateOffline', 'error_dict'"))
                    {
                        ex = new Exception("Fleet Candidate Offline");
                    }
                    else
                    {
                        ex = new Exception(response.Message);
                    }

                    throw new Exception("Fleet Invite Failed", ex);
                }

                return(null);
            }
            catch (Exception ex)
            {
                //s_Log.LogError("{0} error searching API '{1}': {2}", FleetMembers_response.StatusCode, FleetMembers_response.Endpoint, FleetMembers_response.Message);
                //throw new Exception(FleetLayout_response.ErrorType().ToString());
                throw new NotImplementedException();
            }
        }
Beispiel #3
0
        public async Task Start()
        {
            // set up esi connection
            var scopes = new List <string> {
                "esi-mail.send_mail.v1", "esi-search.search_structures.v1", "esi-mail.read_mail.v1", "esi-mail.organize_mail.v1"
            };
            var url = _esiClient.SSO.CreateAuthenticationUrl(scopes);

            System.Diagnostics.Process.Start(url);
            var esiAuthToken = GetEsiAuthToken();
            var token        = await _esiClient.SSO.GetToken(GrantType.AuthorizationCode, esiAuthToken);

            var authChar = await _esiClient.SSO.Verify(token);

            _refreshToken    = authChar.RefreshToken;
            _esiTokenExpires = authChar.ExpiresOn;
            _esiClient.SetCharacterData(authChar);

            // get the mailing list id
            var response = await _esiClient.Mail.MailingLists();

            var mailingList = response.Data.Where(ml => ml.Name.ToLower() == _mailingListName.ToLower()).FirstOrDefault();

            if (mailingList == null)
            {
                Log("The character  used does not have access to the mailing list specified in the config. Please look at mailingListName app setting.");
            }

            _mailingListId = mailingList.MailingListId;

            // set up the discord bot
            _discordClient = new DiscordSocketClient();
            _discordClient.ReactionAdded   += ReactionAdded;
            _discordClient.MessageReceived += MessageReceived;

            await _discordClient.LoginAsync(TokenType.Bot, _discordAuthToken);

            await _discordClient.StartAsync();

            await Task.Delay(-1);
        }
 /// <summary>
 /// Opens the Show Info window for a Character, Corporation or Alliance in game.
 /// </summary>
 /// <param name="pilot">Pilot explicit cast as AuthorizedCharacterData</param>
 /// <param name="target_id"></param>
 /// <see cref="Models.Pilot"/>
 /// <seealso cref="AuthorizedCharacterData"/>
 /// <seealso cref="ESI.NET.Models.Character"/>
 /// <seealso cref="ESI.NET.Models.Corporation"/>
 /// <seealso cref="ESI.NET.Models.Alliance"/>
 public static void ShowInfo(AuthorizedCharacterData pilot, int target_id)
 {
     try
     {
         EsiClient x = GetEsiClient();
         x.SetCharacterData(pilot);
         x.UserInterface.Information(target_id);
     }
     catch (Exception ex)
     {
         Console.Beep();
     }
 }
 /// <summary>
 /// Sets a new autopilot destination in game.
 /// </summary>
 /// <param name="pilot">Pilot explicit cast as AuthorizedCharacterData</param>
 /// <param name="system_id">ID of the target solar system.</param>
 /// <see cref="ESI.NET.Models.Universe.SolarSystem"/>
 public static void SetDestination(AuthorizedCharacterData pilot, int system_id)
 {
     try
     {
         EsiClient x = GetEsiClient();
         x.SetCharacterData(pilot);
         x.UserInterface.Waypoint(system_id, true, true);
     }
     catch (Exception ex)
     {
         Console.Beep();
     }
 }
        public static async Task <List <ESI.NET.Models.Fleets.Wing> > GetFleetLayout(AuthorizedCharacterData fleetBoss, long fleetId)
        {
            EsiClient x = GetEsiClient();

            x.SetCharacterData(fleetBoss);
            EsiResponse <List <ESI.NET.Models.Fleets.Wing> > FleetLayout_response = await x.Fleets.Wings(fleetId);

            if (FleetLayout_response.StatusCode != HttpStatusCode.OK)
            {
                s_Log.LogError("{0} error search API '{1}': {2}", FleetLayout_response.StatusCode, FleetLayout_response.Endpoint, FleetLayout_response.Message);
                throw new Exception(FleetLayout_response.ErrorType().ToString());
            }

            return(FleetLayout_response.Data);
        }
        /// <summary>
        /// Checks ESI to see if the pilot is online.
        /// </summary>
        /// <param name="pilot">Pilot explicit cast as AuthorizedCharacterData</param>
        /// <returns>Bool</returns>
        public static async Task <bool> IsOnlineAsync(AuthorizedCharacterData pilot)
        {
            EsiClient x = GetEsiClient();

            x.SetCharacterData(pilot);
            EsiResponse <ESI.NET.Models.Location.Activity> Location_response = await x.Location.Online();

            if (Location_response.StatusCode != HttpStatusCode.OK)
            {
                s_Log.LogError("{0} error searching API '{1}': {2}", Location_response.StatusCode, Location_response.Endpoint, Location_response.Message);
                return(true);
            }

            return(Location_response.Data.Online);
        }
        public static async Task <List <ESI.NET.Models.Fleets.Member> > GetFleetMembers(AuthorizedCharacterData pilot, long fleet_id)
        {
            EsiClient esi = GetEsiClient();

            esi.SetCharacterData(pilot);

            EsiResponse <System.Collections.Generic.List <ESI.NET.Models.Fleets.Member> > FleetMembers_response = await esi.Fleets.Members(fleet_id);

            if (FleetMembers_response.StatusCode != HttpStatusCode.OK)
            {
                s_Log.LogError("{0} error searching API '{1}': {2}", FleetMembers_response.StatusCode, FleetMembers_response.Endpoint, FleetMembers_response.Message);
                throw new Exception(FleetMembers_response.ErrorType().ToString());
            }

            return(FleetMembers_response.Data);
        }
        public static async Task <ESI.NET.Models.Location.Location> GetSystem(AuthorizedCharacterData pilot)
        {
            EsiClient x = GetEsiClient();

            x.SetCharacterData(pilot);
            EsiResponse <ESI.NET.Models.Location.Location> Location_response = await x.Location.Location();

            if (Location_response.StatusCode != HttpStatusCode.OK)
            {
                s_Log.LogError("{0} error searching API '{1}': {2}", Location_response.StatusCode, Location_response.Endpoint, Location_response.Message);
                return(null);
            }


            return(Location_response.Data);
        }
Beispiel #10
0
        public async void finishAuth(string uri)
        {
            // eveauth-eveclip://callback/?code=DX58B9i1IkvZj23aoAZPXQmNR1NZi7hixM0Vm2lWXV71zl1-Dlpkd1jUgS4gl0tq0
            int    pos  = uri.IndexOf("?code=");
            string code = uri.Substring(pos + 6);

            try
            {
                SsoToken token = await m_client.SSO.GetToken(GrantType.AuthorizationCode, code);

                m_authCharData = await m_client.SSO.Verify(token.Value);

                m_client.SetCharacterData(m_authCharData);
            }
            catch (Exception)
            {
                MessageBox.Show("Login failed. Please enter ClientID and SecretKey in Options. See https://developers.eveonline.com/ for details.", "Error logging in");
            }
        }