Exemplo n.º 1
0
 public static bool IsDev(IUser user)
 {
     for (int i = 0; i <= DevConfig.Load().Devs - 1; i++)
     {
         if (DevConfig.Load().Developers[i] == user.Id)
         {
             Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Suggestions", "This isn't a suggestion, it is a dev!"));
             return(true);
         }
     }
     Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Suggestions", "This isn't a dev, it is a suggestion!"));
     return(false);
 }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Create directories
            ConfigData config = new ConfigData()
            {
                AppConfig    = AppConfig.Load(),
                DevConfig    = DevConfig.Load(),
                KeyMapConfig = KeyMapConfig.Load(),
                SysMessage   = SysMessage.Load()
            };

            ConfigData.Initialize(config);

            PD17();
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        static bool AppInitialize()
        {
            var exists = AppConfig.Exists() &&
                         DevConfig.Exists() &&
                         KeyMapConfig.Exists();

            exists &= MasterDbHelper.DbExists() && TranDbHelper.DbExists();

            if (exists)
            {
                // Create directories
                ConfigData config = new ConfigData()
                {
                    AppConfig    = AppConfig.Load(),
                    DevConfig    = DevConfig.Load(),
                    KeyMapConfig = KeyMapConfig.Load(),
                    SysMessage   = SysMessage.Load()
                };

                ConfigData.Initialize(config);

                exists &= !string.IsNullOrEmpty(config.AppConfig.PosInfo.PosNo) &&
                          !string.IsNullOrEmpty(config.AppConfig.PosInfo.StoreNo);
            }

            if (!exists)
            {
                new MessageDialog(MessageDialogType.Warning, null, string.Empty,
                                  MSG_POS_ENV_INVALID).ShowDialog();
            }
            else
            {
                // set path to damo
                AddPathSegments(FXConsts.FOLDER_DAMO.GetLibFolder());

                // DAMO 암호화 모듈 초기설정
                DataUtils.DamoInitialize();

                // OCXRegister
                string ksNetFile = FXConsts.FOLDER_OCX.GetLibFolder() + "\\KSNet_Dongle.ocx";
                FileUtils.RegSvr32(ksNetFile);

                string keyBoardHookFile = FXConsts.FOLDER_OCX.GetLibFolder() + "\\KeyboardHook.ocx";
                FileUtils.RegSvr32(keyBoardHookFile);
            }

            return(exists);
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create directories
            ConfigData config = new ConfigData()
            {
                AppConfig    = AppConfig.Load(),
                DevConfig    = DevConfig.Load(),
                KeyMapConfig = KeyMapConfig.Load(),
                SysMessage   = SysMessage.Load()
            };

            ConfigData.Initialize(config);

            TextBoxTraceListener listener = new TextBoxTraceListener(txtTraceLog);

            Trace.Listeners.Add(new LogFileTraceListener(LogUtils.Instance));
        }
Exemplo n.º 5
0
        void Initialize()
        {
            // Create directories
            ConfigData config = new ConfigData()
            {
                AppConfig    = AppConfig.Load(),
                DevConfig    = DevConfig.Load(),
                KeyMapConfig = KeyMapConfig.Load(),
                SysMessage   = SysMessage.Load()
            };

            ConfigData.Initialize(config);

            // refresh global config
            FrameBaseData.Current.OnDataChanged(FrameBaseDataItem.ConfigChanged, null);
            SetTopMenu("MNU_CONFIG");

            this.Shown += new EventHandler(MainForm_Shown);
        }
