コード例 #1
0
        /// <summary>
        /// Verify user corp role.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="corpRole"></param>
        /// <param name="eveId"></param>
        /// <returns></returns>
        async Task VerifyCorp(IGuildUser user, IRole corpRole, IRole legacyRole, int eveId)
        {
            IApiResponse corpusersReponse = await ApiModule.Esi.Path("/corporations/{corporation_id}/members/").Get(("corporation_id", Config.CorporationID));

            List <int> corpUsers = corpusersReponse.ToType <List <int> >().FirstPage;

            bool inCorp      = corpUsers.Contains(eveId);
            bool hasCorpRole = await RoleModule.HasRoleAsync(user, corpRole.Name);

            bool hasLegacyRole = await RoleModule.HasRoleAsync(user, legacyRole.Name);

            await UpdateRole(user, corpRole, inCorp, hasCorpRole);

            // Give char legacy role if he has been in corp for six months
            if (!inCorp && hasCorpRole)
            {
                int days = await GetDaysInCorp(eveId);

                if (days >= 30 * 6)                // Min of six months in corp.
                {
                    await LogModule.LogMessage($"{user.Nickname} has been in corp for {days} days and has been moved to #Legacy.", Config.LogChannel);
                    await UpdateRole(user, legacyRole, true, hasLegacyRole);
                }
            }

            if (inCorp && !hasCorpRole)
            {
                string name = (Message.Author as IGuildUser).Nickname ?? Message.Author.Username;

                if (!await JobModule.JobExistsAsync <CheckupJob>(x => x.Character == name))
                {
                    await JobModule.AddJobAsync(new CheckupJob("RecruitmentModule", name));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Verify user alliance role.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="allianceRole"></param>
        /// <param name="eveId"></param>
        /// <returns></returns>
        async Task VerifyAlliance(IGuildUser user, IRole allianceRole, int eveId)
        {
            IApiResponse characterInfo = await ApiModule.Esi.Path("/characters/{character_id}/").Get(("character_id", eveId));

            int corpID = JsonConvert.DeserializeObject <dynamic>(characterInfo.FirstPage)["corporation_id"];

            IApiResponse allianceCorpsResponse = await ApiModule.Esi.Path("/alliances/{alliance_id}/corporations/").Get(("alliance_id", Config.AllianceID));

            List <int> allianceCorps = allianceCorpsResponse.ToType <List <int> >().FirstPage;

            bool inAlliance = allianceCorps.Contains(corpID);
            bool hasRole    = await RoleModule.HasRoleAsync(user, allianceRole.Name);

            await UpdateRole(user, allianceRole, inAlliance, hasRole);
        }
コード例 #3
0
ファイル: CacheManager.cs プロジェクト: Alkrun/Eve-OpenAPI
        public async Task <IApiResponse <T> > GetResponse <T>(IApiRequest request)
        {
            IApiResponse response = await GetResponse(request);

            return(response.ToType <T>());
        }