コード例 #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
        protected override async Task UserJoined(SocketGuildUser user)
        {
            SetContext(new MethodContext(user.Guild, null, null));
            if (!string.IsNullOrEmpty(Config.WelcomeMessage))
            {
                await user.SendMessageAsync(Config.WelcomeMessage);
            }

            await LogModule.LogMessage($"{user.Username} has joined the server.", "recruitment");
        }
コード例 #3
0
        /// <summary>
        /// Job for sending a discord message ten minutes before a moon is about to pop.
        /// </summary>
        /// <param name="job"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        Task MoonPoppedJob(MoonJob job, MethodContext context)
        {
            SystemMoon moon = this.MoonParser.Parse(job.Moon.Split(' '));

            if (TryGetMoon(moon, out MoonComposition comp))
            {
                return(LogModule.LogMessage(Config.MoonPingMessage, Config.MoonPingChannel, embed: comp.PrettyMoon()));
            }

            return(Task.CompletedTask);
        }
コード例 #4
0
        /// <summary>
        /// Verify that a discord users nickname is the same as his EVE name. Change it if there is a mismatch.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="eveId"></param>
        /// <returns></returns>
        async Task VerifyName(IGuildUser user, int eveId)
        {
            IApiResponse response = await ApiModule.Esi.Path("/characters/{character_id}/").Get(("character_id", eveId));

            if (response is ApiError)
            {
                return;
            }

            dynamic casted = JsonConvert.DeserializeObject <dynamic>(response.FirstPage);

            string userName = string.IsNullOrEmpty(user.Nickname) ? user.Username : user.Nickname;
            string eveName  = casted["name"].Value.ToString();

            if (userName != eveName)
            {
                await user.ModifyAsync(x => x.Nickname = eveName);

                await LogModule.LogMessage($"Updated nickname for {userName} to {eveName}", Config.LogChannel);
            }
        }
コード例 #5
0
        /// <summary>
        /// Loop for receiving commands from the bovril auth website.
        /// </summary>
        /// <returns></returns>
        async Task SocketServer(IGuild guild)
        {
            // Website is hosted on he same network.
            IPAddress  ipAdress      = IPAddress.Parse("127.0.0.1");
            IPEndPoint localEndPoint = new IPEndPoint(ipAdress, 55766);

            Socket listener = new Socket(ipAdress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            listener.Bind(localEndPoint);
            listener.Listen(100);

            while (true)
            {
                Socket socket = await listener.AcceptAsync();

                string command = await ReveiceMessage(socket);

                await LogModule.LogMessage($"Received command '{command}' from auth server.", "debug");
                await ProcessRequest(command, guild);
            }
        }
コード例 #6
0
 protected override Task UserLeft(SocketGuildUser user)
 {
     SetContext(new MethodContext(user.Guild, null, null));
     return(LogModule.LogMessage($"{user.Username} has left the server.", "recruitment"));
 }
コード例 #7
0
 /// <summary>
 /// Method to inform recruites when there is time for a checkup.
 /// </summary>
 /// <param name="job"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 Task CheckupJobMethod(CheckupJob job, MethodContext context)
 {
     return(LogModule.LogMessage($"{job.Character} has been in corp for 30 days. Time for a checkup.", Config.CheckupLogChannel));
 }
コード例 #8
0
		/// <summary>
		/// Remove a role from a user
		/// </summary>
		/// <param name="user"></param>
		/// <param name="role"></param>
		/// <returns></returns>
		async Task RemoveActualRole(IGuildUser user, ulong role)
		{
			IRole roleInstance = Guild.GetRole(role);
			await user.RemoveRoleAsync(roleInstance);
			await LogModule.LogMessage($"Role '{roleInstance.Name}' removed from {UserOrNickname(user)}", Config.LogChannel);
		}
コード例 #9
0
		/// <summary>
		/// Add a role to a user.
		/// </summary>
		/// <param name="user"></param>
		/// <param name="role"></param>
		/// <returns></returns>
		async Task AddActualRole(IGuildUser user, ulong role)
		{
			IRole roleInstance = Guild.GetRole(role);
			await user.AddRoleAsync(roleInstance);
			await LogModule.LogMessage($"Role '{roleInstance.Name}' added to {UserOrNickname(user)}", Config.LogChannel);
		}