Exemplo n.º 6
0
        public async Task DeleteCommandAsync(int amount = 100, SocketGuildUser user = null)
        {
            Errors errors = new Errors();
            await Context.Message.DeleteAsync();

            for (int i = 0; i <= DevConfig.Load().Devs - 1; i++)
            {
                if (DevConfig.Load().Developers[i] == Context.Message.Author.Id)
                {
                    if (user == null)
                    {
                        if (amount > 100)
                        {
                            await errors.sendErrorAsync(Context.Channel, "You can not clear more than 100! Deleting 100.", Colours.errorCol);

                            var messageHistory = await Context.Channel.GetMessagesAsync(101).Flatten();

                            await Context.Channel.DeleteMessagesAsync(messageHistory);

                            await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Admin Commands", "Clear command was used by " + Context.User + "."));

                            await Program.Logger(new LogMessage(LogSeverity.Verbose, "GTA5Police Admin Commands", "100 messages were deleted in the channel " + Context.Channel.Name + " by " + Context.User + "."));
                        }
                        else if (amount < 1)
                        {
                            await errors.sendErrorTempAsync(Context.Channel, "You can not clear a negative amount of messages!", Colours.errorCol);
                        }
                        else
                        {
                            var messageHistory = await Context.Channel.GetMessagesAsync(amount).Flatten();

                            await Context.Channel.DeleteMessagesAsync(messageHistory);

                            await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Admin Commands", "Clear command was used by " + Context.User + "."));

                            await Program.Logger(new LogMessage(LogSeverity.Verbose, "GTA5Police Admin Commands", amount + " messages were deleted in the channel " + Context.Channel.Name + " by " + Context.User + "."));
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public async Task DevAddCommandAsync(IUser developer)
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (Context.User.Id == BotConfig.Load().BotCommanders[i])
                {
                    var dev = developer.Id;

                    DevConfig devConfig = new DevConfig();
                    devConfig = Update.UpdateDevConfig(devConfig);
                    devConfig.Developers[DevConfig.Load().Devs] = dev;
                    devConfig.Devs = DevConfig.Load().Devs + 1;
                    devConfig.Save();

                    var embed = new EmbedBuilder()
                    {
                        Color = Colours.adminCol
                    };
                    embed.WithAuthor("Successfully Added", References.GetGta5policeLogo());
                    embed.WithThumbnailUrl(References.GetGta5policeLogo());
                    embed.Description = "The developer " + developer + " was successfully added.";
                    embed.WithFooter(new EmbedFooterBuilder()
                    {
                        Text = "Requested by " + Context.User
                    });
                    embed.WithCurrentTimestamp();

                    await Context.Message.DeleteAsync();

                    var message = await Context.Channel.SendMessageAsync("", false, embed);

                    await Delete.DelayDeleteEmbedAsync(message, 120);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Admin Commands", "Dev add command was used by " + Context.User + "."));

                    Statistics.AddOutgoingMessages();
                }
            }
        }
Exemplo n.º 8
0
        public static async Task HandleSuggestionAsync(SocketMessage pMsg)
        {
            Errors errors  = new Errors();
            var    message = pMsg as SocketUserMessage;
            var    user    = message.Author;

            if (user.Id == 211938243535568896)
            {
                return;
            }
            if (message == null)
            {
                return;
            }
            if (user.IsBot)
            {
                return;
            }
            if (message.Channel.Id != DevConfig.Load().Suggestions)
            {
                return;
            }
            if (SuggestionCheck.IsDev(user) == true)
            {
                return;
            }
            if (SuggestionCheck.IsCorrectLayout(pMsg.ToString()) == true)
            {
                return;
            }

            await errors.sendErrorTempAsync(message.Channel, message.Author.Mention + " please use the correct message layout, it is pinned in this channel!", Colours.errorCol);

            var iDMChannel = await user.GetOrCreateDMChannelAsync();

            await iDMChannel.SendMessageAsync("Here is a copy of your suggestion that was in the wrong layout.\n```\n" + pMsg.ToString() + "\n```\nPlease use the layout that is pinned in the suggestions channel!");

            await pMsg.DeleteAsync();
        }
Exemplo n.º 9
0
        public async Task SettingsCommandAsync()
        {
            for (int i = 0; i <= BotConfig.Load().Commanders - 1; i++)
            {
                if (BotConfig.Load().BotCommanders[i] == Context.User.Id)
                {
                    var embed = new EmbedBuilder()
                    {
                        Color = Colours.adminCol
                    };
                    var blankField = new EmbedFieldBuilder()
                    {
                        Name = "\u200b", Value = "\u200b"
                    };

                    embed.WithAuthor("GTA5PoliceV2 Settings", References.GetGta5policeLogo());
                    embed.WithThumbnailUrl(References.GetGta5policeLogo());

                    string filtered = null;
                    for (int j = 0; j <= BotConfig.Load().Filters - 1; j++)
                    {
                        var filter = BotConfig.Load().FilteredWords[j].ToString();
                        if (filtered != null)
                        {
                            filtered = filtered + ", " + filter;
                        }
                        if (filtered == null)
                        {
                            filtered = filter;
                        }
                    }
                    if (filtered != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Filtered Words", Value = filtered, IsInline = true
                        });
                    }
                    if (filtered == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Filtered Words", Value = "No filtered words.", IsInline = true
                        });
                    }

                    string commanders = null;
                    for (int j = 0; j <= BotConfig.Load().Commanders - 1; j++)
                    {
                        var commander = Context.Client.GetUserAsync(BotConfig.Load().BotCommanders[j]).Result.ToString();
                        if (commanders != null)
                        {
                            commanders = commanders + ", " + commander;
                        }
                        if (commanders == null)
                        {
                            commanders = commander;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Bot commanders", Value = commanders, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Bot commanders", Value = "No commanders.", IsInline = true
                        });
                    }


                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Server Id", Value = BotConfig.Load().ServerId, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Logs Id", Value = BotConfig.Load().LogsId, IsInline = true
                    });
                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Timer Channel Id", Value = BotConfig.Load().TimerChannelId, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Status Timer Interval (Minutes)", Value = BotConfig.Load().StatusTimerInterval, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Message Timer Interval (Minutes)", Value = BotConfig.Load().MessageTimerInterval, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Message Timer Cooldown (Messages)", Value = BotConfig.Load().MessageTimerCooldown, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Command Cooldown (Seconds)", Value = BotConfig.Load().CommandCooldown, IsInline = true
                    });
                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Server IP", Value = ConnectionsConfig.Load().ServerIp, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "NY Port", Value = ConnectionsConfig.Load().NyPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "LA Port", Value = ConnectionsConfig.Load().LaPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "NY WL Port", Value = ConnectionsConfig.Load().NyWlPort, IsInline = true
                    });
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "LA WL Port", Value = ConnectionsConfig.Load().LaWlPort, IsInline = true
                    });

                    embed.AddField(blankField);
                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "EMS Add/Remove", Value = BotConfig.Load().EmsAdd, IsInline = true
                    });
                    string emsHighUps = null;
                    for (int j = 0; j <= RanksConfig.Load().EMSHighRanks - 1; j++)
                    {
                        var emsHighUp = RanksConfig.Load().EMSHighRanksArray[j];
                        if (emsHighUps != null)
                        {
                            emsHighUps = emsHighUps + ", " + emsHighUp;
                        }
                        if (emsHighUps == null)
                        {
                            emsHighUps = emsHighUp;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "EMS Highup Ranks", Value = emsHighUps, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "EMS Highup Ranks", Value = "No high up ranks?", IsInline = true
                        });
                    }

                    embed.AddField(new EmbedFieldBuilder()
                    {
                        Name = "Cop Add/Remove", Value = BotConfig.Load().PoliceAdd, IsInline = true
                    });
                    string copHighUps = null;
                    for (int j = 0; j <= RanksConfig.Load().PDHighRanks - 1; j++)
                    {
                        var copHighUp = RanksConfig.Load().PDHighRanksArray[j];
                        if (copHighUps != null)
                        {
                            copHighUps = copHighUps + ", " + copHighUp;
                        }
                        if (copHighUps == null)
                        {
                            copHighUps = copHighUp;
                        }
                    }
                    if (commanders != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Police Highup Ranks", Value = copHighUps, IsInline = true
                        });
                    }
                    if (commanders == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Police Highup Ranks", Value = "No high up ranks?", IsInline = true
                        });
                    }

                    embed.AddField(blankField);
                    string devs = null;
                    for (int j = 0; j <= DevConfig.Load().Devs - 1; j++)
                    {
                        var dev = Context.Client.GetUserAsync(DevConfig.Load().Developers[j]).Result.ToString();
                        if (devs != null)
                        {
                            devs = devs + ", " + dev;
                        }
                        if (devs == null)
                        {
                            devs = dev;
                        }
                    }
                    if (devs != null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Developers", Value = devs, IsInline = true
                        });
                    }
                    if (devs == null)
                    {
                        embed.AddField(new EmbedFieldBuilder()
                        {
                            Name = "Developers", Value = "No developers added", IsInline = true
                        });
                    }

                    embed.WithFooter(new EmbedFooterBuilder()
                    {
                        Text = References.NAME + References.VERSION
                    });
                    embed.WithCurrentTimestamp();

                    await Context.Message.DeleteAsync();

                    var message = await Context.Channel.SendMessageAsync("", false, embed);

                    await Delete.DelayDeleteEmbedAsync(message, 120);

                    await Program.Logger(new LogMessage(LogSeverity.Info, "GTA5Police Configuration Commands", "Settings command was used by " + Context.User + "."));

                    Statistics.AddOutgoingMessages();
                }
            }
        }
