Пример #1
0
        async static void Deny(SocketMessage message, ulong id)
        {
            var requests = PingRequests.PullData();

            if (requests.Count(x => x.ID == id) == 0)
            {
                await message.Channel.SendMessageAsync("❌ Unkown ID!");

                return;
            }
            var request = requests.Find(x => x.ID == id);

            var deniedEmbed = new EmbedBuilder()
                              .WithAuthor(author =>
            {
                author
                .WithName("Ping Request")
                .WithIconUrl("https://cdn.discordapp.com/attachments/782305154342322226/782619217055842334/noun_Close_1984788.png");         // Close by Bismillah from the Noun Project
            })
                              .WithDescription(request.Description.Replace("Waiting...", "Denied"))
                              .WithFooter(((SocketGuildChannel)message.Channel).Guild.Name)
                              .WithColor(new Color(0xDD0000)).Build();
            var oldMsg = await((IMessageChannel)Program._client.GetChannel(BaseConfig.GetConfig().Channels.PingRequests)).GetMessageAsync(request.ID);

            await((IUserMessage)oldMsg).ModifyAsync(m => m.Embed = deniedEmbed);

            requests.Remove(request);
            PingRequests.PushData(requests);

            await message.Channel.SendMessageAsync("Request denied");
        }
Пример #2
0
        async static void Approve(SocketMessage message, ulong id)
        {
            var requests = PingRequests.PullData();

            if (requests.Count(x => x.ID == id) == 0)
            {
                await message.Channel.SendMessageAsync("❌ Unkown ID!");

                return;
            }
            var request = requests.Find(x => x.ID == id);
            var role    = ((SocketGuildChannel)message.Channel).Guild.GetRole(request.RoleID);

            await((IMessageChannel)Program._client.GetChannel(request.ChannelID)).SendMessageAsync(role.Mention);

            var approvedEmbed = new EmbedBuilder()
                                .WithAuthor(author =>
            {
                author
                .WithName("Ping Request")
                .WithIconUrl("https://cdn.discordapp.com/attachments/782305154342322226/782586791831666688/noun_checkmark_737739.png");         // checkmark by Vladimir from the Noun Project
            })
                                .WithDescription(request.Description.Replace("Waiting...", "Approved"))
                                .WithFooter(((SocketGuildChannel)message.Channel).Guild.Name)
                                .WithColor(new Color(0x00DD00)).Build();
            var oldMsg = await((IMessageChannel)Program._client.GetChannel(BaseConfig.GetConfig().Channels.PingRequests)).GetMessageAsync(request.ID);

            await((IUserMessage)oldMsg).ModifyAsync(m => m.Embed = approvedEmbed);

            requests.Remove(request);
            PingRequests.PushData(requests);

            await message.Channel.SendMessageAsync("Request approved");
        }
 public void AllRequestsCompleted()
 {
     SentPackages     = PingRequests.GetRequestNumber();
     LostPackages     = PingRequests.GetNumOfLostPackage();
     LostInPercent    = Math.Round(PingRequests.GetLossesInPercent(), 2);
     ReceivedPackages = SentPackages - LostPackages;
     MinTime          = PingRequests.GetMinRoundtripTime();
     MaxTime          = PingRequests.GetMaxRoundtripTime();
     AverageTime      = Math.Round(PingRequests.GetAverageRoundtripTime(), 2);
     PingRequests.Clear();
 }
        private void SendRequest(object obj)
        {
            string data = "";

            for (int i = 0; i < BufferSize; i++)
            {
                data += "a";
            }
            byte[]      buffer  = Encoding.ASCII.GetBytes(data);
            PingOptions options = new PingOptions(TimeToLife, IsFragmentation);

            requests.Clear();
            if (IsManualStopSending)
            {
                PingRequests.IsToContinueSending = true;
                PingRequests.SendRequestsUntilStopping(Address, Timeout, buffer, options);
            }
            else
            {
                PingRequests.SetRequestNumber(RequestsNumber);
                PingRequests.SendRequests(Address, Timeout, buffer, options);
            }
        }
Пример #5
0
        async static void Request(SocketMessage message, SocketRole role)
        {
            var    requests            = PingRequests.PullData();
            Random r                   = new Random();
            var    pingRequestsChannel = (IMessageChannel)Program._client.GetChannel(BaseConfig.GetConfig().Channels.PingRequests);

            if (Program.HasPerm(PtanProRoles))
            {
                ulong[] allowedRoles =
                {
                    915699684327186452,
                    915699889399271494,
                    642999690140450816,
                    643057615542157325,
                    915700336080085012,
                    915700679895556157,
                    718745058328707144,
                    656935125610790932,
                    656935401889464320,
                    693928850576506962,
                    915700971697504276,
                    848142088579448862,
                    915701267865677904,
                    656934935978049586
                };

                if (allowedRoles.Contains(role.Id))
                {
                    await message.Channel.SendMessageAsync(role.Mention);

                    await message.Channel.DeleteMessageAsync(message);
                }
                else
                {
                    await message.Channel.SendMessageAsync("❌ No, I will not ping that!");
                }
                return;
            }

            var responseEmbed = new EmbedBuilder()
                                .WithAuthor(author =>
            {
                author
                .WithName("Ping Request Sent")
                .WithIconUrl("https://cdn.discordapp.com/attachments/782305154342322226/782336504462049300/noun_At_7133.png");         // At by Márcio Duarte from the Noun Project
            })
                                .WithDescription($"{role.Mention}\nYour request will be reviewed soon")
                                .WithFooter(((SocketGuildChannel)message.Channel).Guild.Name)
                                .WithColor(role.Color).Build();
            var response = await message.Channel.SendMessageAsync(null, embed : responseEmbed);

            var embedMessage = await pingRequestsChannel.SendMessageAsync(null, embed : new EmbedBuilder().WithDescription("Embed").Build());

            var requestEmbed = new EmbedBuilder()
                               .WithAuthor(author =>
            {
                author
                .WithName("Ping Request")
                .WithIconUrl("https://cdn.discordapp.com/attachments/782305154342322226/782886030638055464/noun_Plus_1809808.png");         // Plus by sumhi_icon from the Noun Project
            })
                               .WithDescription($"{message.Author.Mention} requested to ping {role.Mention} in <#{message.Channel.Id}>.\nStatus: **Waiting...**\n\n Request's link:\n https://discord.com/channels/{((SocketGuildChannel)message.Channel).Guild.Id}/{message.Channel.Id}/{response.Id} \n\nID: `{embedMessage.Id}`")
                               .WithFooter(((SocketGuildChannel)message.Channel).Guild.Name).Build();
            await embedMessage.ModifyAsync(m => m.Embed = requestEmbed);

            var mention = await pingRequestsChannel.SendMessageAsync(((SocketGuildChannel)message.Channel).Guild.GetRole(782879567873310740).Mention); // PingRequest role pingelése a moderátorok értesítéséért.

            await message.Channel.DeleteMessageAsync(message);

            await pingRequestsChannel.DeleteMessageAsync(mention);

            requests.Add(new PingRequests(embedMessage.Id, role.Id, message.Channel.Id, requestEmbed.Description));
            PingRequests.PushData(requests);
        }