Exemplo n.º 10
0
        public static void EnsureBotConfigExists()
        {
            Logger(new LogMessage(LogSeverity.Info, "GTA5Police Start Up", "Searching for existing configurations."));
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "configuration")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "configuration"));
            }

            string configLoc      = Path.Combine(AppContext.BaseDirectory, "configuration/config.json");
            string connectionsLoc = Path.Combine(AppContext.BaseDirectory, "configuration/connections_config.json");
            string urlsLoc        = Path.Combine(AppContext.BaseDirectory, "configuration/url_config.json");
            string devConfigLoc   = Path.Combine(AppContext.BaseDirectory, "configuration/dev_config.json");
            string ranksConfigLoc = Path.Combine(AppContext.BaseDirectory, "configuration/ranks_config.json");
            string autoBansLoc    = Path.Combine(AppContext.BaseDirectory, "configuration/auto_bans.json");

            if (!File.Exists(configLoc))
            {
                var config = new BotConfig();

                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Enter the following info for the configuration."));
                Console.Write("Bot Prefix: ");
                config.Token = Console.ReadLine();
                Console.Write("Bot Token: ");
                config.Token                = Console.ReadLine();
                config.ServerId             = 0;
                config.LogsId               = 0;
                config.TimerChannelId       = 0;
                config.StatusTimerInterval  = 1;
                config.MessageTimerInterval = 30;
                config.MessageTimerCooldown = 5;
                config.CommandCooldown      = 120.0d;
                config.Commanders           = 1;
                config.BotCommanders[0]     = 211938243535568896;
                config.Filters              = 0;
                config.PoliceAdd            = false;
                config.EmsAdd               = false;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Main configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Main configuration has been loaded"));

            if (!File.Exists(connectionsLoc))
            {
                var connections = new ConnectionsConfig();

                connections.ServerIp = "66.150.121.131";
                connections.NyPort   = 30150;
                connections.LaPort   = 30141;
                connections.NyWlPort = 30151;
                connections.LaWlPort = 30142;
                connections.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Connections configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Connections configuration has been loaded"));

            if (!File.Exists(urlsLoc))
            {
                var url = new UrlConfig();
                url.Website     = "https://www.gta5police.com";
                url.Dashboard   = "https://gta5police.com/panel/index.php";
                url.Forums      = "https://gta5police.com/forums/";
                url.Support     = "http://gta5police.com/forums/index.php?/support/";
                url.Suggestions = "https://gta5police.com/forums/index.php?/forum/5-suggestions/";
                url.Donate      = "http://gta5police.com/forums/index.php?/donate/";
                url.Vacbanned   = "http://www.vacbanned.com";

                url.Applications = "https://goo.gl/DpTEyH";
                url.Whitelist    = "https://goo.gl/TLSGdf";
                url.Police       = "https://goo.gl/RYNDBA";
                url.EMS          = "https://goo.gl/vNzGvr";
                url.Mechanic     = "https://goo.gl/rChgek";
                url.Taxi         = "https://goo.gl/DbThWg";
                url.Stream       = "https://goo.gl/EPZpNR";

                url.Logo       = "https://cdn.discordapp.com/attachments/336338554424918017/353934612503855115/GTA5Police_Main.png";
                url.Rules      = "http://goo.gl/7app1D";
                url.HowWeBan   = "https://puu.sh/yG7Nv.png";
                url.ClearCache = "https://gta5police.com/forums/index.php?/topic/921-how-to-clear-fivem-cache/";

                url.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "URL configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "URL configuration has been loaded"));

            if (!File.Exists(devConfigLoc))
            {
                var config = new DevConfig();

                config.DevReports  = 394177874657148940;
                config.Devs        = 0;
                config.Suggestions = 366955141771034625;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Dev config generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Developer configuration has been loaded"));

            if (!File.Exists(ranksConfigLoc))
            {
                var config = new RanksConfig();
                config.EMSHighRanks = 4;
                config.PDHighRanks  = 5;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Ranks configuration generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Ranks configuration has been loaded"));

            if (!File.Exists(autoBansLoc))
            {
                var config = new AutoBans();

                config.Bans = 0;
                config.Save();
                Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Auto bans generated"));
            }
            Logger(new LogMessage(LogSeverity.Debug, "GTA5Police Configuration", "Auto bans has been loaded"));
        }